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

Runcible picture Runcible · May 8, 2009 · Viewed 24.3k times · Source

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!

Answer

lothar picture lothar · May 8, 2009

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