Showing low coverage because it thinks the file has more lines than it does?

I have 100% code coverage, but codecov is saying I have ≈20% because it is saying the lib file is ≈500 lines when it’s really just ≈100. Anyone run into this? Or know whether it’s an issue with Codecov or with my CI setup?

Codecov link: Codecov
Github link: GitHub - BWStearns/circadian_tools

@BWStearns the quick answer is that it looks like you are uploading coverage for your dependencies. You can see it in the report(click Download on the right) uploaded to Codecov.

Due to the naming of those files (also src/lib.rs), we are aggregating all the coverage. I’m not familiar enough with grcov, but there should be a way to not include the dependency coverage.

1 Like

Ah ok. Thanks a ton for the pointers, first time I’m setting up coverage from scratch in Rust.

1 Like

Oh wait, one more q, why doesn’t Codecov show any of the dependency source?

Because the dependencies are not part of your git tree

1 Like

For anyone who runs across the same issue: I was able to exclude deps by calling grcov like this: grcov . --binary-path ./target/debug --ignore="/*" -s ./src -t lcov --branch --ignore-not-existing -o lcov.info

1 Like

You might have better results if you use -s . --keep-only 'src/**', but it’s been a while since I checked. -s tells consumers of the coverage data where the source tree actually starts, so if they want to map things back to the source code I think it’s easier (some tools do various tricks with the path prefixes so they line up, but it doesn’t always work). Then --keep-only is the thing that acts as a filter to ignore any dependency code in cargo’s build directories.

See my project for an example, and the grcov docs for instructions.

1 Like