From 90aeebe84374219b793ddaf02606e8d77a632028 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Mon, 30 Sep 2019 10:13:10 -0400 Subject: [PATCH] cmd/godoc: move poll sleep to top of loop CL 196979 moved the pollInterval sleep to the bottom of the loop with the intent of not sleeping before the first readiness check, but that caused an unintended consequence of the sleep being skipped when errors happen. Move it back to the top to avoid that problem. Change-Id: Ia63f09afe47d93df657ca867ceecc4d7df6abccc Reviewed-on: https://go-review.googlesource.com/c/tools/+/197940 Run-TryBot: Dmitri Shuralyov TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- cmd/godoc/godoc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/godoc/godoc_test.go b/cmd/godoc/godoc_test.go index dff079d8aa..0b5c476abf 100644 --- a/cmd/godoc/godoc_test.go +++ b/cmd/godoc/godoc_test.go @@ -126,6 +126,7 @@ const pollInterval = 200 * time.Millisecond func waitForServer(t *testing.T, ch chan<- error, url, match string, timeout time.Duration, reverse bool) { deadline := time.Now().Add(timeout) for time.Now().Before(deadline) { + time.Sleep(pollInterval) if t.Failed() { return } @@ -144,7 +145,6 @@ func waitForServer(t *testing.T, ch chan<- error, url, match string, timeout tim ch <- nil return } - time.Sleep(pollInterval) } ch <- fmt.Errorf("server failed to respond in %v", timeout) }