Strict mode for requiring full line coverage (in gcov)?
For some years, we've slowly been adding newlines to code to improve our code coverage due to {covr} reporting full coverage of partially-covered lines, e.g.
-if (verbose) Rprintf("reached.\n");
+if (verbose)
+ Rprintf("reached.\n");
Now I am learning a bit more about gcov internals:
https://github.com/Rdatatable/data.table/issues/6950#issuecomment-2863266519
It seems gcov indeed recognizes this line is only partially covered if the test suite always uses verbose=0 by reporting 1* "partially covered":
https://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html
Can this somehow be reported to the user? Is there any option to require lines be fully-covered in order for codecov to consider them "covered" in a 0/1 sense?
Looks like as of today, we only check for "uncovered":
https://github.com/r-lib/covr/blob/d8d33b41b6b013a3e96ea04cb6d1bf434c4822d2/R/compiled.R#L32-L40
To start with we can add maybe("*") here to account for these "unexecuted blocks" for partial coverage:
https://github.com/r-lib/covr/blob/d8d33b41b6b013a3e96ea04cb6d1bf434c4822d2/R/compiled.R#L19
With that, I can get something like this in the matches data.frame:
# coverage line
# 102 20* 98
How about gcov --json-format? The feature is old enough to be in Debian Stable. It may prove easier to parse than the normal text output.
I had the same thought but it feels like a much bigger project to ensure everything keeps WAI: #609
Happily {jsonlite} is already Imports:
https://github.com/r-lib/covr/blob/d8d33b41b6b013a3e96ea04cb6d1bf434c4822d2/DESCRIPTION#L51