mirror of
https://github.com/openai/codex.git
synced 2026-09-07 15:40:00 +00:00
exec-server: test requested cwd through process backends (#28128)
This commit is contained in:
@@ -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")]
|
||||
|
||||
Reference in New Issue
Block a user