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?
to your account
go version go1.8 linux/amd64
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
coverage: 26.3% of statements
$ go tool cover -func=profile.cov | tail -1
total: (statements) 26.1%
Not that I've noticed larger differences, up to 1% on other packages.
I expect to see the same coverage number.
Two different coverage percentages.
The text was updated successfully, but these errors were encountered:
CL https://golang.org/cl/44337 mentions this issue.
Sorry, something went wrong.
Found the issue.
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.
http://golang.org/cl/44337 should fix that.
coverage: Add a coverage command
This command computes the coverage percentage of the whole profile.
This is different from what go tool cover -func does because of this
Signed-off-by: Damien Lespiau <email@example.com>
No branches or pull requests