-
Notifications
You must be signed in to change notification settings - Fork 645
Coverage display is misinterpreting the coverprofile file #1683
Comments
FWIW, I was able to modify |
What version of Go are you using? I am using Go 1.9.2 on my Mac. I have tests for code that gets run multiple times too. But the the last number is always 1. |
On my mac, I'm using https://github.com/golang/go/blob/master/src/cmd/cover/profile.go It doesn't appear to have changed lately. Note these lines: https://github.com/golang/go/blob/master/src/cmd/cover/profile.go#L29 Also, please note that my proposed change is equivalent to the current behavior if the value is only a boolean (either 1 or 0), but it continues to work if the value (as documented in the source) is actually a count. It really has to be a count to explain the behavior of the |
Thanks for the links! I'll make the necessary changes which should be out in the next update which should be in the next few days. |
Unfortunately the test coverage feature doesnt have much test coverage itself :( I would prefer if you get the credit for this fix as you found the issue, root cause and the fix it self :) |
Thank you! I'll try to do that in the next couple of days. Thank you so much for your work on this tool. It is really appreciated. |
This bug fix is now out in the latest update to the Go extension (0.6.81) |
I toggled the code coverage view for a package I was working on, and I quickly saw that some of my heavily-tested code was marked as untested.
I used
go tool cover -html=/name/of/the/cover/profile
to show the "official" html version of the same coverage file used by the vscode-go plugin and it showed the correct result.Looking at the code here the test for whether code was covered is checking to see if fileRange[7] is exactly 1.
The comment in the code says:
But in the comments in the Go profiler source, it says:
In other words, the "count" value (the 8th value at index 7) is not a boolean, it is the number of times that code has been executed.
Consequently, code that has been executed many times is instead being marked as not covered.
I believe that the code should be changed from:
to:
I don't have time at the moment to figure out how to build and test a modification to turn this into a PR but hopefully this is enough that someone internal can easily take it on.
The text was updated successfully, but these errors were encountered: