test(windows-sandbox): normalize relative cmd paths

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
viyatb-oai
2026-05-09 20:22:31 +00:00
parent 9d8a2bcce1
commit 2a7bcb3dd8

View File

@@ -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(),