code_coverage icon indicating copy to clipboard operation
code_coverage copied to clipboard

ROS2 support

Open martiniil opened this issue 4 years ago • 4 comments

I just wanted to ask if you already had any thoughts or even progress in providing code-coverage for ros2 packages?

martiniil avatar Sep 11 '21 08:09 martiniil

My understanding is that is unnecessary (for at least C++) in ROS2 - since colcon natively supports code coverage: https://answers.ros.org/question/355388/generating-a-c-code-coverage-report-with-colcon/ - however I haven't actually tried this out yet.

mikeferguson avatar Sep 11 '21 16:09 mikeferguson

I tried it. I still need to create a baseline, add necessary flags, extract the right information from the report, generate html and so on. Is this not what makes your package necessary, or did I miss s.th. important?

martiniil avatar Oct 11 '21 12:10 martiniil

If anyone is looking for an example on how to do this for their repos in CI for ROS2 you can look at the moveit2 repo's github action workflow and our .ci.prepare_codecov script:

  • https://github.com/ros-planning/moveit2/blob/main/.github/workflows/ci.yaml
  • https://github.com/ros-planning/moveit2/blob/main/.ci.prepare_codecov

If you wanted to do the same thing locally you could follow these steps:

  • Build with colcon build --mixin coverage
  • Use lcov to organize and create the coverage report file
  • Use genhtml to generate the report locally

I've used this workflow when writing tests and searching for the last few lines I don't have coverage of.

tylerjw avatar Oct 11 '21 16:10 tylerjw

Concerning CI coverage jobs, this might also be interesting: https://github.com/ros-industrial/industrial_ci/pull/504

martiniil avatar Oct 12 '21 07:10 martiniil