An extension for colcon-core <https://github.com/colcon/colcon-core>
to provide aggregate
coverage results using LCOV <http://ltp.sourceforge.net/coverage/lcov.php>
.
LCOV is a graphical front-end for GCC's coverage testing tool
gcov <https://gcc.gnu.org/onlinedocs/gcc/Gcov.html>
_, producing the following
coverage metrics:
For more information, see this paper <http://ltp.sourceforge.net/documentation/technical_papers/gcov-ols2003.pdf>
_
and this Wikipedia page <https://en.wikipedia.org/wiki/Code_coverage>
_.
colcon
:.. code-block:: shell
$ colcon build \
--symlink-install \
--cmake-args \
-DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage' \
-DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage'
colcon-mixin <https://github.com/colcon/colcon-mixin>
and
colcon-mixin-repository <https://github.com/colcon/colcon-mixin-repository/blob/master/coverage.mixin>
for a short-hand command (--mixin coverage-gcc
).. code-block:: shell
$ colcon lcov-result --initial
.. code-block:: shell
$ colcon test
lcov
results:.. code-block:: shell
$ colcon lcov-result
Reading tracefile /home/user/workspace/my_cool_ws/lcov/total_coverage.info
Summary coverage rate:
lines......: 78.6% (44 of 56 lines)
functions..: 94.4% (34 of 36 functions)
branches...: 37.0% (34 of 92 branches)
lcov/index.html
in a browser.. code-block:: shell
$ colcon lcov-result --zero-counters
$ colcon lcov-result --initial
$ colcon test
$ colcon lcov-result
Reading tracefile /home/user/workspace/my_cool_ws/lcov/total_coverage.info
Summary coverage rate:
lines......: 78.6% (44 of 56 lines)
functions..: 94.4% (34 of 36 functions)
branches...: 37.0% (34 of 92 branches)
When running locally, use the --packages-select
option to generate
coverage information for relevant packages
The --verbose
flag can be used to print the coverage summary of each
individual package as the results are analyzed
For non-trivial contributions, it is recommended to first create an issue to discuss your ideas.
The following is the recommended workflow for contributing:
colcon
and extensions in a virtual environment:.. code-block:: shell
$ cd <workspace>
$ python3 -m venv colcon-env
$ source colcon-env/bin/activate
$ pip3 install colcon-common-extensions
colcon-lcov-result
in editable mode:.. code-block:: shell
$ cd <workspace>
$ python3 -m venv colcon-env
$ source colcon-env/bin/activate
$ cd path/to/colcon-lcov-result
$ pip3 install -e .
colcon-lcov-result
run colcon lcov-result
, and see the effect of the changes
The seven rules of a great Git commit message
_.. _The seven rules of a great Git commit message: https://chris.beams.io/posts/git-commit/#seven-rules
The following warning when running colcon lcov-result --initial
implies
that the package was not built with the correct flags:
.. code-block:: shell
--packages-skip
to suppress
the warningThe following warning when running colcon lcov-result
implies that no tests
ran for that package
.. code-block:: shell
--packages-skip
to suppress these packages from the totalon the number of packages that were analyzed
See DEVELOPING.md <DEVELOPING.md>
_.