Six tests have their server keep a Claude Code run for a conversation's
next turn, which the bridge holds for idleLongest (an hour):
TestClaudeRunKeptForTheNextTurn, TestClaudeOneOffAskNotKept,
TestClaudeRunLetGoWhenTheConversationMovedOn and
TestClaudeRunKeptAcrossEffort (claude_subscription_test.go),
TestClaudeRunKeptAfterTheClientsOwnToolCall and
TestCodexThreadKeepsItsClaudeRunAcrossAMemoryCall. Nothing ended those
runs, so each test's fake Claude Code ran on until the test binary
exited, 11 more each round: under -race -count=50, gateway.test had 77
of them after about 8 rounds.
Each now ends its server's runs as the gateway does when it stops,
t.Cleanup(s.subscription.abortAll), like the tests that already keep
runs. fakeClaude, and TestClaudeRunKeptAcrossEffort's own fake, register
runsEndWithTest before New(), so it runs after the test's cleanups: it
fails the test when a run of that fake is still in its server's bridge
and not ended, and ends it. Like the park sweep, it counts a run killed
or exited, on its way out of the bridge, as ended.
Without the six abortAll cleanups the six tests fail:
claude_subscription_foreign_test.go:19: Claude Code runs the test started, still going after it: 3
--- FAIL: TestClaudeRunKeptAfterTheClientsOwnToolCall
claude_subscription_test.go:148: Claude Code runs the test started, still going after it: 3
--- FAIL: TestClaudeRunKeptForTheNextTurn
claude_subscription_test.go:192: Claude Code runs the test started, still going after it: 1
--- FAIL: TestClaudeOneOffAskNotKept
claude_subscription_test.go:349: Claude Code runs the test started, still going after it: 2
--- FAIL: TestClaudeRunLetGoWhenTheConversationMovedOn
claude_subscription_test.go:571: Claude Code runs the test started, still going after it: 1
--- FAIL: TestClaudeRunKeptAcrossEffort
codex_developer_cache_test.go:73: Claude Code runs the test started, still going after it: 1
--- FAIL: TestCodexThreadKeepsItsClaudeRunAcrossAMemoryCall
With them they pass.
The test binary's processes after each round of -count=3, each test run
alone with a probe that lists gateway.test's descendants after it: before,
3, 6, 9 (TestClaudeRunKeptForTheNextTurn,
TestClaudeRunKeptAfterTheClientsOwnToolCall), 2, 4, 6
(TestClaudeRunLetGoWhenTheConversationMovedOn) and 1, 2, 3 (the other
three); the six in one run 11, 22, 33. After, none for each. The
package's other tests, run the same way one by one, left none running
into their next round: in a first round the probe saw only the stand-ins
TestMain runs once (testenv.StandIns), and once a fake of
TestClaudeBridgeSafeguardContextUpdates that abortAll had just killed.
The 21 that need bun, which end their plugin host with plugin.Settle, and
the live Codex test were skipped here.
-race -count=20 of the six passes. gofmt -l, go vet ./..., go build ./...,
GOOS=linux go build -tags nogui ./..., GOOS=windows go build ./... and
go test -tags nogui ./... pass under a temp HOME with Go's caches pinned.
Tests only.