#1802: TestClaudeSignInThroughMiseWrapper failed once at load 80-89 in
1.45s, and every provider test after it failed in 0.00s. The run's
messages weren't kept.
What was found, by forcing each failure by hand rather than rerunning:
- The sign-in's run of `claude auth login` outlived the test that started
it. A sign-in that gives up (no link in linkWait), or a test that fails
between StartSignIn and the sign-in's end, leaves the run's goroutine
letting go after the test: it reads claudeKeychain, removes its folder,
forgets the account caches and, had the callback gone in, adds the
account into whatever home is set by then. Under -race,
TestClaudeSignInWrapperThatNeverStarts fails on main with that race
(clearClaudeDir reading claudeKeychain while isolate's cleanup puts it
back).
- TestClaudeSignInThroughMiseWrapper shortened linkWait to 5s, so a busy
machine starting sh, the fake mise and sh again could miss it.
- miseWrapped set claudeExecutable and relied on fakeClaudeLogin's
cleanup to put it back.
- The cascade itself didn't come back. Forced failures with the sign-in
waiting (A), finishing (E) and failed early (D, the CLI exiting at once,
~1.9s like the report), on the old code and the whole package for D:
only the forced test failed, the ~100 after it ran and passed. Nothing
found in the test explains every later test failing in 0.00s. One
unproven candidate: this machine's disk is at 99% (9.9-12 GiB free
today), and a full disk fails every test that writes a file at once.
#1802 stays open for a run that keeps -v output.
What changed:
- claude_signin.go: claudeLogins, a WaitGroup of the `claude auth login`
runs still going on, to the end of their goroutine.
- signin_claude_test.go: fakeClaudeLogin, which every Claude sign-in test
uses, registers endClaudeSignIns: when the test ends it cancels every
Claude sign-in still listed (killing the CLI's process group) and waits
for claudeLogins, failing the test if a run is still going after
signInDeadline. It runs before the test's home and fakes are put back.
- signin_claude_wrapper_test.go: miseWrapped puts claudeExecutable back
itself; the through-the-wrapper test keeps linkWait's own 30s (the link
comes as soon as it is printed); the never-starts test checks it gives
up no sooner than linkWait and no later than linkWait + 1m.
What was run (macOS, sandbox HOME, GOMODCACHE pinned, a private GOCACHE
since the shared one was being emptied):
- Old code (1bf722e28's tests), -race, -run 'TestClaude|TestCodexSignIn|SignIn':
TestClaudeSignInWrapperThatNeverStarts FAILs "race detected".
With this change: 181 pass, no race.
- This change with a forced t.Fatal in TestClaudeSignInThroughMiseWrapper,
with the sign-in waiting (A) and finishing (E), -race, the Claude,
sign-in, Vertex, WorkBuddy-add, store-error and key-allowance tests:
only the forced test fails, 306 pass each time.
- gofmt -l clean; go vet ./... on darwin, GOOS=linux (-tags nogui) and
GOOS=windows.
- go test -tags nogui -timeout 40m ./internal/provider ./internal/proc:
provider ok (774s), proc ok (26s), at load 75-90.