Ask Your Question

Generating a C++ Code Coverage Report with Colcon

asked 2020-06-19 21:44:26 -0500

allenh1 gravatar image

Just trying to create something similar to the ROS 2 CI for code coverage (example here).

With colcon mixins, I've seen coverage-gcc under build mixins, but I'm not sure how to use it.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-07-05 11:27:04 -0500

allenh1 gravatar image

For those curious, I was able to do it by invoking colcon as follows.

colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="--coverage" -DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON

Then I ran the tests.

colcon test

Finally, I ran lcov.

lcov --capture --directory build/ --output-file

And generated fancy HTML with this.

genhtml --output-directory fancy_html_coverage_report

Then just sensible-browser fancy_html_coverage_report/index.html.

edit flag offensive delete link more


For CI purposes, the following PR may be interesting: ros-industrial/industrial_ci/pull/504.

gvdhoorn gravatar image gvdhoorn  ( 2020-07-05 11:42:54 -0500 )edit

The colcon mixin repository provides a mixinto generate C++ coverage ( which contains all the CMake arguments you need.

Dirk Thomas gravatar image Dirk Thomas  ( 2020-07-06 10:55:13 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-06-19 21:44:26 -0500

Seen: 425 times

Last updated: Jul 05 '20