Skip to content
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: is the package thread-safe? #20940

Closed
matthewmueller opened this issue Jul 7, 2017 · 2 comments
Closed

testing: is the package thread-safe? #20940

matthewmueller opened this issue Jul 7, 2017 · 2 comments

Comments

@matthewmueller
Copy link

matthewmueller commented Jul 7, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.8.3 darwin/amd64

What operating system and processor architecture are you using (go env)?

GOHOSTARCH="amd64"
GOHOSTOS="darwin"

What did you do?

Running t.Fatal(err) inside multiple goroutines with the -race flag

What did you expect to see?

The testing package to be thread-safe and not report data races when running the -race flag.

I'm not 100% sure this isn't related to my code, but based on the error I think it's because I'm calling t.Fatal(err) from multiple goroutines. So I'd just like some clarity there.

What did you see instead?

Write at 0x00c42014e524 by goroutine 10:
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:658 +0x119

Previous write at 0x00c42014e524 by goroutine 62:
  testing.(*common).FailNow()
      /usr/local/go/src/testing/testing.go:485 +0x4a
  testing.(*common).Fatal()
      /usr/local/go/src/testing/testing.go:524 +0x7c
  command-line-arguments_test.TestPageSetControlNavigations.func1()
      /Users/matt/go/src/github.com/api/api_test.go:241 +0x2d3
@ALTree
Copy link
Member

ALTree commented Jul 7, 2017

This is documented:

A test ends when its Test function returns or calls any of the methods FailNow, Fatal, Fatalf, SkipNow, Skip, or Skipf. Those methods, as well as the Parallel method, must be called only from the goroutine running the Test function.

http://tip.golang.org/pkg/testing/#T

Closing this, since it's not a bug.

@ALTree ALTree closed this as completed Jul 7, 2017
@matthewmueller
Copy link
Author

Ahh there it is. Thanks!

@mikioh mikioh changed the title Is the testing package thread-safe? testing: is the package thread-safe? Jul 10, 2017
@golang golang locked and limited conversation to collaborators Jul 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants