Go: all: T.FailNow used in goroutines in standard library tests

Created on 12 Nov 2016  ·  3Comments  ·  Source: golang/go

Per the documentation on testing.T, the methods FailNow, Fatal, Fatalf, SkipNow, Skip, and Skipf must be called from the same goroutine that is running the test. This requirement is violated by various tests in the standard library.

The following is a list of all goroutines spawned in tests that call T.FailNow. The list was generated from revision 2f49726.

src/runtime/chan_test.go:209:3
src/runtime/chan_test.go:306:4
src/runtime/chan_test.go:306:4
src/net/http/serve_test.go:2476:2
src/net/http/serve_test.go:2629:2
src/net/http/serve_test.go:2670:2
src/runtime/trace/trace_stack_test.go:85:2
src/runtime/trace/trace_test.go:256:2
src/runtime/trace/trace_test.go:256:2
src/runtime/trace/trace_test.go:256:2
src/database/sql/sql_test.go:2514:2
src/net/rpc/server_test.go:690:3
src/log/syslog/syslog_test.go:368:3
src/crypto/tls/handshake_server_test.go:201:2
src/crypto/tls/tls_test.go:294:2
src/crypto/tls/tls_test.go:294:2
src/sync/cond_test.go:135:2
src/sync/cond_test.go:162:2
src/sync/pool_test.go:121:3
src/net/dnsclient_unix_test.go:667:2
src/net/dnsclient_unix_test.go:667:2
src/net/dnsclient_unix_test.go:667:2
src/net/dnsclient_unix_test.go:667:2
src/sync/atomic/atomic_test.go:1216:3
src/sync/atomic/atomic_test.go:1216:3
src/sync/atomic/atomic_test.go:1259:3
src/sync/atomic/atomic_test.go:1259:3
src/sync/atomic/atomic_test.go:1305:3
src/sync/atomic/atomic_test.go:1353:3
src/os/exec/exec_test.go:431:2
FrozenDueToAge

Most helpful comment

@cespare The output is from a work in progress check for staticcheck (https://github.com/dominikh/go-staticcheck/commit/7f04f979d02ed28ee02203a81c34595b84f249bc)

All 3 comments

@dominikh did you use a tool to find these?

@cespare The output is from a work in progress check for staticcheck (https://github.com/dominikh/go-staticcheck/commit/7f04f979d02ed28ee02203a81c34595b84f249bc)

CL https://golang.org/cl/33243 mentions this issue.

Was this page helpful?
0 / 5 - 0 ratings