Skip to content

Commit f201b4f

Browse files
authored
Fix code coverage (#2419)
* Include filter only by packge name as using package source paths can exclude coverage from other packages such as header files reported usign under workspace's install path * formating * Process gcno Process both gcno and gcda coverage files. This option is useful for capturing untested files in the coverage report. * Validate sources Check if every source file exists * Dump statistic Dump total statistic at the end * Branch coverage Include only the most useful branches in the coverage report. * Fix install path * Explicitly exclude packages to ignore rviz package but still explicitly include packages as the include filter is what mostly speeds up processing * Revert "Branch coverage" This reverts commit 20f2894. * Keep path fixes relative to workspace As the working directory used for running code coverage report script is already at the root of the colcon workspace, avoiding the use of unnecessary path globbing
1 parent cb5f90f commit f201b4f

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

‎codecov.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fixes:
22
- "src/navigation2/::"
3+
- "install/::"
34

45
ignore:
56
- "*/**/test/*" # ignore package test directories, e.g. nav2_dwb_controller/costmap_queue/tests

‎tools/code_coverage_report.bash‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,30 @@ mkdir -p ${LCOVDIR}
4242
# - messages, which are auto generated files
4343
# - system tests, which are themselves all test artifacts
4444
# - rviz plugins, which are not used for real navigation
45-
INCLUDE_PACKAGES=$(
45+
EXCLUDE_PACKAGES=$(
4646
colcon list \
47-
--paths-only \
48-
--packages-ignore-regex \
47+
--names-only \
48+
--packages-select-regex \
4949
".*_msgs" \
5050
".*_tests" \
5151
".*_rviz.*" \
5252
| xargs)
53+
INCLUDE_PACKAGES=$(
54+
colcon list \
55+
--names-only \
56+
--packages-ignore \
57+
$EXCLUDE_PACKAGES \
58+
| xargs)
5359

5460
# Capture executed code data.
55-
fastcov \
61+
fastcov --lcov \
5662
-d build \
57-
--exclude test/ \
63+
--exclude test/ $EXCLUDE_PACKAGES \
5864
--include $INCLUDE_PACKAGES \
59-
--output ${LCOVDIR}/total_coverage.info --lcov
65+
--process-gcno \
66+
--validate-sources \
67+
--dump-statistic \
68+
--output ${LCOVDIR}/total_coverage.info
6069

6170
if [ $COVERAGE_REPORT_VIEW = codecovio ]; then
6271
curl -s https://codecov.io/bash > codecov

0 commit comments

Comments
 (0)