Fix the three Linux and macOS test failures - #7
Merged
Conversation
Three separate causes, none of them the behaviour under test. procrun: TestKillTreeOnExitedProcessIsConfirmed and TestKillTreeBeforeReapIsUnconfirmedWithReason built their command with exec.Command and then called ConfigureTreeCancel, which sets cmd.Cancel. os/exec refuses to start such a command unless it came from exec.CommandContext, so both failed at Start with "command with a non-nil Cancel was not created with CommandContext". Every production caller already uses CommandContext; only these two tests did not, and they live in a !windows file, so Windows never compiled them and the mistake sat there. ConfigureTreeCancel now documents the requirement, because the refusal surfaces at Start rather than at the call. app: TestApp_Undo_RestoreAndDepth was not failing at all in the sense that matters. Every character it asserted was present; the view had soft-wrapped between "depth" and "now:", because the message embeds a t.TempDir() path and its length decides where the break lands. convContains now compares with whitespace collapsed, so none of its ninety-odd call sites can fail for where a line happened to break. app: TestLoopSelfPaced_StartedWhileStreamingKeepsOwnership was a real race. It starts a turn, which starts an agent goroutine that writes the session into a directory under t.TempDir(), then cancels and returns. Cancelling only signals, so that goroutine's last write raced the TempDir cleanup and macOS reported "sessions: directory not empty". It now cancels and drains through the pump the cancellation tests already use. A cancelled turn stops its loop via stopLoopAfterFailedTurn rather than re-running the body, so draining cannot start a second turn. TestLoopSelfPaced_StartedIdleClaimsOwnership has the identical shape and the identical race; it had simply not lost it yet, and is fixed too. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
The three test failures that were left red on
mainafter the lint, TUI-golden and backlog PRs landed. Three separate causes, and none of them is the behaviour the tests exist to check.TestKillTreeOnExitedProcessIsConfirmed/TestKillTreeBeforeReapIsUnconfirmedWithReasonFailing on both Linux and macOS with:
Both tests built their command with
exec.Commandand then calledConfigureTreeCancel, which setscmd.Cancel.os/execrefuses to start a command that has aCancelfunc but no context, and the refusal comes atStart()rather than at the call that installed it.Every production caller already gets this right —
internal/hooks,internal/statusline,internal/mcp,internal/computersall useexec.CommandContext. Only these two tests did not, and they live in a//go:build !windowsfile, so Windows never compiled them and the mistake went unnoticed on the one platform where the suite was otherwise green.Fixed by using
exec.CommandContext, matching the sibling test in the same file that always passed.ConfigureTreeCancelnow documents the requirement, since nothing at the call site hints at it.TestApp_Undo_RestoreAndDepthFailing on Linux with:
Look at the "got". Every character is there. The conversation view soft-wrapped between
depthandnow:, and the assertion was a literal substring that straddled the break.Where the wrap lands depends on the length of the message, which embeds a
t.TempDir()path — different on every platform. That is the whole reason it passed on Windows and failed on Linux, and it would have kept doing so intermittently.convContainsnow compares with whitespace collapsed on both sides, so none of its ~90 call sites can fail over where a line happened to break. The failure message says it is ignoring wrapping, so a future reader is not misled about what was compared.TestLoopSelfPaced_StartedWhileStreamingKeepsOwnershipFailing on macOS with:
This one is a real race rather than an assertion artefact. The test starts a turn, which calls
agent.Runand therefore starts a goroutine that writes the session viaAddMessageinto a directory undert.TempDir(). The test then cancels the turn and returns. Cancelling only signals the goroutine, so its final write could still be in flight whent.TempDir()'sRemoveAllran — andunlinkatfails withdirectory not emptywhen a file appears mid-sweep.It now cancels and then drains, using the
drainPumpthe cancellation tests inapp_cancel_test.goalready use. Draining is safe here and cannot start a second turn: a cancelled turn ends its loop throughstopLoopAfterFailedTurnrather than re-running the body.TestLoopSelfPaced_StartedIdleClaimsOwnershiphas the identical shape and the identical race. It had simply not lost it yet, so it is fixed too rather than left to fail on some future macOS run.Verification
Run on windows/amd64 against the branch tip:
golangci-lint run --max-issues-per-linter=0 --max-same-issues=0 ./...underGOOS=linux,darwin,windowsGOOS=linux go vet ./internal/app/ ./internal/procrun/go test -count=1 ./internal/app/ ./internal/procrun/Windows is the weakest possible witness here: it cannot compile the two
procruntests at all, and it is the platform on which the undo test already passed. CI on Linux and macOS is the real check, which is what this PR is for.🤖 Generated with Claude Code