code_coverage icon indicating copy to clipboard operation
code_coverage copied to clipboard

Coverage of multiple packages

Open MCFurry opened this issue 3 years ago • 3 comments

Let's say I have a couple of packages in my workspace and want to generate a coverage report for all the code in all packages that gets touched using a single test. How would I go with this? I can add the needed depends and CMakeLists entries to all packages that I want a report from. But when I run my test and generate a report, it will only do this for the package the test ran from?

MCFurry avatar Jun 16 '21 12:06 MCFurry

There really isn't a great way to do this within catkin - because each package doesn't know about the others. My typical approach to this (in CI) has been to upload the individual package results to a service like CodeCov.io and then let it do the aggregation. In theory, you could also do that locally with a script running each individual coverage target, storing the results, and the merging the results afterwards.

mikeferguson avatar Jun 17 '21 04:06 mikeferguson

Hmm, actually, I may have misunderstood your question at first. It sounds like all your tests are in a single package, but you don't get coverage data from outside of that. In that case, you are probably looking at this line being the culprit: https://github.com/mikeferguson/code_coverage/blob/master/cmake/Modules/CodeCoverage.cmake#L177 - namely the /${PROJECT_NAME}/ limits the scope to whats inside the package folder - otherwise you'd also get data from all sorts of system libraries.

mikeferguson avatar Jun 17 '21 04:06 mikeferguson

Exactly, in one of the packages I have a single test that depends on the other packages and also starts nodes from these packages. Am I correct that running the binaries (when build with coverage flags) will produce coverage files but they are simply not in the final report? Or don't they generate any coverage information at all?

If they do, I might indeed write a simple script that collects all coverage information, but I'm not sure then if this is possible and where to look for which files?

MCFurry avatar Jun 17 '21 12:06 MCFurry