Merge pull request #8698 from Hassan1305/fix-8693-script-io-real-temp

Tests: script_io makes its temp folders by their real paths
This commit is contained in:
BFlat
2026-11-19 20:02:19 +07:00
committed by GitHub
2 changed files with 7 additions and 3 deletions
+4 -2
View File
@@ -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]) {
+3 -1
View File
@@ -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}");