From d6c8bedc7b3d2de7714dca75bd05912b371538f1 Mon Sep 17 00:00:00 2001 From: Damien Neil Date: Tue, 1 Apr 2025 15:43:22 -0700 Subject: runtime, testing/synctest: stop advancing time when main goroutine exits Once the goroutine started by synctest.Run exits, stop advancing the fake clock in its bubble. This avoids confusing situations where a bubble remains alive indefinitely while a background goroutine reads from a time.Ticker or otherwise advances the clock. For #67434 Change-Id: Id608ffe3c7d7b07747b56a21f365787fb9a057d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/662155 Reviewed-by: Michael Pratt LUCI-TryBot-Result: Go LUCI Auto-Submit: Damien Neil --- src/testing/synctest/synctest.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/testing/synctest') diff --git a/src/testing/synctest/synctest.go b/src/testing/synctest/synctest.go index 90efc789de..1b1aef2e79 100644 --- a/src/testing/synctest/synctest.go +++ b/src/testing/synctest/synctest.go @@ -28,7 +28,10 @@ import ( // goroutines are blocked and return after the bubble's clock has // advanced. See [Wait] for the specific definition of blocked. // -// If every goroutine is blocked and there are no timers scheduled, +// Time stops advancing when f returns. +// +// If every goroutine is blocked and either +// no timers are scheduled or f has returned, // Run panics. // // Channels, time.Timers, and time.Tickers created within the bubble -- cgit v1.3