Open detly opened 1 month ago
The closest I can get, by the way, is with
grcov . --binary-path build --source-dir . --output-path cov --output-types html --ignore-not-existing --prefix-dir '../'
Then my coverage report looks like:
Still no one.c
though.
If --source-dir is set to build
does it resolve correctly?
If --source-dir is set to
build
does it resolve correctly?
Nope, it's completely empty, like in the first screenshot.
I am starting to think it's an issue with the HTML renderer and not the input handling. Here's Cobertura output from the following command:
grcov . --binary-path build --source-dir . --output-path cov.xml --output-types cobertura --ignore-not-existing --prefix-dir '../'
All of the appropriate paths are present, and can be joined up to perfectly match the source tree. Why aren't they in the HTML output though?
I thought I'd try to work around this by using gcovr to generate lcov data, and consume that with grcov:
$ gcovr --root=. --lcov cov.info --lcov-test-name gcovr
(INFO) Reading coverage data...
(INFO) Writing coverage report...
$ lcov -l cov.info
|Lines |Functions |Branches
Filename |Rate Num|Rate Num|Rate Num
=================================================================
[/home/jason/Code/meson-grcov/]
one/src/one.c |50.0% 2| 0.0% 1| - 0
one/test/test_one.c |22.2% 9| 0.0% 2| - 0
test_main.c |33.3% 3| 0.0% 1| - 0
=================================================================
Total:|28.6% 14| 0.0% 4| - 0
$ grcov cov.info --binary-path build --source-dir . --output-path cov --output-types html --ignore-not-existing
I still have the missing paths, but now I also have extremely suspicious line hit counts:
I've been trying to use grcov on a C project that uses Meson as a build system and GCC to compile. Meson does out-of-tree builds where binary artifacts are put in a separate build directory eg.
build
, possibly within the source tree. GCC seems to generategcno
files with a leading../
. I cannot figure out how to tell grcov how to handle this.Here is an example project, with an example CI job. Note the warnings:
I have tried many combinations of the main path argument,
--binary-path
,--source-dir
,--prefix-dir
, changing the current directory tobuild
, using absolute paths wherever possible, etc. At best, I can get coverage for thetest_main.c
file, but never forone/src/one.c
.The example HTML output looks like this:
Frustratingly, the cobertura output sometimes contains perfectly valid paths. They are just not present in the HTML output.
It is possible to generate a proper coverage HTML report with gcovr using the following command:
...so it is possible to use the coverage information generated by Meson and GCC there:
Version information: