You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the github.com/dlespiau/x86db package for the example below, but the same issue can be reproduced on other packages I have around and so assuming it's a general problem:
$ go test -coverprofile=profile.cov
PASS
coverage: 26.3% of statements
Not that I've noticed larger differences, up to 1% on other packages.
What did you expect to see?
I expect to see the same coverage number.
What did you see instead?
Two different coverage percentages.
The text was updated successfully, but these errors were encountered:
ALTree
changed the title
go test -cover and go tool cover -func don't give the same results
cmd/cover: go test -cover and go tool cover -func don't give the same results
May 28, 2017
cmd/cover/func.go initializes total to 1 for each function. Whereas testing/cover.go only does it once. So if your code has lots of functions with total==0, then discrepancy is going to be high.
This command computes the coverage percentage of the whole profile.
This is different from what go tool cover -func does because of this
bug: golang/go#20515
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
What version of Go are you using (
go version
)?go version go1.8 linux/amd64
What did you do?
I used the
github.com/dlespiau/x86db
package for the example below, but the same issue can be reproduced on other packages I have around and so assuming it's a general problem:Whereas:
Not that I've noticed larger differences, up to 1% on other packages.
What did you expect to see?
I expect to see the same coverage number.
What did you see instead?
Two different coverage percentages.
The text was updated successfully, but these errors were encountered: