Hugo
Hugo

Reputation: 2189

lcov, reporting 0% coverage for not tested headers

i will ask using an example. Let's suppose the following files:

root
    - yes.h
    - not.h
    - test.cpp

"test.cpp" includes "yes.h"

when I run lcov shows the percentage covered in yes.h and in test.cpp, but (and here's my question) I want a zero coverage entry for "not.h", this way I can really have a valuable coverage metric. There's any way to achieve this?

Here's my lcov usage:

g++ --coverage test.cpp
lcov --directory . --zerocounters
lcov -c -i -d . -o app_base.info
./a.out
lcov -c -d . -o app_test.info
lcov -a app_base.info -a app_test.info -o app_total.info
geninfo app_total.info

thanks.

Upvotes: 2

Views: 2165

Answers (1)

alestanis
alestanis

Reputation: 21863

You might want to take a look at the --remove and --extract options for lcov (see the man page). In your case, you might want to change

lcov -a app_base.info -a app_test.info -o app_total.info
geninfo app_total.info

with

lcov -a app_base.info -a app_test.info -o app_tmp.info
lcov --remove app_tmp.info */not.h --output app_total.info
geninfo app_total.info

Upvotes: 2

Related Questions