Skip to content

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

Closed
@gopherbot

Description

@gopherbot

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions