How to use gcovr with ros packages?

asked 2017-06-27 12:10:50 -0500

lstelzner gravatar image

I'm trying to use gcovr to generate code coverage statistics for some of my packages that can be used by the Jenkins Cobertura plugin. I have added the following to my CMakeLists.txt

##setup for coverage
set(COVERAGE "OFF" CACHE STRING "Enable coverage generation.")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage")

I'm using catkin_make_isolated. Due to how catkin generates build_isolated/ and devel_isolated/ I'm not sure how to correctly pass the .gcno .gcda data to gcovr (I found the data in build_isolated/package_name/CMakeFiles/package_name-test.dir/test). Anyone have experience successfully running gcovr on ros packages or know a better code coverage tool that has Jenkin's plugins?

edit retag flag offensive close merge delete



See my project here for an example. I use gcovr/lcov to produce code coverage reports. You will have to do some searching around(see rdl_cmake) as well as how I use gcovr in the .gitlab-ci.yml file in the top level. It's a fully working example though.

jlack gravatar image jlack  ( 2017-06-27 14:20:06 -0500 )edit

Thanks, looking at it helped me figure out how to get it to run locally. I think when I attempted yesterday I had both a build and build_isolated in my workspace which was throwing gcovr off.

lstelzner gravatar image lstelzner  ( 2017-06-27 16:17:57 -0500 )edit