build+ci: add code coverage support
This commit also adds GlobalConfigurationFixture to ensure that running
unit tests doesn't interact with system configuration (e.g., doesn't use
or alter user certificates).
Change-Id: I621ce14425a777c94d41b8132cd2858d91235b4d
Refs: #3808
diff --git a/.jenkins.d/30-coverage.sh b/.jenkins.d/30-coverage.sh
index fc3cbc0..7637b61 100755
--- a/.jenkins.d/30-coverage.sh
+++ b/.jenkins.d/30-coverage.sh
@@ -6,11 +6,27 @@
set -x
-# TODO add code coverage support
-if false && [[ $JOB_NAME == *"code-coverage" ]]; then
+if [[ $JOB_NAME == *"code-coverage" ]]; then
gcovr --object-directory=build \
--output=build/coverage.xml \
- --filter="$PWD/(core|tools)" \
+ --exclude="$PWD/tests" \
--root=. \
--xml
+
+ # Generate also a detailed HTML output, but using lcov (better results)
+ lcov --quiet \
+ --capture --no-external \
+ --directory . \
+ --rc lcov_branch_coverage=1 \
+ --output-file build/coverage-with-tests.info
+
+ lcov --quiet \
+ --remove build/coverage-with-tests.info "$PWD/tests/*" \
+ --rc lcov_branch_coverage=1 \
+ --output-file build/coverage.info
+
+ genhtml --legend \
+ --rc genhtml_branch_coverage=1 \
+ build/coverage.info \
+ --output-directory build/coverage
fi