From 24da5d29360ae2028f9579b43281072718098728 Mon Sep 17 00:00:00 2001 From: HassanKhan Date: Thu, 19 Nov 2026 15:26:45 +0500 Subject: [PATCH] Tests: script_io makes its temp folders by their real paths On macOS the temp folder /var/... is a link to /private/var/.... Kept script file grants hold real paths, and ScriptScope refuses a path by its names alone when they don't start with a granted path, so the 11 grant tests that name their files under the temp folder were refused and asked again. folder() now returns the real path of the folder it makes. ui_inspect_script_report_leaves_out_files_outside_the_read_root failed on macOS for the same reason: the report names the included file by its real path, and the test compared it with the /var spelling. It now compares with the real path. No change outside the tests. Fixes #8693 --- crates/engine/src/tests/script_io.rs | 6 ++++-- crates/ui-egui/src/tests/automation.rs | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) 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}");