I am using gcovr for determining line and branch coverage of my C++ code. However, there are some classes that can't be tested (due to dependencies to the OS) and therefore have 0 coverage. I would like to exclude those from my reports.
I have added the GCOV_EXCL_START (and matching GCOV_EXCL_STOP) comments to the start and end of the file. This successfully excludes the code between the comments from branch coverage, but gcovr still reports 0 line coverage for those files.
/** HEADER INCLUDES **/
/*
* This file is excluded from coverage generation. It attempts to create CANSocket and ZMQSocket objects, which are
* themself untestable. Therefore, this class is also untestable and cannot be covered.
*/
// GCOV_EXCL_START
/** CODE **/
// GCOV_EXCL_STOP
Since the exclusion markers are undocumented (I only found out about them through a comment somewhere on stackoverflow), I don't know whether they're supposed to just exclude branch coverage or should exclude line coverage as well.
I hope someone here can tell me:
- Why line coverage isn't covered by these exclusion markers, and if that is intentional, why?
- How I might exclude the files from line coverage anyway, preferably without having to specify them in the gcovr command as excluded.