Unable to generate code coverage using colcon + mixins

asked 2023-06-07 13:44:05 -0500

hugols16 gravatar image

updated 2023-06-07 15:28:28 -0500

When running colcon build and colcon test, code coverage is not generated, and therefore lcov-result and coveragepy-result can't collect the coverage data.

The build command is as follows: colcon build --symlink-install --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DAMENT_CMAKE_PYTEST_WITH_COVERAGE=ON -DCMAKE_C_FLAGS=--coverage -DCMAKE_CXX_FLAGS=--coverage --no-warn-unused-cli

And the test command is as follows: colcon test --ctest-args -DAMENT_CMAKE_PYTEST_WITH_COVERAGE=ON --rerun-failed --output-on-failure --cov-report=term --python-testing pytest --pytest-with-coverage

The packages build successfully without warnings or errors, and the tests succeed without failures or errors. However, within the build/<package_name directory, there are no coverage files... Unsure what I'm doing wrong, or what arguments/processes I may be missing.

Using mixins

I've also tried using mixins to match the process from above, and again, building and testing works, but coverage isn't applied.

The build command is as follows: colcon build --mixin coverage-gcc coverage-pytest compile-commands build-testing-on

And the test command is as follows: colcon test --ctest-args --rerun-failed --output-on-failure --mixin coverage-pytest

Notes:

colcon is installed under /usr/bin/colcon. I've installed colcon-mixin and added the mixins from the main repository. I've tried passing it the colcon arguments directly and also using the coverage-gcc and coverage-pytest mixins, never of which worked. Also, this workspace has multiple packages dependent on each other, and is a mixture of c++ and python, mostly python.

edit retag flag offensive close merge delete

Comments

No idea, just saying, have you tried setting built type as DEBUG?

130s gravatar image 130s  ( 2023-06-08 06:21:32 -0500 )edit