From fd2baa04225c214e911dc26f2e3e0c76615a1da9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 14:51:22 -0800 Subject: [PATCH] Tests: the data folder write test expects Windows line ends and paths on Windows `writeln` uses CRLF by default on Windows, and the script reports paths without the `\?\` prefix that canonicalize adds there. The test expected LF and compared with the prefixed path, so it failed on Windows. It now expects the platform's default line end and compares plain paths. --- crates/engine/src/tests/script_io.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/tests/script_io.rs b/crates/engine/src/tests/script_io.rs index 9fc69e080f..6637d3fe8d 100644 --- a/crates/engine/src/tests/script_io.rs +++ b/crates/engine/src/tests/script_io.rs @@ -500,16 +500,18 @@ fn script_files_write_in_the_temporary_and_data_folders() { vc.log(out); vc.log(u.fsName); vc.log(Folder.temp.fsName);", ) .unwrap(); - assert_eq!(r["log"][0], json!([true, true, true, true, true, true, true, "a1trueb\nc\r\n", true, true, true, 4, true, true])); + // The first `writeln` uses the default line end, which is the platform's. + let text = if cfg!(windows) { "a1trueb\r\nc\r\n" } else { "a1trueb\nc\r\n" }; + assert_eq!(r["log"][0], json!([true, true, true, true, true, true, true, text, true, true, true, 4, true, true])); let notes = PathBuf::from(r["log"][1].as_str().unwrap()); let temp = PathBuf::from(r["log"][2].as_str().unwrap()); - assert_eq!(std::fs::read(¬es).unwrap(), b"a1trueb\nc\r\n"); - assert!(notes.starts_with(std::fs::canonicalize(base.join("settings/Script Data")).unwrap()), "{notes:?}"); + assert_eq!(std::fs::read(¬es).unwrap(), text.as_bytes()); + assert!(notes.starts_with(crate::cmd::findfiles::plain(std::fs::canonicalize(base.join("settings/Script Data")).unwrap())), "{notes:?}"); assert!(!temp.exists(), "the run's temporary folder is deleted when it ends"); let written: Vec<&str> = r["written"].as_array().unwrap().iter().filter_map(Value::as_str).collect(); assert!(written.contains(¬es.to_string_lossy().as_ref()), "{written:?}"); let again = run_in(&mut s, &base, "var u = new File(Folder.userData.fsName + '/notes.txt'); u.open('r'); vc.log(u.read());").unwrap(); - assert_eq!(again["log"], json!(["a1trueb\nc\r\n"]), "a script's data folder is kept between runs"); + assert_eq!(again["log"], json!([text]), "a script's data folder is kept between runs"); let _ = std::fs::remove_dir_all(base); }