-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
testing: allow multiple async t.Fatals #25467
Comments
Is this a proposal or a bug report? I'm asking because this is working as documented.
|
@cznic Its a proposal. I think it should be allowed. |
How do you propose to solve a situation where some IMO, the status quo is the only reasonable approach. |
The main test goroutine still needs to wait for the other two goroutines like it would with
That should of course cause a panic like it does now. |
How to do that? The goroutine that invokes
This program does not panic now, nor it reports any error. The func Test Foo(t *testing.T) {
go func() {
<-time.After(tooLong)
t.Fatal("Vary dangerous error found.")
}()
} |
The user needs to sync by themselves. Its the same problem as with
The bug there is that you're not waiting for the main goroutine. The only way func TestMeow(t *testing.T) {
go func() {
time.Sleep(time.Second)
t.Fatal("Vary dangerous error found.")
}()
t.Log("done")
}
func TestBoo(t *testing.T) {
time.Sleep(time.Second*3)
} That however does produce the panic I was talking about. You can change the |
It's very different in that one terminates execution of the |
Here's my argument. |
That's not necessarily true. See #15758. |
Thanks so much @bcmills - that is exactly what I was proposing in my comment :) @nhooyr please refer to that issue as far as making the testing package's behavior more consistent and intuitive. If you would still like to propose that concurrent Fatal calls were supported and documented, feel free to open a new issue following the proposal process: https://github.com/golang/proposal |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +e86c26789d Sat May 19 17:38:01 2018 +0000 darwin/amd64
Does this issue reproduce with the latest release?
Yes but you encounter #24438 first so thats why I'm using a devel version.
What operating system and processor architecture are you using (
go env
)?macOS 10.13.4
What did you do?
go test -race scratch_test.go
What did you expect to see?
Two test failures with error message "meow".
What did you see instead?
Race condition report due to the two concurrent writes at
go/src/testing/testing.go
Line 589 in e86c267
t.Fatal
.I think we should patch up this race. Its very similar to #24438 in that the test is racy, but not in an interesting way.
The text was updated successfully, but these errors were encountered: