Ask Your Question
2

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
2

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 my_fantastic_coverage_report.info

And generated fancy HTML with this.

genhtml my_fantastic_coverage_report.info --output-directory fancy_html_coverage_report

Then just sensible-browser fancy_html_coverage_report/index.html.

edit flag offensive delete link more

Comments

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 (https://github.com/colcon/colcon-mixi...) 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

2 followers

Stats

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

Seen: 425 times

Last updated: Jul 05 '20