2

I am using googletest in conjunction with gcovr which is producing some odd behavior. I have a header file foo.h that gcovr claims has some lines that are not being covered under a test. These lines are the class definition and the move constructor:

File  Lines Exec Cover Missing
foo.h 42    40   95%   39,47

Where line 39 is:

class foo

and line 47 is:

foo(foo&&) = default;

I have tried explicitly calling this function in a test body with std::move(), to no avail. Is there a solution to this problem, or am I stuck with a 99% coverage report?

I should note, there is no implementation in this header apart from the class definition and the copy/move semantics (which are all defined as default); all function bodies are in foo.cpp.

David Freitag
  • 2,252
  • 2
  • 16
  • 18

2 Answers2

0

It appears that the only way to get these lines to be removed from the coverage report as "uncovered" is to remove them from the header. This does not really affect anything since they are just setting copy/move/dtor to default. Everywhere else where these are actually implemented or deleted does not show up on the coverage report.

David Freitag
  • 2,252
  • 2
  • 16
  • 18
0

You can exclude some lines from the coverage calculation with special comments. This behaviour is undocumented, but stable. You can:

  • exclude a line that contains GCOVR_EXCL_LINE
  • exclude a region of lines between GCOVR_EXCL_START and GCOVR_EXCL_STOP.

The marker can start with GCOVR or LCOV in case you are using that tool as well. Lcov's branch exclusion markers are not currently supported.

amon
  • 57,091
  • 2
  • 89
  • 149