leaktest: github.com/fortytw2/leaktest Index | Files

package leaktest

import "github.com/fortytw2/leaktest"

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


Package Files



var TickerInterval = time.Millisecond * 50

TickerInterval defines the interval used by the ticker in Check* functions.

func Check Uses

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 Uses

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 Uses

func CheckTimeout(t ErrorReporter, dur time.Duration) func()

CheckTimeout is the same as Check, but with a configurable timeout

type ErrorReporter Uses

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

Package leaktest imports 7 packages (graph) and is imported by 1 packages. Updated 2019-06-25. Refresh now. Tools for package owners.