Skip to content

Guard core test subprocess cleanup - #27343

Merged
etraut-openai merged 7 commits into
mainfrom
etraut/core-test-cleanup-guard
Jun 10, 2026
Merged

Guard core test subprocess cleanup#27343
etraut-openai merged 7 commits into
mainfrom
etraut/core-test-cleanup-guard

Conversation

@etraut-openai

@etraut-openai etraut-openai commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Why

Local integration-heavy codex-core CLI tests can time out or be interrupted after spawning codex exec. Stopping only the direct child is not enough: codex exec can leave grandchildren behind, including python3/python3.12 processes that get reparented to PID 1 and keep running after the test is gone.

This PR fixes that failure mode directly for the affected CLI integration tests, without changing production code or reducing local test concurrency.

What

  • Run the cli_stream codex exec subprocesses through a small private wrapper in core/tests/suite/cli_stream.rs.
  • Spawn those subprocesses in their own process group before execution.
  • Keep .output()-style stdout/stderr capture and the existing 30-second timeout behavior.
  • Own each spawned process with a drop guard that kills the whole process group on success, timeout, panic, or other early return.

The switch from assert_cmd::Command to std::process::Command is only for these subprocess launches; assert_cmd does not expose a pre-spawn hook for setting the process group.

Verification

  • just test -p codex-core --test all responses_mode_stream_cli

This is limited to core integration tests; it does not change production src code paths.

@etraut-openai
etraut-openai marked this pull request as ready for review June 10, 2026 08:00
@etraut-openai
etraut-openai requested a review from a team as a code owner June 10, 2026 08:00

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

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 52a69d375c

ℹ️ 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/Cargo.toml Outdated
@etraut-openai etraut-openai changed the title [codex] Guard core test subprocess cleanup Guard core test subprocess cleanup Jun 10, 2026
}
}

fn run_cli_command(command: &mut Command) -> io::Result<Output> {

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.

Let's Add a comment with context so Codex use it when making new tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep, good call. Added.

@etraut-openai
etraut-openai merged commit 1346811 into main Jun 10, 2026
31 checks passed
@etraut-openai
etraut-openai deleted the etraut/core-test-cleanup-guard branch June 10, 2026 19:19
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 10, 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