Skip to content

Add test coverage reporting #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ on:
pull_request:
branches:
- "*"
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: install-mingw
- name: Install MinGW
run: "sudo apt-get install gcc-mingw-w64-i686"
- uses: actions/checkout@v2
- name: make
run: make zip
- name: succ
- name: Work around silly artifact uploader
run: unzip flexptools.zip -d flexptools-zip
- run: unzip spin2cpp.zip -d spin2cpp-zip
- uses: actions/upload-artifact@v2.1.3
Expand All @@ -29,10 +35,20 @@ jobs:
name: spin2cpp-git
path: "spin2cpp-zip/*"
test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: make
run: make
- name: test
run: make test_offline
- uses: actions/checkout@v2
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
- name: Install non-buggy GCC/GCOV
run: "sudo apt-get install gcc-8"
- name: make
run: make all TEST_COVERAGE=1 CC=gcc-8 CCOV=gcov-8
- name: test
run: make test_offline TEST_COVERAGE=1 CC=gcc-8 CCOV=gcov-8
- name: gcov
run: make coverage TEST_COVERAGE=1 CC=gcc-8 CCOV=gcov-8
- name: Upload coverage
run: "bash <(curl -s https://codecov.io/bash) -X gcov"
41 changes: 30 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,29 @@ else ifeq ($(CROSS),macosx)
CC=o64-clang -DMACOSX -O
EXT=
BUILD=./build-macosx
else ifeq ($(OS),Windows_NT)
CC=gcc
else ifeq ($(OS),Windows_NT)
ifeq ($(CC),cc)
# Workaround for weird windows/mingw/msys/whatever nonsense
CC=gcc
endif
CC?=gcc
EXT=.exe
BUILD=./build
else
CC=gcc
CC?=gcc
EXT=
BUILD=./build
endif

CCOV?=gcov

ifdef TEST_COVERAGE
BUILD=./build-gcov
CFLAGS+=--coverage -fprofile-dir=$(realpath .) -fprofile-abs-path
endif

export BUILD

INC=-I. -I$(BUILD)
DEFS=-DFLEXSPIN_BUILD

Expand Down Expand Up @@ -106,9 +119,9 @@ endif
#check:
# echo YACC="$(RUNYACC)" YACCVER="$(YACCVER)" YACC_CHECK="$(YACC_CHECK)"

CFLAGS = -g -Wall $(INC) $(DEFS)
#CFLAGS = -no-pie -pg -Wall $(INC) $(DEFS)
#CFLAGS = -g -Og -Wall -Wc++-compat -Werror $(INC) $(DEFS)
CFLAGS += -g -Wall $(INC) $(DEFS)
#CFLAGS += -no-pie -pg -Wall $(INC) $(DEFS)
#CFLAGS += -g -Og -Wall -Wc++-compat -Werror $(INC) $(DEFS)
LIBS = -lm
RM = rm -rf

Expand Down Expand Up @@ -151,7 +164,7 @@ help:

all: $(BUILD) $(PROGS)

$(BUILD)/testlex$(EXT): testlex.c $(LEXOBJS)
$(BUILD)/testlex$(EXT): $(LEXOBJS) $(BUILD)/testlex.o
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)

