From 4f218bc3a66adaa5a55db3b7ee611bc287038e40 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Tue, 16 Jun 2026 21:36:57 +0000 Subject: [PATCH] exec-server: test requested cwd through process backends (#28128) --- codex-rs/exec-server/tests/exec_process.rs | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/codex-rs/exec-server/tests/exec_process.rs b/codex-rs/exec-server/tests/exec_process.rs index e5522f4073..755e573ce3 100644 --- a/codex-rs/exec-server/tests/exec_process.rs +++ b/codex-rs/exec-server/tests/exec_process.rs @@ -731,6 +731,52 @@ async fn exec_process_starts_and_exits(use_remote: bool) -> Result<()> { assert_exec_process_starts_and_exits(use_remote).await } +#[test_case(false ; "local")] +#[test_case(true ; "remote")] +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +// Serialize tests that launch a real exec-server process through the full CLI. +#[serial_test::serial(remote_exec_server)] +async fn exec_process_uses_requested_cwd(use_remote: bool) -> Result<()> { + let context = create_process_context(use_remote).await?; + let cwd = TempDir::new()?; + let expected_cwd = std::fs::canonicalize(cwd.path())?; + let argv = if cfg!(windows) { + vec![ + std::env::var("COMSPEC").unwrap_or_else(|_| "cmd.exe".to_string()), + "/C".to_string(), + "cd".to_string(), + ] + } else { + vec![ + "/bin/sh".to_string(), + "-c".to_string(), + "pwd -P".to_string(), + ] + }; + let session = context + .backend + .start(ExecParams { + process_id: ProcessId::from("proc-cwd"), + argv, + cwd: PathUri::from_path(expected_cwd.clone())?, + env_policy: /*env_policy*/ None, + env: Default::default(), + tty: false, + pipe_stdin: false, + arg0: None, + }) + .await?; + let wake_rx = session.process.subscribe_wake(); + let (output, exit_code, closed) = + collect_process_output_from_reads(session.process, wake_rx).await?; + + assert_eq!( + (std::fs::canonicalize(output.trim())?, exit_code, closed), + (expected_cwd, Some(0), true) + ); + Ok(()) +} + #[test_case(false ; "local")] #[test_case(true ; "remote")] #[cfg_attr(not(unix), ignore = "Unix-only exec-server process test")]