mirror of https://github.com/golang/go.git
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
This commit is contained in:
parent
d1eb9c8e0d
commit
40cd845eea
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue