-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/go: go test -cover reports 0% coverage on pure struct packages #25492
Comments
This is an expected behavior of the cover tool. Type struct is not a statement. |
Yes, but cover could print something else than |
What about
coverage: 0.0% of 0 statements
?
… On 22 May 2018, at 19:26, egonk ***@***.***> wrote:
Yes, but cover could print something else than coverage: 0.0% of statements if there are no statements. I think this is a valid scenario: pure protocol description packages.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, this looks ok to me. Or maybe |
Strictly speaking, we should not print
|
This looks like a simple fix, so I'll optimistically milestone it for 1.11. If noone has sent a fix by tomorrow, I'll likely send one myself. |
Note: #24570 adds coverage to |
@kyroy thanks - I've mentioned it there, to make sure a decision is made before a fix for either issue is merged. |
I stumbled in this issue as well using go 1.11.2. Tried 1.9.7 and I cannot replicate this. |
Surprisingly, using go 1.11.4, I can no longer replicate this issue. |
Change https://golang.org/cl/155777 mentions this issue: |
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
)?What did you do?
cvr.go:
cvr_test.go:
go test -cover:
What did you expect to see?
Anything but "0.0% of statements", it's misleading, it looks like there are no tests. I have a pure struct package like this that describes a network protocol and contains no other code. Adding a single line of code suddenly makes the coverage jump to 100%:
cvr.go:
cvr_test.go:
go test -cover:
The text was updated successfully, but these errors were encountered: