diff --git a/internal/gui/warm_turns_test.go b/internal/gui/warm_turns_test.go index fb6e81f65..dd8a4351c 100644 --- a/internal/gui/warm_turns_test.go +++ b/internal/gui/warm_turns_test.go @@ -16,7 +16,10 @@ func TestColdTurnsTaken(t *testing.T) { coldTurns.over.Store(false) t.Cleanup(func() { coldTurnsTaken = false; coldTurns.over.Store(false) }) var inStep, inPage, both atomic.Int32 - asked, release := make(chan struct{}), make(chan struct{}) + // the warm-up holds its turn before the page asks: asked at once, the + // page could take the turn before the warm-up's goroutine ran, a + // right order the test called wrong (#4510) + holding, release := make(chan struct{}), make(chan struct{}) page := coldTurn(func(http.ResponseWriter, *http.Request) { inPage.Add(1) if inStep.Load() > 0 { @@ -33,7 +36,7 @@ func TestColdTurnsTaken(t *testing.T) { warmUp(func() { inStep.Add(1) defer inStep.Add(-1) - <-asked + close(holding) <-release }, func() { inStep.Add(1) @@ -43,9 +46,9 @@ func TestColdTurnsTaken(t *testing.T) { } }) }() + <-holding answered := make(chan struct{}) go func() { - close(asked) ask() close(answered) }()