Package: colcon-lcov-result
colcon-lcov-resultAn extension forcolcon-coreto provide aggregate
coverage results usingLCOV.LCOV is a graphical front-end for GCC’s coverage testing toolgcov, producing the following
coverage metrics:Statement coverageFunction coverageBranch coverageFor more information, seethis paperandthis Wikipedia page.UsageBuild your packages with coverage flags, usingcolcon:$colconbuild\--symlink-install\--cmake-args\-DCMAKE_CXX_FLAGS='-fprofile-arcs -ftest-coverage'\-DCMAKE_C_FLAGS='-fprofile-arcs -ftest-coverage'See alsocolcon-mixinandcolcon-mixin-repositoryfor a short-hand command (--mixincoverage-gcc)Create a baseline for zero coverage:$colconlcov-result--initialThis step is optional, but will help reveal any files that are untouched by
testsRun tests:$colcontestGather thelcovresults:$colconlcov-resultReadingtracefile/home/user/workspace/my_cool_ws/lcov/total_coverage.infoSummarycoveragerate:lines......:78.6%(44of56lines)functions..:94.4%(34of36functions)branches...:37.0%(34of92branches)Browse the coverage report by openinglcov/index.htmlin a browserZero the coverage counters and re-run tests:$colconlcov-result--zero-counters$colconlcov-result--initial$colcontest$colconlcov-resultReadingtracefile/home/user/workspace/my_cool_ws/lcov/total_coverage.infoSummarycoveragerate:lines......:78.6%(44of56lines)functions..:94.4%(34of36functions)branches...:37.0%(34of92branches)Tips and TricksWhen running locally, use the--packages-selectoption to generate
coverage information for relevant packagesThis will also suppress warnings for packages that were either not built
with coverage flags or for which tests did not runThe--verboseflag can be used to print the coverage summary of each
individual package as the results are analyzedContributingFor non-trivial contributions, it is recommended to first create an issue to discuss
your ideas.The following is the recommended workflow for contributing:Installcolconand extensions in a virtual environment:$cd<workspace>$python3-mvenvcolcon-env$sourcecolcon-env/bin/activate$pip3installcolcon-common-extensionsInstallcolcon-lcov-resultin editable mode:$cd<workspace>$python3-mvenvcolcon-env$sourcecolcon-env/bin/activate$cdpath/to/colcon-lcov-result$pip3install-e.As long as you are in the virtual environment, make changes tocolcon-lcov-resultruncolconlcov-result, and see the effect of the changesCommit changes and submit a PR:SeeThe seven rules of a great Git commit messageTroubleshootingThe following warning when runningcolconlcov-result--initialimplies
that the package was not built with the correct flags:---stderr:my_pkggeninfo:WARNING:no.gcnofilesfoundin/home/user/workspace/build/my_pkg-skipping!---The package will not show up in the final results. Use--packages-skipto suppress
the warningThe following warning when runningcolconlcov-resultimplies that no tests
ran for that package[0.576s]ERROR:colcon.colcon_lcov_result.task.lcov:lcov:ERROR:novalidrecordsfoundintracefile/home/user/workspace/build/my_pkg/coverage.info---stderr:my_pkggeninfo:WARNING:no.gcdafilesfoundin/home/user/workspace/build/my_pkg-skipping!---The package will show up in the final results with 0% coverage. Use--packages-skipto suppress these packages from the totalKnown IssuesThe final step of aggregating all the result files can be slow depending
on the number of packages that were analyzed