From 40cd845eea345d7ae84324c8d37cd0680b243773 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 27 Mar 2013 10:07:22 -0700 Subject: [PATCH] net/http: improve test leak checker flakiness And make it have more useful output on failure. Update #5005 R=golang-dev, r CC=golang-dev https://golang.org/cl/8016046 --- src/pkg/net/http/z_last_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/pkg/net/http/z_last_test.go b/src/pkg/net/http/z_last_test.go index a80fb01d0a..5d97f9db65 100644 --- a/src/pkg/net/http/z_last_test.go +++ b/src/pkg/net/http/z_last_test.go @@ -65,8 +65,6 @@ func afterTest(t *testing.T) { if testing.Short() { return } - buf := make([]byte, 1<<20) - var stacks string var bad string badSubstring := map[string]string{ ").readLoop(": "a Transport", @@ -75,9 +73,10 @@ func afterTest(t *testing.T) { "timeoutHandler": "a TimeoutHandler", "net.(*netFD).connect(": "a timing out dial", } + var stacks string for i := 0; i < 4; i++ { bad = "" - stacks = string(buf[:runtime.Stack(buf, true)]) + stacks = strings.Join(interestingGoroutines(), "\n\n") for substr, what := range badSubstring { if strings.Contains(stacks, substr) { bad = what @@ -90,6 +89,5 @@ func afterTest(t *testing.T) { // shutting down, so give it some time. time.Sleep(250 * time.Millisecond) } - gs := interestingGoroutines() - t.Errorf("Test appears to have leaked %s:\n%s", bad, strings.Join(gs, "\n\n")) + t.Errorf("Test appears to have leaked %s:\n%s", bad, stacks) } -- 2.48.1