Merge branch 'lcov-branch-coverage-tests' into 'master'

Ignore g_return_*if_fail() branches in lcov coverage report

See merge request GNOME/glib!379
This commit is contained in:
Philip Withnall 2018-10-06 13:02:45 +00:00
commit 22d75a0889
5 changed files with 64 additions and 39 deletions

View File

@ -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

View File

@ -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

13
.gitlab-ci/lcovrc Normal file
View File

@ -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

View File

@ -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"

View File

@ -581,41 +581,53 @@ GPrintFunc g_set_printerr_handler (GPrintFunc func);
#else /* !G_DISABLE_CHECKS */
#define g_return_if_fail(expr) G_STMT_START{ \
if G_LIKELY(expr) { } else \
{ \
g_return_if_fail_warning (G_LOG_DOMAIN, \
G_STRFUNC, \
#expr); \
return; \
}; }G_STMT_END
#define g_return_if_fail(expr) \
G_STMT_START { \
if (G_LIKELY (expr)) \
{ } \
else \
{ \
g_return_if_fail_warning (G_LOG_DOMAIN, \
G_STRFUNC, \
#expr); \
return; \
} \
} G_STMT_END
#define g_return_val_if_fail(expr,val) G_STMT_START{ \
if G_LIKELY(expr) { } else \
{ \
g_return_if_fail_warning (G_LOG_DOMAIN, \
G_STRFUNC, \
#expr); \
return (val); \
}; }G_STMT_END
#define g_return_val_if_fail(expr, val) \
G_STMT_START { \
if (G_LIKELY (expr)) \
{ } \
else \
{ \
g_return_if_fail_warning (G_LOG_DOMAIN, \
G_STRFUNC, \
#expr); \
return (val); \
} \
} G_STMT_END
#define g_return_if_reached() G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
G_STRFUNC); \
return; }G_STMT_END
#define g_return_if_reached() \
G_STMT_START { \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
G_STRFUNC); \
return; \
} G_STMT_END
#define g_return_val_if_reached(val) G_STMT_START{ \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
G_STRFUNC); \
return (val); }G_STMT_END
#define g_return_val_if_reached(val) \
G_STMT_START { \
g_log (G_LOG_DOMAIN, \
G_LOG_LEVEL_CRITICAL, \
"file %s: line %d (%s): should not be reached", \
__FILE__, \
__LINE__, \
G_STRFUNC); \
return (val); \
} G_STMT_END
#endif /* !G_DISABLE_CHECKS */