core tests: rename automatic environment builder (#29728)

## Why

Use a clearer name for what happens when this helper sets up a test
environment.

## What

- Rename the builder and its harness wrapper to use `auto_env` instead
of `remote_env` because the helper will set up a local environment if
configured by the build system.
This commit is contained in:
Adam Perry @ OpenAI
2026-06-23 14:45:06 -07:00
committed by GitHub
Unverified
parent 9a79536e6b
commit 5283522939
9 changed files with 74 additions and 65 deletions
+12 -3
View File
@@ -405,7 +405,16 @@ impl TestCodexBuilder {
.await
}
pub async fn build_with_remote_env(
/// Builds a test runtime using the execution environment selected by the test process.
///
/// With no remote test configuration, or with `CODEX_TEST_ENVIRONMENT=local`, this uses a
/// temporary local environment just like [`Self::build`]. `CODEX_TEST_ENVIRONMENT=docker` or
/// `CODEX_TEST_ENVIRONMENT=wine-exec` selects the remote exec server configured by
/// `CODEX_TEST_REMOTE_EXEC_SERVER_URL`; the legacy `CODEX_TEST_REMOTE_ENV` Docker-container
/// configuration does the same. Only the automatically selected environment is registered.
/// Use [`Self::build_with_remote_and_local_env`] when a remote test also needs the local
/// environment to be selectable explicitly.
pub async fn build_with_auto_env(
&mut self,
server: &wiremock::MockServer,
) -> anyhow::Result<TestCodex> {
@@ -961,9 +970,9 @@ impl TestCodexHarness {
Ok(Self { server, test })
}
pub async fn with_remote_env_builder(mut builder: TestCodexBuilder) -> Result<Self> {
pub async fn with_auto_env_builder(mut builder: TestCodexBuilder) -> Result<Self> {
let server = start_mock_server().await;
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
Ok(Self { server, test })
}
+4 -4
View File
@@ -57,7 +57,7 @@ async fn agents_instructions(mut builder: TestCodexBuilder) -> Result<String> {
)
.await;
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
test.submit_turn("hello").await?;
let request = resp_mock.single_request();
@@ -372,7 +372,7 @@ async fn selected_environment_sources_match_model_visible_instructions() -> Resu
.await?;
Ok::<(), anyhow::Error>(())
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let project_agents = test.config.cwd.join("AGENTS.md");
let global_agents = global_agents.abs();
@@ -430,7 +430,7 @@ async fn loads_user_instructions_without_a_primary_environment() -> Result<()> {
.await?;
Ok(())
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
assert_eq!(provider.load_count(), 1);
let no_environment_thread = test
@@ -515,7 +515,7 @@ async fn fresh_thread_composes_global_before_project_and_reports_sources() -> Re
.await?;
Ok(())
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let project_source = test.config.cwd.join(GLOBAL_AGENTS_FILENAME);
let creation_sources = vec![
PathUri::from_abs_path(&global_source),
+1 -1
View File
@@ -74,7 +74,7 @@ async fn apply_patch_harness_with(
let builder = configure(test_codex());
// Box harness construction so apply_patch_cli tests do not inline the
// full test-thread startup path into each test future.
Box::pin(TestCodexHarness::with_remote_env_builder(builder)).await
Box::pin(TestCodexHarness::with_auto_env_builder(builder)).await
}
async fn submit_without_wait(harness: &TestCodexHarness, prompt: &str) -> Result<()> {
+1 -1
View File
@@ -199,7 +199,7 @@ async fn codex_apps_file_params_upload_environment_files_before_mcp_tool_call()
.await?;
Ok(())
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let mock = run_extract_turn(&test, &server).await?;
let requests = mock.requests();
+2 -2
View File
@@ -214,7 +214,7 @@ async fn remote_test_env_exposes_target_shell_to_model() -> Result<()> {
]),
)
.await;
let test = test_codex().build_with_remote_env(&server).await?;
let test = test_codex().build_with_auto_env(&server).await?;
test.submit_turn("report remote environment").await?;
@@ -274,7 +274,7 @@ async fn explicit_remote_shell_runs_in_remote_cwd() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let response_mock = mount_sse_sequence(
&server,
vec![
+15 -15
View File
@@ -603,7 +603,7 @@ async fn stdio_server_round_trip() -> anyhow::Result<()> {
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -782,7 +782,7 @@ async fn stdio_server_uses_configured_cwd_before_runtime_fallback() -> anyhow::R
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -908,7 +908,7 @@ async fn stdio_mcp_tool_call_includes_sandbox_state_meta() -> anyhow::Result<()>
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1002,7 +1002,7 @@ async fn stdio_mcp_parallel_tool_calls_default_false_runs_serially() -> anyhow::
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1143,7 +1143,7 @@ async fn stdio_mcp_read_only_tool_calls_run_concurrently_without_server_opt_in()
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1232,7 +1232,7 @@ async fn stdio_mcp_parallel_tool_calls_opt_in_runs_concurrently() -> anyhow::Res
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1323,7 +1323,7 @@ async fn stdio_image_responses_round_trip() -> anyhow::Result<()> {
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1477,7 +1477,7 @@ async fn stdio_image_responses_resize_large_image() -> anyhow::Result<()> {
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1565,7 +1565,7 @@ async fn stdio_image_responses_preserve_original_detail_metadata() -> anyhow::Re
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1711,7 +1711,7 @@ async fn stdio_image_responses_are_sanitized_for_text_only_model() -> anyhow::Re
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1819,7 +1819,7 @@ async fn stdio_server_propagates_whitelisted_env_vars() -> anyhow::Result<()> {
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -1944,7 +1944,7 @@ async fn stdio_server_propagates_explicit_local_env_var_source() -> anyhow::Resu
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -2040,7 +2040,7 @@ async fn remote_stdio_env_var_source_does_not_copy_local_env() -> anyhow::Result
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -2224,7 +2224,7 @@ async fn streamable_http_tool_call_round_trip() -> anyhow::Result<()> {
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
wait_for_mcp_server(&fixture.codex, server_name).await?;
@@ -2411,7 +2411,7 @@ async fn streamable_http_with_oauth_round_trip_impl() -> anyhow::Result<()> {
},
);
})
.build_with_remote_env(&server)
.build_with_auto_env(&server)
.await?;
// Phase 5: wait for MCP startup before the turn is submitted, which keeps
// failures tied to server startup/discovery.
+1 -1
View File
@@ -57,7 +57,7 @@ async fn user_turn_includes_skill_instructions() -> Result<()> {
let mut builder = test_codex().with_workspace_setup(move |cwd, fs| async move {
write_repo_skill(cwd, fs, "demo", "demo skill", skill_body).await
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let skill_path = test
.config
+26 -26
View File
@@ -403,7 +403,7 @@ async fn unified_exec_emits_exec_command_begin_event() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let cwd = test.config.cwd.to_path_buf();
let call_id = "uexec-begin-event";
@@ -466,7 +466,7 @@ async fn unified_exec_resolves_relative_workdir() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let workdir_rel = std::path::PathBuf::from("uexec_relative_workdir");
let workdir = create_workspace_directory(&test, &workdir_rel).await?;
@@ -534,7 +534,7 @@ async fn unified_exec_respects_workdir_override() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let workdir = create_workspace_directory(&test, "uexec_workdir_test").await?;
@@ -600,7 +600,7 @@ async fn unified_exec_emits_exec_command_end_event() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-end-event";
let args = json!({
@@ -674,7 +674,7 @@ async fn unified_exec_emits_output_delta_for_exec_command() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-delta-1";
let args = json!({
@@ -733,7 +733,7 @@ async fn unified_exec_full_lifecycle_with_background_end_event() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-full-lifecycle";
// This timing force the long-standing PTY
@@ -944,7 +944,7 @@ allow_local_binding = true
.set_permission_profile(permission_profile_for_config)
.expect("set permission profile");
});
let test = builder.build_with_remote_env(server).await?;
let test = builder.build_with_auto_env(server).await?;
assert!(
test.config.permissions.network.is_some(),
"expected managed network proxy config to be present"
@@ -1027,7 +1027,7 @@ async fn unified_exec_emits_terminal_interaction_for_write_stdin() -> Result<()>
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let open_call_id = "uexec-open";
let open_args = json!({
@@ -1111,7 +1111,7 @@ async fn unified_exec_terminal_interaction_captures_delayed_output() -> Result<(
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let open_call_id = "uexec-delayed-open";
let open_args = json!({
@@ -1290,7 +1290,7 @@ async fn unified_exec_emits_one_begin_and_one_end_event() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let open_call_id = "uexec-open-session";
let open_args = json!({
@@ -1413,7 +1413,7 @@ async fn exec_command_reports_chunk_and_exit_metadata() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-metadata";
let args = serde_json::json!({
@@ -1509,7 +1509,7 @@ async fn exec_command_clamps_model_requested_max_output_tokens_to_policy() -> Re
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-clamped-max-output";
let args = serde_json::json!({
@@ -1572,7 +1572,7 @@ async fn write_stdin_clamps_model_requested_max_output_tokens_to_policy() -> Res
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let start_call_id = "uexec-stdin-clamp-start";
let start_args = serde_json::json!({
@@ -1660,7 +1660,7 @@ async fn unified_exec_defaults_to_pipe() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-default-pipe";
let args = serde_json::json!({
@@ -1730,7 +1730,7 @@ async fn unified_exec_can_enable_tty() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-tty-enabled";
let args = serde_json::json!({
@@ -1797,7 +1797,7 @@ async fn unified_exec_respects_early_exit_notifications() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec-early-exit";
let args = serde_json::json!({
@@ -1881,7 +1881,7 @@ async fn write_stdin_returns_exit_metadata_and_clears_session() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let start_call_id = "uexec-cat-start";
let send_call_id = "uexec-cat-send";
@@ -2063,7 +2063,7 @@ async fn assert_write_stdin_ctrl_c_interrupts_non_tty_session(
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let start_call_id = format!("uexec-non-tty-interrupt-{test_name}-start");
let interrupt_call_id = format!("uexec-non-tty-interrupt-{test_name}");
@@ -2181,7 +2181,7 @@ async fn write_stdin_ctrl_c_reports_unsupported_interrupt_to_model_on_windows()
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let start_call_id = "uexec-windows-interrupt-start";
let interrupt_call_id = "uexec-windows-interrupt";
@@ -2283,7 +2283,7 @@ async fn unified_exec_emits_end_event_when_session_dies_via_stdin() -> Result<()
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let start_call_id = "uexec-end-on-exit-start";
let start_args = serde_json::json!({
@@ -2583,7 +2583,7 @@ async fn unified_exec_reuses_session_via_stdin() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let first_call_id = "uexec-start";
let first_args = serde_json::json!({
@@ -2683,7 +2683,7 @@ async fn unified_exec_streams_after_lagged_output() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let script = r#"python3 - <<'PY'
import sys
@@ -2799,7 +2799,7 @@ async fn unified_exec_timeout_and_followup_poll() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let first_call_id = "uexec-timeout";
let first_args = serde_json::json!({
@@ -2892,7 +2892,7 @@ async fn unified_exec_formats_large_output_summary() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let script = r#"python3 - <<'PY'
import sys
@@ -3339,7 +3339,7 @@ async fn unified_exec_runs_on_all_platforms() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let call_id = "uexec";
let args = serde_json::json!({
@@ -3398,7 +3398,7 @@ async fn unified_exec_prunes_exited_sessions_first() -> Result<()> {
.enable(Feature::UnifiedExec)
.expect("test config should allow feature update");
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
const MAX_SESSIONS_FOR_TEST: i32 = 64;
const FILLER_SESSIONS: i32 = MAX_SESSIONS_FOR_TEST - 1;
+12 -12
View File
@@ -182,7 +182,7 @@ async fn assert_user_turn_local_image_resizes_to(
let server = start_mock_server().await;
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -282,7 +282,7 @@ async fn view_image_tool_attaches_local_image() -> anyhow::Result<()> {
let server = start_mock_server().await;
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -679,7 +679,7 @@ async fn view_image_tool_can_preserve_original_resolution_when_requested_on_gpt5
let server = start_mock_server().await;
let mut builder = test_codex().with_model("gpt-5.3-codex");
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -770,7 +770,7 @@ async fn view_image_tool_errors_clearly_for_unsupported_detail_values() -> anyho
let server = start_mock_server().await;
let mut builder = test_codex().with_model("gpt-5.3-codex");
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -848,7 +848,7 @@ async fn view_image_tool_treats_null_detail_as_omitted() -> anyhow::Result<()> {
let server = start_mock_server().await;
let mut builder = test_codex().with_model("gpt-5.3-codex");
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -938,7 +938,7 @@ async fn view_image_tool_resizes_when_model_lacks_original_detail_support() -> a
let server = start_mock_server().await;
let mut builder = test_codex().with_model("gpt-5.2");
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -1032,7 +1032,7 @@ async fn view_image_tool_does_not_force_original_resolution_with_capability_only
let server = start_mock_server().await;
let mut builder = test_codex().with_model("gpt-5.3-codex");
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -1123,7 +1123,7 @@ async fn view_image_tool_errors_when_path_is_directory() -> anyhow::Result<()> {
let server = start_mock_server().await;
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -1193,7 +1193,7 @@ async fn view_image_tool_turns_invalid_image_into_placeholder() -> anyhow::Resul
let server = start_mock_server().await;
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -1264,7 +1264,7 @@ async fn view_image_tool_errors_when_file_missing() -> anyhow::Result<()> {
let server = start_mock_server().await;
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,
@@ -1404,7 +1404,7 @@ async fn view_image_tool_returns_unsupported_message_for_text_only_model() -> an
.with_config(|config| {
config.model = Some(model_slug.to_string());
});
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex { codex, .. } = &test;
let rel_path = "assets/example.png";
@@ -1491,7 +1491,7 @@ async fn replaces_invalid_local_image_after_bad_request() -> anyhow::Result<()>
let completion_mock = responses::mount_sse_once(&server, success_response).await;
let mut builder = test_codex();
let test = builder.build_with_remote_env(&server).await?;
let test = builder.build_with_auto_env(&server).await?;
let TestCodex {
codex,
session_configured,