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: t.FailNow should panic if called from wrong goroutine #3800

Closed
gopherbot opened this issue Jul 4, 2012 · 5 comments
Closed

testing: t.FailNow should panic if called from wrong goroutine #3800

gopherbot opened this issue Jul 4, 2012 · 5 comments
Milestone

Comments

@gopherbot
Copy link
Contributor

by dawagner:

I expect testing.T.FailNow() to cleanly fail a test, including terminating any running
goroutines, and the main routine if it was called in a goroutine.

Running `go test` with the attached file, I expect to see "I'm about to fail",
followed by the test cleanly failing.

Instead I see:
$ go test
I'm about to fail
I'm about to loop forever

and the process never terminates.

This also happens if the infinite loop is in the main thread.
If rather than looping forever, a channel is being waited on, I get a deadlock panic.
If I remove the time.Sleep from the test, the test will pass, and then loop forever!

Which operating system are you using?
Mac OSX 10.6.8 x64

Which version are you using?  (run 'go version')
$ go version
go version go1.0.2

Attachments:

  1. bug_test.go (292 bytes)
@minux
Copy link
Member

minux commented Jul 5, 2012

Comment 1:

i don't think it is pkg testing's responsibility to kill all goroutines (maybe they are
useful anyway)
when a test fails
and the test itself is supposed to manage its goroutines.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 3:

t.FailNow is an error if called from a different goroutine. That should be documented
well. Also, it would be great if t.FailNow could panic in that case. However, I am not
sure we can catch that.

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 5:

Labels changed: added size-m.

@rsc
Copy link
Contributor

rsc commented Feb 2, 2013

Comment 6:

This issue was closed by revision 2cb8dce.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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