Do code coverage analysis, and publish the results to GitLab Pages.

This commit is contained in:
Jason S. Ninneman 2017-06-02 15:02:34 -07:00
parent aef609291d
commit 900f8d9df5
3 changed files with 28 additions and 8 deletions

View file

@ -3,6 +3,7 @@ image: alpine
stages:
- build
- test
- deploy
# build advent itself
binary:
@ -15,6 +16,8 @@ binary:
artifacts:
paths:
- advent
- "*.gcda"
- "*.gcno"
# cache outputs to reduce the build time
cache:
paths:
@ -47,7 +50,24 @@ test:
stage: test
before_script:
- apk update
- apk add make
- apk add make gcc
- apk add lcov --update-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
script:
- cd tests
- make
- cd ..
- lcov -t "advent" -o advent.info -c -d .
- genhtml -o coverage advent.info
artifacts:
paths:
- coverage
pages:
stage: deploy
script:
- mv coverage public
artifacts:
paths:
- public
only:
- master

View file

@ -1,7 +1,7 @@
# Makefile for the open-source release of adventure 2.5
CC?=gcc
CCFLAGS=-std=c99
CCFLAGS=-std=c99 -O0 --coverage
LIBS=
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
@ -12,10 +12,10 @@ OBJS=main.o init.o actions1.o actions2.o score.o misc.o database.o
SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO adventure.text advent.text control advent.h funcs.h
.c.o:
$(CC) $(CCFLAGS) -O $(DBX) -c $<
$(CC) $(CCFLAGS) $(DBX) -c $<
advent: $(OBJS) database.o
$(CC) $(CCFLAGS) -O $(DBX) -o advent $(OBJS) $(LIBS)
$(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) $(LIBS)
main.o: advent.h funcs.h database.h
@ -38,7 +38,7 @@ compile: compile.c
database.c database.h: compile adventure.text
./compile
$(CC) $(CCFLAGS) -O $(DBX) -c database.c
$(CC) $(CCFLAGS) $(DBX) -c database.c
clean:
rm -f *.o advent advent.html advent.6 database.[ch] compile

View file

@ -18,10 +18,10 @@ clean:
# Show summary lines for all tests.
testlist:
@grep --text '^##' *.log
@grep '^##' *.log
listcheck:
@for f in *.log; do \
if ( head -3 $$f | grep --text -q '^ *##' ); then :; else echo "$$f needs a description"; fi; \
if ( head -3 $$f | grep -q '^ *##' ); then :; else echo "$$f needs a description"; fi; \
done
# General regression testing of commands and output; look at the *.log and
@ -34,7 +34,7 @@ buildregress:
done
regress:
@for file in $(TESTLOADS); do \
$(ECHO) -n " $${file} "; grep --text '##' $${file}.log || echo ' ## (no description)'; \
$(ECHO) -n " $${file} "; grep '##' $${file}.log || echo ' ## (no description)'; \
if advent < $${file}.log >/tmp/regress$$$$ 2>&1; \
then diff --text -u $${file}.chk /tmp/regress$$$$ || exit 1; \
else echo "*** Nonzero return status on $${file}!"; exit 1; fi \