Make the test suite hermetic and green under -shuffle#45
Open
LukasIngemarsson wants to merge 1 commit into
Open
Make the test suite hermetic and green under -shuffle#45LukasIngemarsson wants to merge 1 commit into
LukasIngemarsson wants to merge 1 commit into
Conversation
Three pre-existing non-hermeticity classes made the macOS suite a moving target: failures shifted with test order, and config/cwd state could flip any run red. - HOME/config: keybinding tests (Ctrl+P/O/Z) read the developer's real ~/.config/ask/ask.json via currentKeyMap, so a contributor's custom or unbound shortcuts failed them. A package TestMain now points $HOME/$XDG at a throwaway dir, so config reads fall back to compiled defaults. - macOS temp symlinks: t.TempDir() lives under /var (symlink to /private/var), but production resolves cwd via EvalSymlinks (memoryProjectRoot). isolateHome now resolves up front so seeded and read project-config keys match -- fixes the workflow_* MCP tests and the index-out-of-range panic that was masking later failures. - cwd leakage: production os.Chdir (closeTab / cd handler / shell mode) left the process in a temp dir, breaking later relative-path tests (usage-plugin reads). newTestModel now restores cwd via t.Cleanup, and TestMain restores it at the suite boundary. Verified green in default order and under -shuffle (seeds 1/42/9999 + random), 1729 passed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jun 11, 2026
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.
Problem
The test suite was non-hermetic and order-dependent on macOS —
go test ./...failures shifted with test order, and a contributor's local config/cwd state could flip any run red. Three independent causes:Ctrl+P/O/Z) read the developer's real~/.config/ask/ask.jsonviacurrentKeyMap, so custom or unbound shortcuts failed them.t.TempDir()lives under/var(a symlink to/private/var), but production resolves cwd viafilepath.EvalSymlinks(memoryProjectRoot). The mismatch keyed seeded vs. read project config under different roots, failing theworkflow_*MCP tests (and anindex out of rangepanic that was masking later failures).os.Chdir(closeTab, thecdhandler, shell mode) left the process in a temp dir, breaking later relative-path tests (e.g. the usage-plugin file reads).Fix (test-only, all in
testhelpers_test.go)TestMainpoints$HOME/$XDG_CONFIG_HOME/$XDG_CACHE_HOMEat a throwaway dir, so config reads fall back to compiled defaults; it also invalidates the keymap cache and restores cwd at the suite boundary.isolateHomeresolves the temp dir throughfilepath.EvalSymlinksso seeded and read project-config keys agree.newTestModelcaptures cwd and restores it viat.Cleanup.Verification
go test ./...is green in default order and under-shuffle(seeds 1/42/9999 + random), 1729 passed.🤖 Generated with Claude Code