tests: isolate codex home for live cli#22563
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9556f742c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
6e18332 to
6404901
Compare
6404901 to
750fc97
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 750fc9714e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| std::env::set_var("CODEX_HOME", codex_home.path()); | ||
| } | ||
|
|
||
| let arg0 = codex_arg0::arg0_dispatch().expect("configure arg0 aliases for test binary"); |
There was a problem hiding this comment.
Avoid temp CODEX_HOME for release test aliases
In release/optimized test builds where debug_assertions are off, arg0_dispatch() refuses to create aliases under std::env::temp_dir(); because CODEX_HOME was just pointed at a TempDir, this expect panics from the ctor before any core tests can run. This makes cargo test --release or optimized Bazel test configurations fail at process startup; use a non-system-temp home or preserve the previous fallible behavior instead.
Useful? React with 👍 / 👎.
Why
Some core integration-test paths were creating Codex state under ambient
~/.codex. In environments whereHOME=/tmp, that showed up as/tmp/.codex, which is host-level shared state and makes these tests environment/order sensitive.The affected paths were:
core/tests/suite/live_cli.rs:run_live()spawned the real CLI with a temp cwd, but without an isolated home, so the child resolved Codex home from ambientHOME.configure_test_binary_dispatch(...): their startup ctor installs arg0 helper aliases likeapply_patchandcodex-linux-sandbox. Fullarg0_dispatch()also installs aliases from ambient Codex-home resolution, so test-binary startup could createCODEX_HOME/tmp/arg0; withHOME=/tmp, that became/tmp/.codex/tmp/arg0/....What changed
live_clinow gives the spawned CLI a tempHOMEand tempCODEX_HOME.prepend_path_entry_for_codex_aliases_in(...), so test helpers can place alias state under a temp directory without relying on ambientCODEX_HOME.dispatch_arg0_if_needed(), so aliases likeapply_patchandcodex-linux-sandboxstill dispatch correctly before test alias installation.Verification
Verified on
dev2withHOME=/tmpthat the focused core test-binary startup path no longer recreates/tmp/.codex.Also checked the exact
live_clitest path underHOME=/tmp; ondev2it still hits the existing remote-onlycargo_bin("codex-rs")resolution failure before spawning the child, but/tmp/.codexremains absent after the run.