$(BUILD)/spin.tab.c $(BUILD)/spin.tab.h: frontends/spin/spin.y
Expand All @@ -172,10 +185,16 @@ preproc: preprocess.c $(UTIL)
clean:
$(RM) $(PROGS) $(BUILD)/* *.zip

test_offline: lextest asmtest cpptest errtest p2test
clean_profile:
$(RM) $(BUILD)/*.gcda $(BUILD)/*.gcov

test_offline: $(BUILD) lextest asmtest cpptest errtest p2test
test: test_offline runtest
#test: lextest asmtest cpptest errtest runtest

coverage:
(cd $(BUILD); $(CCOV) testlex.c cmdline.c spin2cpp.c flexspin.c flexcc.c $(SPINSRCS))

lextest: $(PROGS)
$(BUILD)/testlex

Expand All @@ -194,13 +213,13 @@ p2test: $(PROGS)
runtest: $(PROGS)
(cd Test; ./runtests.sh)

$(BUILD)/spin2cpp$(EXT): spin2cpp.c cmdline.c $(OBJS)
$(BUILD)/spin2cpp$(EXT): $(BUILD)/spin2cpp.o $(BUILD)/cmdline.o $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)

$(BUILD)/flexspin$(EXT): flexspin.c cmdline.c $(OBJS)
$(BUILD)/flexspin$(EXT): $(BUILD)/flexspin.o $(BUILD)/cmdline.o $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)

$(BUILD)/flexcc$(EXT): flexcc.c cmdline.c $(OBJS)
$(BUILD)/flexcc$(EXT): $(BUILD)/flexcc.o $(BUILD)/cmdline.o $(OBJS)
$(CC) $(CFLAGS) -o $@ $^ $(LIBS)

$(BUILD):
Expand Down
2 changes: 1 addition & 1 deletion Test/asmtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ "$1" != "" ]; then
SPIN2CPP=$1
else
SPIN2CPP=../build/spin2cpp
SPIN2CPP=../${BUILD:='./build'}/spin2cpp
fi

PROG="$SPIN2CPP -I../Lib"
Expand Down
2 changes: 1 addition & 1 deletion Test/cpptests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ "$1" != "" ]; then
SPIN2CPP=$1
else
SPIN2CPP=../build/spin2cpp
SPIN2CPP=../${BUILD:='./build'}/spin2cpp
fi

PROG="$SPIN2CPP -I../Lib"
Expand Down
2 changes: 1 addition & 1 deletion Test/errtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ "$1" != "" ]; then
PROG=$1
else
PROG=../build/spin2cpp
PROG=../${BUILD:='./build'}/spin2cpp
fi
CC=propeller-elf-gcc
ok="ok"
Expand Down
2 changes: 1 addition & 1 deletion Test/p2bin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ "$1" != "" ]; then
FASTSPIN=$1
else
FASTSPIN=../build/flexspin
FASTSPIN=../${BUILD:='./build'}/flexspin
fi

PROG="$FASTSPIN -q -2b -I../Lib"
Expand Down
4 changes: 2 additions & 2 deletions Test/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ if [ "$1" != "" ]; then
SPIN2CPP=$1
FASTSPIN="$1 --asm --binary --code=hub"
else
SPIN2CPP=../build/spin2cpp
FASTSPIN="../build/flexspin -g -q"
SPIN2CPP=../${BUILD:='./build'}/spin2cpp
FASTSPIN="../${BUILD:='./build'}/flexspin -g -q"
fi

PROG_C="$SPIN2CPP -I../Lib"
Expand Down
4 changes: 2 additions & 2 deletions Test/runtests_bc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ if [ "$1" != "" ]; then
SPIN2CPP=$1
FASTSPIN="$1 -g -q --interp=rom"
else
SPIN2CPP=../build/spin2cpp
FASTSPIN="../build/flexspin -g -q --interp=rom"
SPIN2CPP=../${BUILD:='./build'}/spin2cpp
FASTSPIN="../${BUILD:='./build'}/flexspin -g -q --interp=rom"
fi

PROG_ASM="$FASTSPIN -I../Lib"
Expand Down
4 changes: 2 additions & 2 deletions Test/runtests_p2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ if [ "$1" != "" ]; then
SPIN2CPP=$1
FASTSPIN="$1 --asm --binary --code=hub"
else
SPIN2CPP=../build/spin2cpp
FASTSPIN="../build/flexspin -2 -O2 -g -q"
SPIN2CPP=../${BUILD:='./build'}/spin2cpp
FASTSPIN="../${BUILD:='./build'}/flexspin -2 -O2 -g -q"
fi

PROG_C="$SPIN2CPP -I../Lib"
Expand Down