Repository navigation
test: make the suite race-clean and order-independent - #57
Merged
Merged
Conversation
- Pin time.Local to UTC once in TestMain instead of swapping it per test: the swap raced with time.Now() in net/http servers (runWrite, TestBYOKGoldenViews). - Add a generic swap helper (set + restore via t.Cleanup) and use it for package vars tests override (writeStdin, writeStdinTTY, writeStdout, writeStderr, runsBaseURL, createAttempts, openTUI). - TestSecretsSetWithoutRetryFailsOnALostAnswer set createAttempts=1 before runWrite snapshotted it, so the "restore" kept 1 and broke TestSecretsSetRetriesWithTheSameIdempotencyKey whenever it ran later. - execute resets the shared cobra tree's flags before running and again on cleanup; tests that drove rootCmd by hand now go through it. - CI runs go test -race -shuffle=on. Fixes #55 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sre-helmcode
pushed a commit
that referenced
this pull request
Oct 20, 2026
Brings #50, #51, #52, #53, #54, #56 and #57 onto the new structure: - mimo-v2.6-flash, qwen3.8-flash at 1M, and the Codex model catalogue: the writer changes go to internal/tools, the catalogue and its embedded prompt to internal/tools/codexprompt. - BYOK runs, secrets and automation writes, and notifications: the commands go to internal/cli and hang off NewRootCmd; their goldens to internal/cli/testdata. - The --json contract test counts the commands with a --json of their own, not the one every command inherits from the root. - The embedded Codex prompt is Apache-2.0: its NOTICE and licence are now in THIRD-PARTY-NOTICES.txt. - Messages without em dashes, and the new code lint-clean.
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 #55
What and why
Two pre-existing test-only defects surfaced by the Opus QA of #54:
time.Local(TestTriggersJSONAndTokensand any otherrunWritecaller, plusTestBYOKGoldenViews). The tests swappedtime.Localto UTC per test, whilenet/httpserver goroutines (including keep-alive ones left from earlier tests) read it viatime.Now(). Nowtime.Local = time.UTCis set once inTestMain, before any test or goroutine starts.TestSecretsSetRetriesWithTheSameIdempotencyKey).TestSecretsSetWithoutRetryFailsOnALostAnswersetcreateAttempts = 1beforerunWritesnapshotted it, sorunWrite's cleanup "restored" 1 and the retry test later saw no retry (EOF). Now it usesswap(t, &createAttempts, 1).Global-state audit (cmd package)
swap[T](t, *T, v)helper (set + restore viat.Cleanup) used for every package var tests override:runsBaseURL,writeStdin,writeStdinTTY,writeStdout,writeStderr,createAttempts,openTUI. Removes hand-written save/restore blocks that restored hard-coded values instead of the previous ones.execute(the shared cobra tree runner) now resets every flag before running and again on cleanup, and clears args/out/err. Tests that droverootCmdby hand and resetrunOpts/flags manually (TestVersionPrintsOneLine,TestContradictoryWorktreeFlagsSayWhatIsWrong,TestCobraRefusalsExit64OnRunCommands) now go through it.t.Setenveverywhere, noos.Setenv),apiBaseURL/logoutWarnings/keepToolsFlag/tokenFileFlag/cancelWindow/loginVerifyURL/logoutTimeout/runHermesConfig(restored via cleanup/defer), runs/phase-2 flag vars (resetRunsFlags/resetPhase2Flagsat start and end),os.Stdout/os.Stdinswaps (restored in cleanup/defer). Nohttp.DefaultClientmutation, not.Parallelanywhere.CI
go test ./...->go test -race -shuffle=on ./...on ubuntu and macos. The full suite takes ~10 s locally under-race. A shuffle failure prints its-test.shuffleseed for reproduction.Test evidence (local, darwin/arm64)
go test -race ./...-> DATA RACE (runWrite/TestBYOKGoldenViewsvsnet/http.(*conn).setState);go test -shuffle=on ./...failed 4/5 runs onTestSecretsSetRetriesWithTheSameIdempotencyKey.go test -race -count=3 ./...ok;go test -shuffle=on -count=5 ./...ok;go test -race -shuffle=on ./...ok; the four previously failing seeds now pass; 10 more random shuffles of./cmdok.go vetandgofmt -lclean.Deploy notes
Test-only change. No VERSION /
tui.Versionbump, no release.🤖 Generated with Claude Code