3

I am creating code coverage reports for my C++ projects using gcov/lcov, and I am trying to remove all files except the ones in a certain directory from the coverage report (i.e. I do not want different dependencies in various folders to show up in the report).

However I want to do this automatically and not manually. I tried the following:

lcov -r coverage.total '!(<path>)' -o coverage.info

But then lcov comes back with Deleted 0 files. I also tried !(<path>), '[^path]*' and slight variations of these but nothing seems to work. I can manually remove the undesired folders for example the following does work:
lcov -r coverage.total '/usr/libs/*' '/usr/mylibs/*' -o coverage.info

So my question is, how can I have lcov exclude all but a specific directory?

P.S.

  • I am open to workarounds (for example if this can be done with a bash script)
  • I am using bash+CMake+gcov+lcov

P.S.

This is not a duplicate of this question. I am asking about an automated way to only include files in a specific directory in the report. (for example the current directory) I am aware of the --remove argument but that is not an automated solution.

Your help is greately appreciated!

pooya13
  • 2,060
  • 2
  • 23
  • 29
  • Why the down-vote? – pooya13 Feb 20 '19 at 23:22
  • I didn't DV, but it seems the c++ tag without specific c++ code wasn't well appreciated. Also there seems to be an easy to fing duplicate [https://stackoverflow.com/questions/837639/is-there-a-way-to-focus-lcov-code-coverage-reports-to-just-one-or-two-directorie]() – πάντα ῥεῖ Feb 20 '19 at 23:23
  • @πάνταῥεῖ It is not a duplicate. As I mentioned in my question I want to do this automatically. Using the --remove flag would require me to do this manually for all unwanted folders for each report. I want to only include a specific folder (for example the project folder or the current directory). – pooya13 Feb 23 '19 at 05:25

0 Answers0