-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
testing: Coverage() returns different values in 1.21 than 1.19.X #62212
Comments
please include code that demonstrates the difference in coverage. |
this function:
With 1.19.12:
With 1.20.0:
|
I mean, show us the code that is being tested and why the reported coverage percentage for it is incorrect |
Can't do it, it is thousand of lines. I can tell you that I run the same code and the same test suit with different go version with those different results. We have changed the minor version of go a lot of times since we started with go 1.8 and this never was a problem. If that is not enough I can try to do some adhoc code at some moment. |
changed isn't a clear enough signal, we'll need to see if the old or new numbers are the correct ones. |
Here you go:
According to this I would say that the value from
|
Without -race different values:
covermode=count same results:
|
cc @thanm |
I am also seeing this behaviour
|
Looking at the code... it looks like the snapshot function is wrong.
In particular, the tot += uint64(len(sd)) is adding the length of the entire structure which include the length of the counts. As this sd structure looks like this
|
As a potential workaround, running the tests with |
Change https://go.dev/cl/528815 mentions this issue: |
Sum number of counters to obtain total number of coverable units instead of using length of the section data. Updates golang#62212
Any update on this? The possible fix seems that has been abandoned. Thanks |
It was, see CL discussion |
Just noting that this affects us as well; using the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Call testing.Coverage() and comparing the resulting value with the expected vaue that is working in 1.19.X
What did you expect to see?
testing.Coverage() to return the same value as 1.19.X.
I did not update to 1.20.X due to #59590, testing.Coverage() was totally broken in 1.20.X and in principle it was fixed for 1.21.0 but the return value is not the same as 1.19.X, it is quite lower
What did you see instead?
Different values:
The text was updated successfully, but these errors were encountered: