-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
-Cinstrument-coverage
produces invalid coverage mapping for the test harness's entry point
#110749
Comments
I did some initial investigation, and discovered a few things:
*: There are special circumstances where it's legal for a region to have 0 for its start column and its end column, but that isn't what's happening here. |
-Cinstrument-coverage
produces invalid coverage mapping for the test runner's entry point-Cinstrument-coverage
produces invalid coverage mapping for the test harness's entry point
The origin of the bogus (1,0) to (1,1) region seems to be:
|
My first thought was to sidestep the whole issue by adding However, I couldn’t get that to work, because So I think the fix will involve having the instrumentor detect and skip code with dummy spans. |
@rustbot label +A-code-coverage |
#97368 fixes the overflow, which gets rid of the duplicate line. However, the instrumentor still ends up emitting an empty region from (1,1) to (1,1) for the test harness's |
I think the empty region now confusing the
It makes sense that line 1 is “covered” (via the injected |
It looks like |
Take this simple crate:
If I try to gather code coverage for
cargo test
, I end up with the first line mysteriously duplicated as a covered region:(I'm using
cargo-llvm-cov
for convenience, but the same thing happens when I useRUSTC_FLAGS="-Cinstrument-coverage"
and process the coverage data manually withllvm-profdata
andllvm-cov
.)Note that in the report produced by
llvm-cov
, the first line of the file appears twice. It is marked as having executed once, even though it is a comment.Instead, the line should only appear once, and its execution count (if any) should be the execution count of the actual code on that line.
Meta
The text was updated successfully, but these errors were encountered: