testdata: attempt to deflake timers/goroutines tests#5384
Open
jakebailey wants to merge 2 commits into
Open
Conversation
The timers test interleaved goroutine prints with ticker/timer waits, which produced non-deterministic output ordering under thread-based scheduling. On loaded systems, the goroutine prints could race with the ticker ticks, causing test failures. Fix by synchronizing the goroutine via a done channel before the first tick arrives. The goroutine still runs concurrently with the ticker (proving both mechanisms work together), but finishes well before the tick fires so the output order is deterministic. Also use wider timing margins (goroutine at 100/200ms vs ticker at 500ms) to avoid races on slow CI machines. Addresses tinygo-org/tinygo issue 4963.
The goroutines test had two races under thread-based scheduling: 1. "main 2" vs "sub 2": both printed around 100-200ms from start, racing on loaded systems. Fixed by using channel synchronization between main and sub() instead of relying on sleep timing. 2. "slept inside func pointer" vs "slept inside closure": both goroutines launched by sleepFuncValue slept 1ms then printed, with only a 1ms gap between launches. Fixed by waiting for each goroutine to complete via a done channel before starting the next. The test still exercises goroutine creation, function value calls, closure captures, and channel communication. Addresses tinygo-org/tinygo issue 4965.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4963
Fixes #4965
I got tired of hitting these flakes locally and in CI. These changes seem to make them pass, but it's a little unclear without more eyes whether or not I have defeated the purpose of these tests somehow as I of course arrived here after these were committed...