From 729c05d06524eabcf0b4ed097f94d70aba48de8a Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 17 Mar 2023 12:42:02 -0400 Subject: net/http: eliminate more arbitrary timeouts in tests Change-Id: I5b3158ecd0eb20dc433a53a2b03eb4551cbb3f7d Reviewed-on: https://go-review.googlesource.com/c/go/+/477196 Auto-Submit: Bryan Mills TryBot-Result: Gopher Robot Run-TryBot: Bryan Mills Reviewed-by: Damien Neil --- src/net/http/clientserver_test.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/net/http/clientserver_test.go') diff --git a/src/net/http/clientserver_test.go b/src/net/http/clientserver_test.go index e49bed113a..58321532ea 100644 --- a/src/net/http/clientserver_test.go +++ b/src/net/http/clientserver_test.go @@ -1283,24 +1283,28 @@ func testInterruptWithPanic(t *testing.T, mode testMode, panicValue any) { } wantStackLogged := panicValue != nil && panicValue != ErrAbortHandler - if err := waitErrCondition(5*time.Second, 10*time.Millisecond, func() error { + waitCondition(t, 10*time.Millisecond, func(d time.Duration) bool { gotLog := logOutput() if !wantStackLogged { if gotLog == "" { - return nil + return true } - return fmt.Errorf("want no log output; got: %s", gotLog) + t.Fatalf("want no log output; got: %s", gotLog) } if gotLog == "" { - return fmt.Errorf("wanted a stack trace logged; got nothing") + if d > 0 { + t.Logf("wanted a stack trace logged; got nothing after %v", d) + } + return false } if !strings.Contains(gotLog, "created by ") && strings.Count(gotLog, "\n") < 6 { - return fmt.Errorf("output doesn't look like a panic stack trace. Got: %s", gotLog) + if d > 0 { + t.Logf("output doesn't look like a panic stack trace after %v. Got: %s", d, gotLog) + } + return false } - return nil - }); err != nil { - t.Fatal(err) - } + return true + }) } type lockedBytesBuffer struct { -- cgit v1.3