Documentation
¶
Overview ¶
Package leaktest provides tools to detect leaked goroutines in tests. To use it, call "defer leaktest.Check(t)()" at the beginning of each test that may use goroutines. copied out of the cockroachdb source tree with slight modifications to be more re-useable
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
func Check(t ErrorReporter) func()
Check snapshots the currently-running goroutines and returns a function to be run at the end of tests to see whether any goroutines leaked, waiting up to 5 seconds in error conditions
func CheckContext ¶ added in v1.1.0
func CheckContext(ctx context.Context, t ErrorReporter) func()
CheckContext is the same as Check, but uses a context.Context for cancellation and timeout control
func CheckTimeout ¶ added in v1.1.0
func CheckTimeout(t ErrorReporter, dur time.Duration) func()
CheckTimeout is the same as Check, but with a configurable timeout
Types ¶
type ErrorReporter ¶
type ErrorReporter interface {
Errorf(format string, args ...interface{})
}
ErrorReporter is a tiny subset of a testing.TB to make testing not such a massive pain