From 944176beef54a81f6d1f3e30fdd4482d8887b8b0 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 18 Apr 2026 11:39:15 +0200 Subject: [PATCH] testdata: fix flaky timers test by draining ticker channel after Stop Ticker.Stop does not drain already-buffered ticks from the channel, so on slow CI runners a tick may already be queued before Stop takes effect, causing a spurious "fail: ticker should have stopped!" failure. Drain the channel immediately after Stop before checking that no new ticks arrive. Signed-off-by: deadprogram --- testdata/timers.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testdata/timers.go b/testdata/timers.go index c179e4744..7206cc2d9 100644 --- a/testdata/timers.go +++ b/testdata/timers.go @@ -21,6 +21,11 @@ func main() { <-ticker.C println("waited on ticker at 1000ms") ticker.Stop() + // Drain any tick that was already queued before Stop took effect. + select { + case <-ticker.C: + default: + } time.Sleep(time.Millisecond * 750) select { case <-ticker.C: