1

I'm generating code coverage for a C++ project.

My project has multiple binaries in it. When I'm running unit tests, it generates the gcda files and I generate code coverage based on the respective gcda and gcno files.
This is the command I run:

gcovr --gcov-ignore-parse-errors -r $repositoryRootDir `
--object-directory $gcdaSourceDir --xml "outputDir/coverage_cpp_$currentTime.xml" 

Everytime I run gcovr, it generates the coverage for the entire repository, which is not ideal for my use case.

How do I make sure that only certain binaries (or gcda files) are covered in the coverage?

Note: I would love to avoid filter or exclude flags, looking at the shape and structure of the repo if that is an option.

5
  • Does the --filter ... option not do what you want? Commented Jun 11 at 17:53
  • I was wondering if there was a way to apply the filter based on the gcda files. The projects I'm dealing with have pretty complicated directory structure, it might get very complicated to start adding filters. Commented Jun 11 at 18:04
  • 2
    What exactly do you mean by "filter based on the gcda files"? Given a specific gcda file how would you determine whether or not its associated source file should form part of the report? Commented Jun 11 at 18:14
  • 1
    lcov does what you want - if I understand what you want. In particular, if you don't use either of the --all or --initial flags during capture, then only the GCDA files will be processed. This does involve using a different tool, though. Perhaps not what you want. Commented Jun 11 at 20:43
  • How do you decide what the "certain binaries" you want coverage for are? Commented Jun 15 at 17:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.