diff --git a/crates/engine/src/tests/script_io.rs b/crates/engine/src/tests/script_io.rs index 7c8c167527..7653dc083d 100644 --- a/crates/engine/src/tests/script_io.rs +++ b/crates/engine/src/tests/script_io.rs @@ -12,12 +12,14 @@ use crate::*; const DENIED: &str = "Script file access denied"; -/// A fresh folder for test `name`, with a `main` folder inside it for the script. +/// A fresh folder for test `name`, with a `main` folder inside it for the script, by its real +/// path: kept grants hold real paths, and a path named through a link (macOS's `/var` is +/// `/private/var`) is refused by its names alone. fn folder(name: &str) -> PathBuf { let base = std::env::temp_dir().join(format!("vc-script-io-{name}-{}", std::process::id())); let _ = std::fs::remove_dir_all(&base); std::fs::create_dir_all(base.join("main")).unwrap(); - base + std::fs::canonicalize(&base).unwrap() } fn write(path: &Path, bytes: &[u8]) { diff --git a/crates/ui-egui/src/tests/automation.rs b/crates/ui-egui/src/tests/automation.rs index 7a904e4646..00505b84cc 100644 --- a/crates/ui-egui/src/tests/automation.rs +++ b/crates/ui-egui/src/tests/automation.rs @@ -1310,7 +1310,9 @@ fn ui_inspect_script_report_leaves_out_files_outside_the_read_root() { std::fs::write(base.join("outside/bad.jsxinc"), "\nthrow new Error('stopped here');\n").unwrap(); finish(&mut app, json!({"path": s(base.join("outside/run.jsx"))})); let person = crate::control::inspect(&app, &ctx); - assert_eq!(person["scriptReport"]["file"], json!(s(base.join("outside/bad.jsxinc"))), "{person}"); + // The report names the file by its real path (on macOS the temp folder is reached through a link). + let bad = std::fs::canonicalize(base.join("outside/bad.jsxinc")).unwrap(); + assert_eq!(person["scriptReport"]["file"], json!(s(bad)), "{person}"); let r = request(&mut app, &tx, "ui.inspect", json!({})); assert_eq!(r["result"]["scriptReport"]["file"], "bad.jsxinc", "{r}"); assert!(r["result"]["scriptReport"]["console"].to_string().contains("bad.jsxinc:2:"), "{r}");