Remove CODEX_RS_SSE_FIXTURE test hook (#22413)

## Why

`CODEX_RS_SSE_FIXTURE` let integration-style CLI, exec, and TUI tests
bypass the normal Responses transport by reading SSE from local files.
That kept test-only behavior wired through production client code. The
affected tests can stay hermetic by using the existing
`core_test_support::responses` mock server and passing `openai_base_url`
instead.

## What Changed

- Removed the `CODEX_RS_SSE_FIXTURE` flag,
`codex_api::stream_from_fixture`, the `env-flags` dependency, and the
checked-in SSE fixture files.
- Repointed the affected core, exec, and TUI tests at `MockServer` with
the existing SSE event constructors.
- Removed the Bazel test data plumbing for the deleted fixtures and
refreshed cargo/Bazel lock state.

## Verification

- `cargo build -p codex-cli`
- `cargo test -p codex-api`
- `cargo test -p codex-core --test all responses_api_stream_cli`
- `cargo test -p codex-core --test all
integration_creates_and_checks_session_file`
- `cargo test -p codex-exec --test all ephemeral`
- `cargo test -p codex-exec --test all resume`
- `cargo test -p codex-tui --test all
resume_startup_does_not_consume_model_availability_nux_count`
- `just bazel-lock-update`
- `just bazel-lock-check`
- `just fix -p codex-api -p codex-core -p codex-exec -p codex-tui`
- `git diff --check`
This commit is contained in:
pakrym-oai
2026-05-13 03:08:01 +00:00
committed by GitHub
parent 913aad4d3c
commit 96833c5b15
23 changed files with 198 additions and 249 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ codex_rust_crate(
test_data_extra = glob([
"src/**/*.rs",
"src/**/snapshots/**",
]) + ["//codex-rs/core:model_availability_nux_fixtures"],
]),
integration_compile_data_extra = ["src/test_backend.rs"],
extra_binaries = [
"//codex-rs/cli:codex",
+2
View File
@@ -152,6 +152,7 @@ arboard = { workspace = true }
[dev-dependencies]
codex-cli = { workspace = true }
codex-mcp = { workspace = true }
core_test_support = { workspace = true }
codex-utils-cargo-bin = { workspace = true }
codex-utils-pty = { workspace = true }
assert_matches = { workspace = true }
@@ -162,3 +163,4 @@ rand = { workspace = true }
serial_test = { workspace = true }
vt100 = { workspace = true }
uuid = { workspace = true }
wiremock = { workspace = true }
@@ -4,11 +4,14 @@ use std::time::Duration;
use anyhow::Context;
use anyhow::Result;
use codex_models_manager::bundled_models_response;
use core_test_support::responses;
use core_test_support::skip_if_no_network;
use serde_json::Value as JsonValue;
use tempfile::tempdir;
use tokio::select;
use tokio::time::sleep;
use tokio::time::timeout;
use wiremock::MockServer;
#[tokio::test]
async fn resume_startup_does_not_consume_model_availability_nux_count() -> Result<()> {
@@ -16,6 +19,7 @@ async fn resume_startup_does_not_consume_model_availability_nux_count() -> Resul
if cfg!(windows) {
return Ok(());
}
skip_if_no_network!(Ok(()));
let repo_root = codex_utils_cargo_bin::repo_root()?;
let codex_home = tempdir()?;
@@ -68,8 +72,14 @@ trust_level = "trusted"
);
std::fs::write(codex_home.path().join("config.toml"), config_contents)?;
let fixture_path =
codex_utils_cargo_bin::find_resource!("../core/tests/cli_responses_fixture.sse")?;
let server = MockServer::start().await;
let sse = responses::sse(vec![
responses::ev_response_created("resp-seed-session"),
responses::ev_assistant_message("msg-seed-session", "seed session response"),
responses::ev_completed("resp-seed-session"),
]);
let _response_mock = responses::mount_sse_once(&server, sse).await;
let openai_base_url_config = format!("openai_base_url=\"{}/v1\"", server.uri());
let codex = if let Ok(path) = codex_utils_cargo_bin::cargo_bin("codex") {
path
} else {
@@ -85,12 +95,13 @@ trust_level = "trusted"
let exec_output = std::process::Command::new(&codex)
.arg("exec")
.arg("--skip-git-repo-check")
.arg("-c")
.arg(&openai_base_url_config)
.arg("-C")
.arg(&repo_root)
.arg("seed session for resume")
.env("CODEX_HOME", codex_home.path())
.env("OPENAI_API_KEY", "dummy")
.env("CODEX_RS_SSE_FIXTURE", fixture_path)
.output()
.context("failed to execute codex exec")?;
anyhow::ensure!(
@@ -114,6 +125,8 @@ trust_level = "trusted"
repo_root.display().to_string(),
"-c".to_string(),
"analytics.enabled=false".to_string(),
"-c".to_string(),
openai_base_url_config,
];
let spawned = codex_utils_pty::spawn_pty_process(
+36 -47
View File
@@ -8,14 +8,18 @@ use std::time::Instant;
use anyhow::Context;
use anyhow::Result;
use core_test_support::responses;
use core_test_support::skip_if_no_network;
use tempfile::tempdir;
use wiremock::MockServer;
#[test]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[ignore = "requires tmux and a locally built codex binary; run with --ignored for manual resize smoke"]
fn tmux_split_preserves_fresh_session_composer_row_after_resize_reflow() -> Result<()> {
async fn tmux_split_preserves_fresh_session_composer_row_after_resize_reflow() -> Result<()> {
if cfg!(windows) {
return Ok(());
}
skip_if_no_network!(Ok(()));
if Command::new("tmux").arg("-V").output().is_err() {
eprintln!("skipping resize smoke because tmux is unavailable");
return Ok(());
@@ -24,9 +28,9 @@ fn tmux_split_preserves_fresh_session_composer_row_after_resize_reflow() -> Resu
let repo_root = codex_utils_cargo_bin::repo_root()?;
let codex = codex_binary(&repo_root)?;
let codex_home = tempdir()?;
let fixture_dir = tempdir()?;
let fixture = fixture_dir.path().join("resize-reflow.sse");
write_fixture(&fixture)?;
let server = MockServer::start().await;
let _response_mock = responses::mount_sse_once(&server, resize_reflow_sse()).await;
let openai_base_url_config = format!("openai_base_url=\"{}/v1\"", server.uri());
write_config(
codex_home.path(),
&repo_root,
@@ -57,10 +61,11 @@ fn tmux_split_preserves_fresh_session_composer_row_after_resize_reflow() -> Resu
.arg("env")
.arg(format!("CODEX_HOME={}", codex_home.path().display()))
.arg("OPENAI_API_KEY=dummy")
.arg(format!("CODEX_RS_SSE_FIXTURE={}", fixture.display()))
.arg(codex)
.arg("-c")
.arg("analytics.enabled=false")
.arg("-c")
.arg(&openai_base_url_config)
.arg("--no-alt-screen")
.arg("-C")
.arg(&repo_root)
@@ -162,29 +167,31 @@ fn tmux_split_preserves_fresh_session_composer_row_after_resize_reflow() -> Resu
Ok(())
}
#[test]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[ignore = "requires tmux and a locally built codex binary; run with --ignored for manual resize smoke"]
fn tmux_repeated_resizes_do_not_push_composer_down() -> Result<()> {
async fn tmux_repeated_resizes_do_not_push_composer_down() -> Result<()> {
if cfg!(windows) {
return Ok(());
}
skip_if_no_network!(Ok(()));
if Command::new("tmux").arg("-V").output().is_err() {
eprintln!("skipping resize smoke because tmux is unavailable");
return Ok(());
}
run_repeated_resize_smoke(/*terminal_resize_reflow_enabled*/ false)?;
run_repeated_resize_smoke(/*terminal_resize_reflow_enabled*/ true)?;
run_repeated_resize_smoke(/*terminal_resize_reflow_enabled*/ false).await?;
run_repeated_resize_smoke(/*terminal_resize_reflow_enabled*/ true).await?;
Ok(())
}
#[test]
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
#[ignore = "requires tmux and a locally built codex binary; run with --ignored for manual resize smoke"]
fn tmux_width_resize_restore_keeps_visible_content_anchored() -> Result<()> {
async fn tmux_width_resize_restore_keeps_visible_content_anchored() -> Result<()> {
if cfg!(windows) {
return Ok(());
}
skip_if_no_network!(Ok(()));
if Command::new("tmux").arg("-V").output().is_err() {
eprintln!("skipping resize smoke because tmux is unavailable");
return Ok(());
@@ -193,9 +200,9 @@ fn tmux_width_resize_restore_keeps_visible_content_anchored() -> Result<()> {
let repo_root = codex_utils_cargo_bin::repo_root()?;
let codex = codex_binary(&repo_root)?;
let codex_home = tempdir()?;
let fixture_dir = tempdir()?;
let fixture = fixture_dir.path().join("resize-reflow.sse");
write_fixture(&fixture)?;
let server = MockServer::start().await;
let _response_mock = responses::mount_sse_once(&server, resize_reflow_sse()).await;
let openai_base_url_config = format!("openai_base_url=\"{}/v1\"", server.uri());
write_config(
codex_home.path(),
&repo_root,
@@ -226,10 +233,11 @@ fn tmux_width_resize_restore_keeps_visible_content_anchored() -> Result<()> {
.arg("env")
.arg(format!("CODEX_HOME={}", codex_home.path().display()))
.arg("OPENAI_API_KEY=dummy")
.arg(format!("CODEX_RS_SSE_FIXTURE={}", fixture.display()))
.arg(codex)
.arg("-c")
.arg("analytics.enabled=false")
.arg("-c")
.arg(&openai_base_url_config)
.arg("--no-alt-screen")
.arg("-C")
.arg(&repo_root)
@@ -312,13 +320,13 @@ fn tmux_width_resize_restore_keeps_visible_content_anchored() -> Result<()> {
Ok(())
}
fn run_repeated_resize_smoke(terminal_resize_reflow_enabled: bool) -> Result<()> {
async fn run_repeated_resize_smoke(terminal_resize_reflow_enabled: bool) -> Result<()> {
let repo_root = codex_utils_cargo_bin::repo_root()?;
let codex = codex_binary(&repo_root)?;
let codex_home = tempdir()?;
let fixture_dir = tempdir()?;
let fixture = fixture_dir.path().join("resize-reflow.sse");
write_fixture(&fixture)?;
let server = MockServer::start().await;
let _response_mock = responses::mount_sse_once(&server, resize_reflow_sse()).await;
let openai_base_url_config = format!("openai_base_url=\"{}/v1\"", server.uri());
write_config(
codex_home.path(),
&repo_root,
@@ -354,10 +362,11 @@ fn run_repeated_resize_smoke(terminal_resize_reflow_enabled: bool) -> Result<()>
.arg("env")
.arg(format!("CODEX_HOME={}", codex_home.path().display()))
.arg("OPENAI_API_KEY=dummy")
.arg(format!("CODEX_RS_SSE_FIXTURE={}", fixture.display()))
.arg(codex)
.arg("-c")
.arg("analytics.enabled=false")
.arg("-c")
.arg(&openai_base_url_config)
.arg("--no-alt-screen")
.arg("-C")
.arg(&repo_root)
@@ -510,33 +519,13 @@ fn write_auth(codex_home: &Path) -> Result<()> {
Ok(())
}
fn write_fixture(path: &Path) -> Result<()> {
fn resize_reflow_sse() -> String {
let text = "resize reflow sentinel says hi. This paragraph is intentionally long enough to exercise terminal wrapping, scrollback redraw, and pane resize behavior without requiring a live model response. It includes enough ordinary prose to wrap across several rows in a narrow tmux pane, then keep going so repeated split and restore cycles have visible history above the composer. If a resize path accidentally inserts blank rows or anchors the viewport lower on each pass, the composer row will drift after the pane returns to its original height.";
let created = serde_json::json!({
"type": "response.created",
"response": { "id": "resp-resize-smoke" },
});
let done = serde_json::json!({
"type": "response.output_item.done",
"item": {
"type": "message",
"role": "assistant",
"content": [
{ "type": "output_text", "text": text }
],
},
});
let completed = serde_json::json!({
"type": "response.completed",
"response": { "id": "resp-resize-smoke", "output": [] },
});
let fixture = format!(
"event: response.created\ndata: {created}\n\n\
event: response.output_item.done\ndata: {done}\n\n\
event: response.completed\ndata: {completed}\n\n"
);
std::fs::write(path, fixture)?;
Ok(())
responses::sse(vec![
responses::ev_response_created("resp-resize-smoke"),
responses::ev_assistant_message("msg-resize-smoke", text),
responses::ev_completed("resp-resize-smoke"),
])
}
fn wait_for_capture_contains(pane: &str, needle: &str, timeout: Duration) -> Result<String> {