Search code examples
code-coveragegcovlcov

Is there a way to focus lcov code coverage reports to just one or two directories?


I recently started using lcov to visualize my code coverage. It's a great tool.

One thing I'm noticing is that it generates code coverage reports for all the files that I'm using - including those that I'm not interested in. For example, it will give me code coverage reports for boost and mysql++ files.

Is there an easy way to force lcov to only generate coverage reports for specific files?

I have tried using the -k parameter like so:

/usr/bin/lcov -q -c -i -b . -d .obj -k src/ -k include/ -o app_base.info

{run unit tests now}

/usr/bin/lcov -q -c -b . -d .obj -k src/ -k include/ -o app_test.info
/usr/bin/lcov -q -a app_base.info -a app_test.info -o app_total.info
/usr/bin/genhtml -q -o lcov_output_directory app_total.info

(Meaning that I only want coverage files for the "include" and "src" directories.)

However, this doesn't seem to work. The report still shows me all the extraneous files. Any suggestions are very much appreciated. Thanks!


Solution

  • lcov supports a command line argument --remove to do exactly what you are asking for.