From b4ce81b1c901137b994ccfcefc71475e161b5fa9 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 15 Mar 2018 02:54:01 +0100 Subject: [PATCH] Move test coverage generation into Makefile Add the necessary compiler flags to the Makefile to actually make coverage reports available locally, too. The coverage files have to get cleaned every time before the test gets run. Otherwise, it would sum up the coverage over multiple test runs. --- .gitignore | 3 +++ .travis.yml | 4 ++-- Makefile | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 68d723e..03b8a91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ dunst *.o +*.gcda +*.gcno +*.gcov core vgcore.* dunst.1 diff --git a/.travis.yml b/.travis.yml index 76e9979..4cf6e64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,8 +26,8 @@ before_install: script: - CFLAGS="-Werror" make all dunstify test-valgrind doc-doxygen - - make clean - - CFLAGS="-Werror -fprofile-arcs -ftest-coverage -O0" make test + - CFLAGS="-Werror" make clean + - CFLAGS="-Werror" make test-coverage matrix: include: diff --git a/Makefile b/Makefile index 5261b17..91b8dc1 100644 --- a/Makefile +++ b/Makefile @@ -69,8 +69,8 @@ dunst: ${OBJ} main.o dunstify: dunstify.o ${CC} -o ${@} dunstify.o ${CFLAGS} ${LDFLAGS} -.PHONY: test test-valgrind -test: test/test +.PHONY: test test-valgrind test-coverage +test: test/test clean-coverage-run cd test && ./test test-valgrind: test/test @@ -84,6 +84,9 @@ test-valgrind: test/test --error-exitcode=123 \ ./test +test-coverage: CFLAGS += -fprofile-arcs -ftest-coverage -O0 +test-coverage: test + test/test: ${OBJ} ${TEST_OBJ} ${CC} -o ${@} ${TEST_OBJ} ${OBJ} ${CFLAGS} ${LDFLAGS} @@ -104,8 +107,8 @@ service-systemd: @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service endif -.PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests -clean: clean-dunst clean-dunstify clean-doc clean-tests +.PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests clean-coverage clean-coverage-run +clean: clean-dunst clean-dunstify clean-doc clean-tests clean-coverage clean-coverage-run clean-dunst: rm -f dunst ${OBJ} main.o @@ -123,6 +126,14 @@ clean-doc: clean-tests: rm -f test/test test/*.o +clean-coverage: clean-coverage-run + find . -type f -name '*.gcno' -delete + find . -type f -name '*.gcna' -delete +# Cleans the coverage data before every run to not double count any lines +clean-coverage-run: + find . -type f -name '*.gcov' -delete + find . -type f -name '*.gcda' -delete + .PHONY: install install-dunst install-doc \ install-service install-service-dbus install-service-systemd \ uninstall \