Repository navigation
test: start interactive bash in tests without the developer's startup files - #361
Conversation
… files A test that started a plain /bin/bash loaded ~/.bashrc and ~/.profile. A startup file that prompts, prints or ends the shell broke the commands the test typed (a mise 'Trust them?' prompt swallowed one). Start these shells with --norc --noprofile -i and HISTFILE=/dev/null, like lifecycle.test.ts does.
This test already passed --noprofile --norc, but not -i or HISTFILE=/dev/null, so it still wrote ~/.bash_history. Use createBashSession like the other run tests.
|
@codex review |
|
@codex security review |
Codex Review Summary: ✅ CompletedThis 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. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Why
A test that starts a plain
/bin/bashruns the developer's~/.bashrc. That file can print text, ask a question, or end the shell. Then the test types into a shell that is not the one it expects.This broke the new test "answers a run whose catch-up replay goes on for longer than the client waits" from #359. In one checkout, mise printed a "Trust them?" prompt at shell start. The prompt read the first typed line. The test failed 3 of 3 runs, and its event log showed
bash: syntax error near unexpected token 'do'. With/bin/bash --norc --noprofile -ithe same steps passed.lifecycle.test.tsalready starts its shells that way. Nine other tests did not.What
Test-only change. No file under
src/changes.test/helpers.tsadds two exports:HERMETIC_BASH: the command/bin/bash --norc --noprofile -i.createBashSession(testHome, options):createSessionwith that command andHISTFILE=/dev/null, so the shell neither reads nor writes~/.bash_history.run.test.ts: 8 sessions usecreateBashSession. Seven started a plain/bin/bash. One ("does not log postamble cursor controls when shell echo is disabled") already passed--noprofile --norcbut wrote~/.bash_history.batch.test.ts: 1 session ("reads the step array from --file") usescreateBashSession.slow-replay.test.ts: the fix: keep a live render waiting while its replay moves forward #359 test passesHERMETIC_BASHto its own helper. The test already setsHISTFILE=/dev/nullin the env it passes.Not changed:
lifecycle.test.tstests that startbash --norc --noprofile -iby hand. They are already hermetic./bin/shsessions:run.test.ts(3 tests),io-loop.test.ts(exec /bin/sh) and the--shelltest inlifecycle.test.ts. Here/bin/shis dash. A non-login interactive dash reads no file unless the developer exportsENV, so these tests have no startup-file dependency by default. I checked this with a scratch HOME that holds a.profileand a.bashrc. No/bin/shsession read either file.Validation
All runs used Node 26.8.1, one worker, no retry. The host load average was 60 to 120, so many
createcalls failed with exit 6. I judged each red test by its assertion and reran the ones that failed increateSession.Scratch HOME proof. A scratch HOME under
/tmpheld a.bashrcthat appends a line to a marker file, then either (a) prints "Trust them?" and reads one line, or (b) printsdoand runsexit 3. Each file was run with that HOME.origin/main(c9f7152), variant (b), whole files: 9 tests fail and 9 marker lines appear. They are 7 inrun.test.ts, 1 inbatch.test.tsand the fix: keep a live render waiting while its replay moves forward #359 test inslow-replay.test.ts. Every failure is an assertion aftercreateworked (expected 4 to be +0, the session had exited). The three/bin/shtests and thesh -ctests pass and add no marker line.origin/main, variant (a): the fix: keep a live render waiting while its replay moves forward #359 test fails with "timed out waiting for the printed lines". Tworun.test.tstests also fail on assertions (waits for the command to complete before reporting success,returns timedOut when run completion is not observed within timeout).run.test.ts15/15,batch.test.ts11/11,slow-replay.test.ts5/5. The one exception is variant (b) inslow-replay.test.ts: one test that this PR does not change (it startssh -c) failed increateSessionwith exit 6 under load, and it passed alone on rerun. The marker file got 0 lines, and no.bash_historyappeared in either scratch HOME.--norcfromHERMETIC_BASHmakesreturns immediately with --no-wait,reads the step array from --fileand the fix: keep a live render waiting while its replay moves forward #359 test fail again under variant (b). RemovingHISTFILE=/dev/nullleaves the tests green but creates.bash_historyin the scratch HOME.Dogfood with the real CLI (
npx tsx src/cli/main.ts, isolated--homeunder/tmp, variant (a) HOME): with/bin/bash,run 'echo hello-old'answered the prompt and printed nohello-old. With/bin/bash --norc --noprofile -i, the samerunprintedhello-new.Gates.
npm run format:check,npm run lintandnpm run typecheckpass.npx vitest run test/unitpasses exceptprobeUsedFonts > stops between batches once the time budget is spent, a timing test that does not importtest/helpers.ts. It failed once under load and passed twice alone.check.sh --drift-onlyreports "Covered code matches the sync record." Other integration files that importtest/helpers.tsalso passed:pty-basicsandio-loop. Inevent-logandlifecycle, 3 tests failed increateSession(exit 6) under load, and all passed on rerun.Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh