Commit df17a08c authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-a/coverage-reports' into 'dev'

Coverage reports

Closes #1696

See merge request !227
parents 507ea3b0 62de1649
Pipeline #31323 passed with stages
in 49 seconds
......@@ -16,6 +16,7 @@ stages:
- test_functional
- test_functional_external
- test_shouldvdj
- coverage
- prepare_release
- release
- valgrind_unit
......@@ -23,6 +24,13 @@ stages:
- prepare_deploy
- deploy_prod
# Anchors
.coverage_dependency: &lcov_artifact
artifacts:
paths:
- algo/lcov_test_*.filtered
expire_in: 6hrs
# Tools
......@@ -46,7 +54,8 @@ test_germlines:
test_algo_unit:
stage: test_unit
script: make -C algo unit
script: make -C algo unit_coverage
<<: *lcov_artifact
only:
- /^feature-.*a.*\/.*$/
......@@ -58,13 +67,27 @@ test_tools_unit:
test_algo_should:
stage: test_functional
script: make -C algo should
script: make -C algo should_coverage
only:
- /^feature-.*a.*\/.*$/
<<: *lcov_artifact
test_algo_shouldvdj:
stage: test_shouldvdj
script: make -C algo shouldvdj
script: make -C algo shouldvdj_coverage
<<: *lcov_artifact
only:
- /^feature-.*a.*\/.*$/
algo_coverage:
stage: coverage
coverage: /^\s*lines\.*:\s+([0-9.]+\%)/
script:
- make -C algo lcov_reports
- mv algo/reports/ coverage
artifacts:
paths:
- coverage/
only:
- /^feature-.*a.*\/.*$/
......
......@@ -6,9 +6,19 @@ else
COVERAGE_OPTION=
endif
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
override CXXFLAGS += $(COVERAGE_OPTION) $(DEBUG)
ifeq ($(LDFLAGS),)
LDFLAGS := $(COVERAGE_OPTION)
endif
COV_OUTFILE?=lcov.out
BASE_PATH=$(dir $(abspath .))
OPTIM=-O2 -DNDEBUG $(COVERAGE_OPTION) $(DEBUG)
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM)
export CXXFLAGS
export LDFLAGS
export CXX
## inspired from http://stackoverflow.com/questions/399850/best-compiler-warning-level-for-c-c-compilers/401276
PARANOID= -Wall -Weffc++ -pedantic \
......@@ -50,7 +60,7 @@ CREATE_VERSION_GIT_H := $(shell test -x ./create-git-version-h.sh && ./create-gi
TEE = python ../tools/tee.py -v
.PHONY: all core lib clean forcedep
.PHONY: all core lib clean forcedep gcovr_reports
all: $(VIDJIL) $(ALIGN_CGI) $(SIMILARITY_CGI) $(SIMILARITY_TOOL)
$(MAKE) -C $(TOOLDIR)
......@@ -63,7 +73,7 @@ static:
###
paranoid: clean
$(MAKE) vidjil OPTIM="$(PARANOID)"
$(MAKE) vidjil CXXFLAGS="$(CXXFLAGS) $(PARANOID)"
###
......@@ -91,17 +101,17 @@ cleanspaced:
$(ALIGN_CGI): cgi/align.o $(LIBCORE)
mkdir -p $(CGIDIR)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(SIMILARITY_CGI): cgi/similarity.o $(LIBCORE)
mkdir -p $(CGIDIR)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(SIMILARITY_TOOL): cgi/similarity.o $(LIBCORE)
mkdir -p $(TOOLDIR)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C core
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
###
......@@ -111,9 +121,9 @@ debug:
$(MAKE) DEBUG="-ggdb"
$(VIDJIL): $(BINDIR)%: $(MAIN).o $(LIBCORE)
$(MAKE) -C core OPTIM="$(OPTIM)"
$(MAKE) -C lib OPTIM="$(OPTIM)"
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS) $(CXXFLAGS)
$(MAKE) -C core
$(MAKE) -C lib
$(CXX) -o $@ $^ $(LDFLAGS) $(LDLIBS)
###
# Subdirectories
......@@ -146,7 +156,7 @@ cleanall: cleancoverage
test:
$(MAKE) -C tests cleantests
$(TEE) '$(MAKE) COVERAGE="$(COVERAGE)" unit' tests/out-unit.log
$(TEE) '$(MAKE) unit' tests/out-unit.log
$(MAKE) functional
@echo
@echo "*** All tests passed. Congratulations !"
......@@ -160,24 +170,27 @@ snapshot_diff:
snapshot_diff_current:
$(MAKE) -C tests snapshot_diff_current
unit: all
unit:
$(MAKE) CXXFLAGS="$(filter-out -DNDEBUG, $(CXXFLAGS))" all
@echo "*** Launching unit tests..."
$(MAKE) COVERAGE="$(COVERAGE_OPTION)" -C tests
$(MAKE) -C tests
@echo "*** All unit tests passed"
functional: all
functional:
$(TEE) '$(MAKE) should' tests/out-should-get.log
$(TEE) '$(MAKE) shouldvdj' tests/out-should-vdj.log
should: all
should:
$(MAKE) CXXFLAGS="$(filter-out -DNDEBUG, $(CXXFLAGS))" all
@echo
@echo "*** Launching .should_get tests..."
$(MAKE) COVERAGE="$(COVERAGE_OPTION)" -C tests should
$(MAKE) -C tests should
@echo "*** All .should_get tests passed"
shouldvdj: all
shouldvdj:
@echo
$(MAKE) COVERAGE="$(COVERAGE_OPTION)" -C tests shouldvdj_if_python
$(MAKE) CXXFLAGS="$(filter-out -DNDEBUG, $(CXXFLAGS))" all
$(MAKE) -C tests shouldvdj_if_python
valgrind_unit:
......@@ -192,27 +205,29 @@ valgrind_should:
coverage: unit_coverage should_coverage
unit_coverage: clean
unit_coverage: cleancoverage
$(MAKE) COVERAGE=1 unit
should_coverage: clean
$(MAKE) COV_OUTFILE=lcov_test_unit gencov
should_coverage: cleancoverage
$(MAKE) COVERAGE=1 should
$(MAKE) COV_OUTFILE=lcov_test_should gencov
shouldvdj_coverage: cleancoverage
$(MAKE) COVERAGE=1 shouldvdj
$(MAKE) COV_OUTFILE=lcov_test_shouldvdj gencov
functional_coverage: cleancoverage
$(MAKE) COVERAGE=1 functional
$(MAKE) COV_OUTFILE=lcov_test_functional gencov
### Reports with gcovr
unit_gcovr: unit_coverage
mkdir -p reports
which gcovr > /dev/null && (gcovr -r . -e tests/ --xml > ../reports/unit_coverage.xml) || echo "gcovr is needed to generate a full report"
should_gcovr: should_coverage
mkdir -p reports
which gcovr > /dev/null && (gcovr -r . -e tests/ --xml > ../reports/should_coverage.xml) || echo "gcovr is needed to generate a full report"
gencov:
which lcov > /dev/null || exit 0
lcov --rc lcov_branch_coverage=1 --rc geninfo_adjust_src_path="$(BASE_PATH)" -d . -c -o $(COV_OUTFILE)
lcov --rc lcov_branch_coverage=1 --remove $(COV_OUTFILE) '/usr/*' '*algo/tests/*' '*algo/lib/*' '*algo/tools/*' -o $(COV_OUTFILE).filtered
### Upload to coveralls.io
unit_coveralls:
coveralls $(COVERALLS_OPTIONS) --exclude release --exclude lib --exclude tests --exclude tools --exclude tests --exclude ../tools --exclude lib --gcov-options '\-lp'
should_coveralls:
coveralls $(COVERALLS_OPTIONS) --exclude release --exclude lib --exclude tests --exclude tools --exclude tests --exclude ../tools --exclude lib --gcov-options '\-lp' -r algo
### Reports with lcov
lcov_reports:
mkdir -p reports
which lcov > /dev/null && (lcov --rc lcov_branch_coverage=1 $(addprefix -a ,$(wildcard lcov*.filtered)) | sed 's_^SF:algo_SF:'"$(BASE_PATH)"'/algo_' > lcov_filtered_total.out && genhtml --branch-coverage --legend --output-directory reports/ lcov_filtered_total.out ) || echo "gcovr is needed to generate a full report"
### cppcheck
......
CXX?=g++
OPTIM=-O2
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
export CXXFLAGS
INC=-I ../
SRCCORE=$(wildcard *.cpp)
OBJCORE=$(SRCCORE:.cpp=.o)
......
CXX?=g++
OPTIM=-O2
override CXXFLAGS += -W -Wall -std=c++11 $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
export CXXFLAGS
SRCCORE=$(wildcard *.cpp unbam/*.c)
TMP_OBJCORE=$(SRCCORE:.cpp=.o)
OBJCORE=$(TMP_OBJCORE:.c=.o)
......
CXX?=g++
INCLUDE=-I ..
OPTIM=-g -O2 $(COVERAGE)
override CXXFLAGS += -std=c++11 -W -Wall $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2
endif
CXXFLAGS := $(filter-out -DNDEBUG,$(CXXFLAGS))
export CXXFLAGS
LDLIBS=-lz
SRC= unit-tests/tests.cpp
EXEC=$(SRC:.cpp=)
......@@ -136,7 +139,7 @@ $(EXEC): % : %.o $(LIB)
vidjil:
$(MAKE) -C ../ clean
$(MAKE) -C ../ OPTIM="$(OPTIM)"
$(MAKE) -C ../
core:
$(MAKE) -C ../core
......
CXX?=g++
OPTIM=-O2
override CXXFLAGS += -std=c++11 -W -Wall -I.. -I../lib/ $(OPTIM)
ifeq ($(CXXFLAGS), )
CXXFLAGS := -W -Wall -std=c++11 -O2 -DNDEBUG
endif
override CXXFLAGS += -I.. -I../lib/
export CXXFLAGS
LDLIBS=-lm -lz
SRC=$(wildcard *.cpp)
EXEC=$(SRC:.cpp=)
......@@ -13,8 +16,8 @@ go: vdj_assign align
all: $(EXEC)
$(EXEC): %: %.o
$(MAKE) -C .. base OPTIM="$(OPTIM)"
$(CXX) -I .. -o $@ $^ $(LIBCORE) $(LDLIBS)
$(MAKE) -C .. base
$(CXX) -I .. -o $@ $^ $(LIBCORE) $(LDLIBS) $(LDFLAGS)
clean:
rm -f $(EXEC)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment