Documentation ¶
Overview ¶
Package leaktest provides tools to detect leaked goroutines in tests. To use it, call "defer leaktest.AfterTest(t)" at the beginning of each test that may use goroutines, and add a TestMain function for the package which calls leaktest.TestMainWithLeakCheck.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AfterTest ¶
AfterTest should be called (generally with "defer leaktest.AfterTest(t)") from each test which uses goroutines. This waits for all goroutines on a blacklist to terminate and provides more precise error reporting than TestMainWithLeakCheck alone. If a previous test's check has already failed, this is a noop (to avoid failing unrelated tests).
func TestMainWithLeakCheck ¶
TestMainWithLeakCheck is an implementation of TestMain which verifies that there are no leaked goroutines at the end of the run (except those created by the system which are on a whitelist). Usage:
// Adjust the relative path as needed. //go:generate ../util/leaktest/add-leaktest.sh *_test.go
func TestMain(m *testing.M) { leaktest.TestMainWithLeakCheck(m) }
Types ¶
This section is empty.