ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
3

Generating a C++ Code Coverage Report with Colcon

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

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
4

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

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 -0600 )edit
1

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 -0600 )edit

That's nice to get back the details of the commands but can you get back the CmakeModule to directly generate report as new target ?

TomSon gravatar image TomSon  ( 2021-11-05 10:23:18 -0600 )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

3 followers

Stats

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

Seen: 966 times

Last updated: Jul 05 '20