ci: fix the failures in the new test-race job - #4228
Open
aheritier wants to merge 4 commits into
Open
Conversation
…ta race runDockerAgentInContainer read stderrData after cmd.Wait() while a hand-rolled goroutine was still writing it; Wait does not wait for our own goroutine. Let exec.Cmd own the copy via a bytes.Buffer so Wait (bounded by WaitDelay) guarantees the data is complete before we read it.
withVersion wrote the global version.Version from a t.Parallel() test while sibling parallel tests read it through DefaultAgentImage(), which the race detector flagged. Extract the pure defaultAgentImageFor helper and table-test it with explicit versions instead.
Eight tests started a program inline and only quit it at the end of the function, so a failed require leaked a live render loop whose View() kept reading styles globals while later tests called ApplyTheme. The race detector then failed unrelated theme tests. startTestProgram now guarantees Quit, a bounded wait for Run, and ar.Stop() in t.Cleanup.
Tests comparing two frames across a message round trip flaked when a spinner TickMsg landed between them and advanced the glyph; -race slows the loop enough to straddle TickRate. frozenClockRoot builds the harness on a scheduler that never schedules a tick, so ar.Now() stays constant. Perf and geometry tests stay on wallClockRoot.
aheritier
enabled auto-merge
September 10, 2026 16:29
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.
Why
#4221 added a
test-racejob (go test -race -shuffle=on ./...) on pushes tomain. Its first run ( 34493297831 ) failed whiletest-linuxpassed. Nothing in the merged code regressed: the race detector exposed pre-existing bugs thatgo testnever saw. Two packages failed for four root causes; the ~15 other "race detected during execution of test" failures are collateral, since Go fails every test running when a race fires.What
fix(evaluation)runDockerAgentInContainerreadstderrDataaftercmd.Wait()while its own goroutine was still writing it;Waitdoes not wait for our goroutine. Stderr now goes throughcmd.Stderr = &bytes.Buffer{}, whichWait(bounded byWaitDelay) synchronizes.test(evaluation)withVersionmutated the globalversion.Versionfrom at.Parallel()test while sibling parallel tests read it viaDefaultAgentImage(). Extracted a puredefaultAgentImageFor(v)and table-test that instead; nothing writesversion.Versionfrom tests any more.test(tui)freeze clockTestActualProgramScrollCancelResizeMatrixNeverNeedsRecoveryClickcompares two frames taken milliseconds apart; under-racea spinnerTickMsglands between them and advances the glyph. NewfrozenClockRootbuilds the harness on a scheduler that never schedules a tick, used by the three exact-frame tests. Perf/geometry tests stay onwallClockRoot.test(tui)teardownrequireaborted beforeprogram.Quit(), leaking a live render loop whoseView()readstylesglobals while later tests calledstyles.ApplyTheme. NewstartTestProgramhelper quits, waits (bounded) and stops the runtime int.Cleanup; all eight inline program starts use it.Verification
go test -race -shuffle=on -count=5 ./pkg/evaluation: clean.go test -race -count=20 -run 'TestActualProgram|TestColorScheme|TestHandleChangeTheme' ./pkg/tui: clean.task lintpasses.Not in this PR
A shuffled full
pkg/tuirace run still fails ~1 in 5 onTestLoadSessionThenClickEditLabel, from an unrelated production race inpkg/app(App.Start's goroutine readsa.sessionwhileReplaceSessionwrites it). That one was not in run 34493297831 and is tracked and fixed separately.