Skip to content

Commit

Permalink
Fix code coverage (ros-navigation#2419)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ruffsl authored Jun 23, 2021
1 parent cb5f90f commit f201b4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
fixes:
- "src/navigation2/::"
- "install/::"

ignore:
- "*/**/test/*" # ignore package test directories, e.g. nav2_dwb_controller/costmap_queue/tests
Expand Down
21 changes: 15 additions & 6 deletions tools/code_coverage_report.bash
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,30 @@ mkdir -p ${LCOVDIR}
# - messages, which are auto generated files
# - system tests, which are themselves all test artifacts
# - rviz plugins, which are not used for real navigation
INCLUDE_PACKAGES=$(
EXCLUDE_PACKAGES=$(
colcon list \
--paths-only \
--packages-ignore-regex \
--names-only \
--packages-select-regex \
".*_msgs" \
".*_tests" \
".*_rviz.*" \
| xargs)
INCLUDE_PACKAGES=$(
colcon list \
--names-only \
--packages-ignore \
$EXCLUDE_PACKAGES \
| xargs)

# Capture executed code data.
fastcov \
fastcov --lcov \
-d build \
--exclude test/ \
--exclude test/ $EXCLUDE_PACKAGES \
--include $INCLUDE_PACKAGES \
--output ${LCOVDIR}/total_coverage.info --lcov
--process-gcno \
--validate-sources \
--dump-statistic \
--output ${LCOVDIR}/total_coverage.info

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

0 comments on commit f201b4f

Please sign in to comment.