diff options
| author | Joe Tsai <thebrokentoaster@gmail.com> | 2016-12-08 07:13:50 +0000 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-12-09 04:04:11 +0000 |
| commit | 4bf7d1e722e852f4a28d1898cbe5d0a0d505763b (patch) | |
| tree | 02cc41940ec538b2990fce2411f118153cf2b8c2 /src/testing/testing_test.go | |
| parent | e12ce1e4005fcefd7a3537c433e6a60044160086 (diff) | |
| download | go-4bf7d1e722e852f4a28d1898cbe5d0a0d505763b.tar.xz | |
Revert "testing: add T.Context method"
This reverts commit 26827bc2fe4c80dc68b3793631d24975425c9467.
Fixes #18199
Change-Id: I42e292cb4e3d740a4fbb5d0380c6ee15ac742092
Reviewed-on: https://go-review.googlesource.com/34141
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/testing/testing_test.go')
| -rw-r--r-- | src/testing/testing_test.go | 38 |
1 files changed, 5 insertions, 33 deletions
diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go index 9954f9af8c..45e44683b4 100644 --- a/src/testing/testing_test.go +++ b/src/testing/testing_test.go @@ -5,42 +5,14 @@ package testing_test import ( - "fmt" "os" - "runtime" "testing" - "time" ) -func TestMain(m *testing.M) { - g0 := runtime.NumGoroutine() - - code := m.Run() - if code != 0 { - os.Exit(code) - } +// This is exactly what a test would do without a TestMain. +// It's here only so that there is at least one package in the +// standard library with a TestMain, so that code is executed. - // Check that there are no goroutines left behind. - t0 := time.Now() - stacks := make([]byte, 1<<20) - for { - g1 := runtime.NumGoroutine() - if g1 == g0 { - return - } - stacks = stacks[:runtime.Stack(stacks, true)] - time.Sleep(50 * time.Millisecond) - if time.Since(t0) > 2*time.Second { - fmt.Fprintf(os.Stderr, "Unexpected leftover goroutines detected: %v -> %v\n%s\n", g0, g1, stacks) - os.Exit(1) - } - } -} - -func TestContextCancel(t *testing.T) { - ctx := t.Context() - // Tests we don't leak this goroutine: - go func() { - <-ctx.Done() - }() +func TestMain(m *testing.M) { + os.Exit(m.Run()) } |
