-
Notifications
You must be signed in to change notification settings - Fork 122
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
[go1.14] Panics in a test confuse test2json, test is considered passing #94
Comments
Thanks for the detailed bug report! I haven't been able to get my PR for #66 accepted to fix that issue, so I would like to work around this problem in case it takes a while to get fixed. For an immediate workaround I would suggest using I think a potential code change workaround could be:
I hope this will fix the problem in |
I think the problem is any panic in a test. Ex, I added this: func Test_PanicInMain(t *testing.T) {
panic("panic anywhere")
} and it seems to have the same behaviour. |
Tested with both |
So good news: This report issue is indeed a regression in 1.14, with a fix targeting 1.14.1. There is a fix already for golang/go@76a6adc . Sadly, we've encountered another bug with similar symptoms. Prior to upgrading to golang 1.14, we had seen cases no failed tests but exit code 1 with golang 1.12, e.g. https://circleci.com/gh/hashicorp/nomad/41667 and https://circleci.com/gh/hashicorp/nomad/28151 . It happened at a much lower rate. It might be #66 . I'll close this issue, research the issue we saw in 1.12 by adding more logging and collecting data, and then follow up with a new ticket or comment on #66 . Thank you so much for your quick follow up! |
There are still some issues like this in go1.14.1. I wrote up #99 |
When a panic occurs in a test background goroutine, gotestsum terminates with exit code 1 but without reporting the panic and without reporting the package name, unlike
go test
.go test -json
unexpectedly emits aaction=pass
event for the test and doesn't the result of package name. Justifiably,gotestsum
doesn't report the output of a reportedly successful test.This seems unambiguously a
go test
issue, and I aim to follow up go test maintainers; though, I'd suggest considering a workaround or noting a caveat in documentation. It has been a bit hard to identify in our case and some peers have advocated for switching back to usinggo test
to avoid similar bugs in future.Reproduction
With sample file blow:
go test .; echo "exit code: $?"
- note the FAIL message, panic and non-zero exit codesample test
more details
The json output of
go test
for Test_PanicInGoroutineand
Test_AlwaysFails` are included below. I would note two differences:Test_PanicInGoroutine
has"Action":"pass"
entry for the test despite the previous FAIL output.Test_PanicInGoroutine
does not have a"Action":"{pass|fail}"
for the package level.Test_PanicInGoroutine
AlwaysFails
The text was updated successfully, but these errors were encountered: