From 2a7bcb3dd87bfa65830888440da1d47faccd0905 Mon Sep 17 00:00:00 2001 From: viyatb-oai Date: Sat, 9 May 2026 20:22:31 +0000 Subject: [PATCH] test(windows-sandbox): normalize relative cmd paths Co-authored-by: Codex --- .../src/unified_exec/tests.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/codex-rs/windows-sandbox-rs/src/unified_exec/tests.rs b/codex-rs/windows-sandbox-rs/src/unified_exec/tests.rs index 7948f07bef..ea276c0db9 100644 --- a/codex-rs/windows-sandbox-rs/src/unified_exec/tests.rs +++ b/codex-rs/windows-sandbox-rs/src/unified_exec/tests.rs @@ -194,8 +194,16 @@ fn legacy_non_tty_cmd_honors_deny_read_overrides() { let _ = fs::remove_dir_all(&fixture_dir); let secret_path = fixture_dir.join("secret.env"); let public_path = fixture_dir.join("public.txt"); - let secret_rel = secret_path.strip_prefix(&cwd).expect("relative secret"); - let public_rel = public_path.strip_prefix(&cwd).expect("relative public"); + let secret_rel = secret_path + .strip_prefix(&cwd) + .expect("relative secret") + .to_string_lossy() + .replace('/', "\\"); + let public_rel = public_path + .strip_prefix(&cwd) + .expect("relative public") + .to_string_lossy() + .replace('/', "\\"); fs::create_dir_all(&fixture_dir).expect("create deny-read fixture"); fs::write(&secret_path, "secret denied").expect("write secret"); fs::write(&public_path, "public allowed").expect("write public"); @@ -221,7 +229,7 @@ fn legacy_non_tty_cmd_honors_deny_read_overrides() { vec![ "C:\\Windows\\System32\\cmd.exe".to_string(), "/c".to_string(), - format!("type \"{}\" 2>&1", public_rel.display()), + format!("type \"{public_rel}\" 2>&1"), ], cwd.as_path(), HashMap::new(), @@ -254,7 +262,7 @@ fn legacy_non_tty_cmd_honors_deny_read_overrides() { vec![ "C:\\Windows\\System32\\cmd.exe".to_string(), "/c".to_string(), - format!("type \"{}\" 2>&1", public_rel.display()), + format!("type \"{public_rel}\" 2>&1"), ], cwd.as_path(), HashMap::new(), @@ -280,7 +288,7 @@ fn legacy_non_tty_cmd_honors_deny_read_overrides() { vec![ "C:\\Windows\\System32\\cmd.exe".to_string(), "/c".to_string(), - format!("type \"{}\" 2>NUL", secret_rel.display()), + format!("type \"{secret_rel}\" 2>NUL"), ], cwd.as_path(), HashMap::new(),