leaktest

package
v0.0.0-...-6538a59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

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

func AfterTest(t testing.TB)

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.

func TestMainWithLeakCheck

func TestMainWithLeakCheck(m *testing.M)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL