Code coverage reporting utility

This commit is contained in:
Robert Bendun 2022-05-02 22:09:11 +02:00
parent 0eeb21c885
commit c8acceb329
2 changed files with 11 additions and 3 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.ccls-cache .ccls-cache
bin/* bin/*
compile_commands.json compile_commands.json
coverage

View File

@ -1,6 +1,6 @@
MAKEFLAGS="-j $(grep -c ^processor /proc/cpuinfo)" MAKEFLAGS="-j $(grep -c ^processor /proc/cpuinfo)"
CXXFLAGS=-std=c++20 -Wall -Wextra -O2 -Werror=switch CXXFLAGS:=$(CXXFLAGS) -std=c++20 -Wall -Wextra -Werror=switch
CPPFLAGS=-Ilib/expected/ -Ilib/ut/ -Isrc/ CPPFLAGS:=$(CPPFLAGS) -Ilib/expected/ -Ilib/ut/ -Isrc/
Obj=bin/errors.o \ Obj=bin/errors.o \
bin/lexer.o \ bin/lexer.o \
@ -9,7 +9,6 @@ Obj=bin/errors.o \
all: bin/musique bin/unit-tests all: bin/musique bin/unit-tests
bin/%.o: src/%.cc src/*.hh bin/%.o: src/%.cc src/*.hh
g++ $(CXXFLAGS) $(CPPFLAGS) -o $@ $< -c g++ $(CXXFLAGS) $(CPPFLAGS) -o $@ $< -c
@ -20,6 +19,14 @@ bin/musique: $(Obj) bin/main.o src/*.hh
unit-tests: bin/unit-tests unit-tests: bin/unit-tests
./$< ./$<
unit-test-coverage:
CXXFLAGS=--coverage $(MAKE) bin/unit-tests -B
bin/unit-tests
rm -rf coverage
mkdir coverage
gcovr -e '.*\.hpp' --html --html-details -o coverage/index.html
rm -rf bin
bin/unit-tests: src/tests/*.cc $(Obj) bin/unit-tests: src/tests/*.cc $(Obj)
g++ $(CXXFLAGS) $(CPPFLAGS) -o $@ $^ g++ $(CXXFLAGS) $(CPPFLAGS) -o $@ $^