Skip to content

tests: isolate codex home for live cli#22563

Merged
starr-openai merged 3 commits into
mainfrom
starr/live-cli-home-fix
May 14, 2026
Merged

tests: isolate codex home for live cli#22563
starr-openai merged 3 commits into
mainfrom
starr/live-cli-home-fix

Conversation

@starr-openai
Copy link
Copy Markdown
Contributor

@starr-openai starr-openai commented May 13, 2026

Why

Some core integration-test paths were creating Codex state under ambient ~/.codex. In environments where HOME=/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 ambient HOME.
  • core / exec-server integration test binaries using configure_test_binary_dispatch(...): their startup ctor installs arg0 helper aliases like apply_patch and codex-linux-sandbox. Full arg0_dispatch() also installs aliases from ambient Codex-home resolution, so test-binary startup could create CODEX_HOME/tmp/arg0; with HOME=/tmp, that became /tmp/.codex/tmp/arg0/....

What changed

  • live_cli now gives the spawned CLI a temp HOME and temp CODEX_HOME.
  • arg0 alias setup now has an explicit-home form, prepend_path_entry_for_codex_aliases_in(...), so test helpers can place alias state under a temp directory without relying on ambient CODEX_HOME.
  • helper re-entry behavior is preserved with dispatch_arg0_if_needed(), so aliases like apply_patch and codex-linux-sandbox still dispatch correctly before test alias installation.
  • core test support keeps the temp Codex home alive for the lifetime of the test binary, matching the alias lifetime.

Verification

Verified on dev2 with HOME=/tmp that the focused core test-binary startup path no longer recreates /tmp/.codex.

Also checked the exact live_cli test path under HOME=/tmp; on dev2 it still hits the existing remote-only cargo_bin("codex-rs") resolution failure before spawning the child, but /tmp/.codex remains absent after the run.

@starr-openai starr-openai requested a review from a team as a code owner May 13, 2026 22:47
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread codex-rs/core/tests/common/lib.rs Outdated
Comment thread codex-rs/test-binary-support/lib.rs Outdated
@starr-openai starr-openai force-pushed the starr/live-cli-home-fix branch 5 times, most recently from 6e18332 to 6404901 Compare May 13, 2026 23:20
@starr-openai starr-openai force-pushed the starr/live-cli-home-fix branch from 6404901 to 750fc97 Compare May 14, 2026 01:50
@starr-openai starr-openai marked this pull request as draft May 14, 2026 01:50
@starr-openai starr-openai marked this pull request as ready for review May 14, 2026 01:51
Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread codex-rs/core/tests/common/lib.rs Outdated
std::env::set_var("CODEX_HOME", codex_home.path());
}

let arg0 = codex_arg0::arg0_dispatch().expect("configure arg0 aliases for test binary");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@starr-openai starr-openai merged commit 32b45a4 into main May 14, 2026
31 checks passed
@starr-openai starr-openai deleted the starr/live-cli-home-fix branch May 14, 2026 19:59
@github-actions github-actions Bot locked and limited conversation to collaborators May 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants