testing: t.Fatal does not fatal tests if defers do not complete #22989
Labels
Milestone
Comments
I'm marking this as a documentation issue. If someone can figure out how to fix it reasonably, that's fine with me. But in practice I think we should just document this and move on. |
Change https://golang.org/cl/83881 mentions this issue: |
This is working as intended. You want those deferred calls to run and finish before the test is torn down. If one is buggy and blocks forever, well, sorry. Sent a CL. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?What did you do?
test_test.go
What did you expect to see?
What did you see instead?
The above example is obviously broken, but this hanging behavior from the test runner causes quite a confusing experience when there are more subtle issues going on.
It's also worth noting that there is no way to determine from the dumped goroutines what is causing the hang.
From what I can tell, this is due to
t.FailNow()
usingruntime.GoExit()
which waits for defers to complete.The docs for
t.FailNow()
say the following:The text was updated successfully, but these errors were encountered: