Read the backslash path only on Windows in the build path test

On Linux a backslash is part of a file name, so the read couldn't match there.
This commit is contained in:
bflatastic
2026-11-01 15:04:39 +07:00
parent 61e66cd580
commit 51fd6166a7
+3 -1
View File
@@ -392,7 +392,9 @@ mod tests {
let r = call(&e, "build_file_write", json!({"path": "/app/package.json", "content": "{}"})).unwrap();
assert_eq!((r["written"].as_str(), r.get("note")), (Some("app/package.json"), None));
assert!(ws.app_dir().join("package.json").is_file());
assert_eq!(call(&e, "build_file_read", json!({"path": "\\app\\package.json"})).unwrap()["text"], "{}\n");
// Backslashes separate folders only on Windows; elsewhere they're part of a name.
let read = if cfg!(windows) { "\\app\\package.json" } else { "/app/package.json" };
assert_eq!(call(&e, "build_file_read", json!({"path": read})).unwrap()["text"], "{}\n");
assert!(call(&e, "build_files_list", json!({"path": "/app"})).unwrap()["entries"].to_string().contains("app/package.json"));
// A folder the project doesn't have stays outside it.
assert!(call(&e, "build_file_read", json!({"path": "/etc/passwd"})).is_err());