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

Comments

Projects
None yet
3 participants
@matthewmueller
Copy link

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

This comment has been minimized.

Copy link
Member

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 Jul 7, 2017

@matthewmueller

This comment has been minimized.

Copy link
Author

commented Jul 7, 2017

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.
You can’t perform that action at this time.