[glib: 2/3] ci: Add lcov configuration to ignore g_return_*if_fail()/g_assert*()
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] ci: Add lcov configuration to ignore g_return_*if_fail()/g_assert*()
- Date: Sat, 6 Oct 2018 13:03:07 +0000 (UTC)
commit 8efe28c570e1ef0ec25d51e424f6cc1a767b35ce
Author: Philip Withnall <withnall endlessm com>
Date: Wed Oct 3 14:47:26 2018 +0100
ci: Add lcov configuration to ignore g_return_*if_fail()/g_assert*()
While we can’t add markers to the macro implementations to cause lcov to
ignore them automatically, we can change our lcov configuration to
ignore all calls to them.
See https://github.com/linux-test-project/lcov/issues/44.
This causes all the un-takeable branches and un-reachable assertions to
be ignored by our code coverage, which bumps our statistics:
• Lines: 74.9% → 74.8%
• Functions: 82.3% → 82.3%
• Branches: 53.3% → 64.2%
The rationale is that nobody should be testing programmer error
handling, as g_return_*if_fail() are used to guard against — so it’s not
reasonable to count missed branches like that in code coverage
statistics.
Signed-off-by: Philip Withnall <withnall endlessm com>
.gitlab-ci.yml | 4 ++--
.gitlab-ci/coverage-docker.sh | 6 +++---
.gitlab-ci/lcovrc | 13 +++++++++++++
.gitlab-ci/test-msys2.sh | 4 ++--
4 files changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9c790bae6..96d11f805 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -24,9 +24,9 @@ fedora-x86_64:
- meson ${MESON_COMMON_OPTIONS} --werror -Dsystemtap=true -Ddtrace=true -Dfam=true _build
- ninja -C _build
- mkdir -p _coverage
- - lcov --rc lcov_branch_coverage=1 --directory _build --capture --initial --output-file
"_coverage/${CI_JOB_NAME}-baseline.lcov"
+ - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file
"_coverage/${CI_JOB_NAME}-baseline.lcov"
- meson test -C _build --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER}
- - lcov --rc lcov_branch_coverage=1 --directory _build --capture --output-file
"_coverage/${CI_JOB_NAME}.lcov"
+ - lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file
"_coverage/${CI_JOB_NAME}.lcov"
artifacts:
name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
when: always
diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh
index 63e305147..b6421be86 100755
--- a/.gitlab-ci/coverage-docker.sh
+++ b/.gitlab-ci/coverage-docker.sh
@@ -7,14 +7,14 @@ python3 ./.gitlab-ci/fixup-cov-paths.py _coverage/*.lcov
for path in _coverage/*.lcov; do
# Remove coverage from generated code in the build directory
- lcov --rc lcov_branch_coverage=1 -r "${path}" '*/_build/*' -o "$(pwd)/${path}"
+ lcov --config-file .gitlab-ci/lcovrc -r "${path}" '*/_build/*' -o "$(pwd)/${path}"
# Remove any coverage from system files
- lcov --rc lcov_branch_coverage=1 -e "${path}" "$(pwd)/*" -o "$(pwd)/${path}"
+ lcov --config-file .gitlab-ci/lcovrc -e "${path}" "$(pwd)/*" -o "$(pwd)/${path}"
done
genhtml \
--ignore-errors=source \
- --rc lcov_branch_coverage=1 \
+ --config-file .gitlab-ci/lcovrc \
_coverage/*.lcov \
-o _coverage/coverage
diff --git a/.gitlab-ci/lcovrc b/.gitlab-ci/lcovrc
new file mode 100644
index 000000000..3901f81e7
--- /dev/null
+++ b/.gitlab-ci/lcovrc
@@ -0,0 +1,13 @@
+# lcov and genhtml configuration
+# See http://ltp.sourceforge.net/coverage/lcov/lcovrc.5.php
+
+# Always enable branch coverage
+lcov_branch_coverage = 1
+
+# Exclude precondition assertions, as we can never reasonably get full branch
+# coverage of them, as they should never normally fail.
+# See https://github.com/linux-test-project/lcov/issues/44
+lcov_excl_br_line = LCOV_EXCL_BR_LINE|g_return_if_fail|g_return_val_if_fail|g_assert|g_assert_
+
+# Similarly for unreachable assertions.
+lcov_excl_line = LCOV_EXCL_LINE|g_return_if_reached|g_return_val_if_reached|g_assert_not_reached
\ No newline at end of file
diff --git a/.gitlab-ci/test-msys2.sh b/.gitlab-ci/test-msys2.sh
index 0c375bbb7..149c7137c 100755
--- a/.gitlab-ci/test-msys2.sh
+++ b/.gitlab-ci/test-msys2.sh
@@ -44,7 +44,7 @@ ninja
"${LCOV}" \
--quiet \
- --rc lcov_branch_coverage=1 \
+ --config-file .gitlab-ci/lcovrc \
--directory "${DIR}/_build" \
--capture \
--initial \
@@ -55,7 +55,7 @@ meson test --timeout-multiplier ${MESON_TEST_TIMEOUT_MULTIPLIER} || true
"${LCOV}" \
--quiet \
- --rc lcov_branch_coverage=1 \
+ --config-file .gitlab-ci/lcovrc \
--directory "${DIR}/_build" \
--capture \
--output-file "${DIR}/_coverage/${CI_JOB_NAME}.lcov"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]