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
"go tool cover -func=cover.out" reports wrong percentage value on Windows? #42452
Comments
In wait.go you have:
Depending on how you set up the test and on timing, net.Dial() may succeed the first time and never hit the time.Sleep() line. Check out the html output and you'll see what happens. I wouldn't worry too much about 100% test coverage. Depending on how you are using the function in question, I'd perhaps worry a bit more about the unstoppable go routine it spawns. For example, if you give it an unreachable address, the go routine will continue to dial it forever, with no way to stop it. |
Hi @antong, thanks for your reply! |
I think |
You're right, here is proof based on new CI output: --- /tmp/linux.txt 2020-11-08 23:42:51.919840484 +0100
+++ /tmp/windows.txt 2020-11-08 23:42:52.860847559 +0100
@@ -23,7 +23,7 @@
github.com/hartwork/go-wait-for-it/internal/network/wait.go:24.12,25.7 1 1
github.com/hartwork/go-wait-for-it/internal/network/wait.go:25.7,27.18 2 1
github.com/hartwork/go-wait-for-it/internal/network/wait.go:27.18,30.10 3 1
-github.com/hartwork/go-wait-for-it/internal/network/wait.go:32.4,32.38 1 1
+github.com/hartwork/go-wait-for-it/internal/network/wait.go:32.4,32.38 1 0
github.com/hartwork/go-wait-for-it/internal/network/wait.go:35.2,35.18 1 1
github.com/hartwork/go-wait-for-it/internal/network/wait.go:38.130,42.17 3 1
github.com/hartwork/go-wait-for-it/internal/network/wait.go:42.17,44.3 1 1 So I was using the tool wrong. Thanks for your help 🙏 , I'll close the issues as invalid then. |
@hartwork , glad I could help and happy that you got it working! |
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?
This is my first ever bug report to the Go community. Please bare with me if anything in here is not optimal, yet. Thank you! 🙏
I have publicly available code that is not platform specific and has 100.0% code coverage when run on Linux or macOS. Now I added Windows to the CI mix, and one function (
waitForAddress
) seems to be mis-reported as 91.7% bygo tool cover -func=cover.out
on Windows only, for no apparent reason. In detail (this is Bash on Windows in this very GitHub Actions CI):What did you expect to see?
I expect the coverage to be 100.0% just like on macOS and Linux, because
diff -u internal/network/wait.go <(go tool cover -mode=set internal/network/wait.go)
across all three platforms (and that very output is included in the CI log): all three are identical.
So I'm suspecting a Windows-specific bug in
go tool cover
here. What do you think?What did you see instead?
A misreport of 91.7% for function
waitForAddress
on Windows, only. Linux und macOS show 100.0%.The text was updated successfully, but these errors were encountered: