Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line Coverage and Number of Lines in the HTML report are different from grcov #315

Open
qveera opened this issue Sep 22, 2023 · 1 comment
Labels
C-question Category: A question S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.

Comments

@qveera
Copy link

qveera commented Sep 22, 2023

How it calculates the number of the lines? When I compare it with grcov reports, grcov is providing proper reports compared to cargo-llvm-cov.

@taiki-e
Copy link
Owner

taiki-e commented Sep 22, 2023

Please provide a detailed description and reproduction of the problem.


How it calculates the number of the lines?

This is handled by llvm-cov that included in llvm-tools{,-preview} component.


FYI, I have previously received questions from others regarding the differences between grcov and cargo-llvm-cov coverage results, and the following is the explanation I provided at that time.

FWIW, as for the difference in coverage results between grcov and cargo-llvm-cov, I think it is related to the fact that grcov seems to count coverage of test files by default, while cargo-llvm-cov tries to avoid this as much as possible.

The reason for cargo-llvm-cov tries to avoid this as much as possible is that counting the coverage of the test code itself as part of the coverage of the test target (library or binary being tested) would result in a different coverage than the actual coverage of the test target.1 (in many cases the test code itself is 100% covered)

So, it is not surprising that the coverage percentages drop when switching from grcov to cargo-llvm-cov; rather, it is maybe more accurate result of the coverage of the test target.

Footnotes

  1. The approach adopted by cargo-llvm-cov is not yet perfect, although

@taiki-e taiki-e added the C-question Category: A question label Sep 22, 2023
@taiki-e taiki-e changed the title Line Coverage and Number of Lines in the HTML report are not proper Line Coverage and Number of Lines in the HTML report are different from grcov Sep 22, 2023
@taiki-e taiki-e added needs-mcve Call for participation: This issue needs a Minimal Complete and Verifiable Example S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. and removed needs-mcve Call for participation: This issue needs a Minimal Complete and Verifiable Example labels Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-question Category: A question S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress.
Projects
None yet
Development

No branches or pull requests

2 participants