From 52e404754f76434c95f5bb93fbdc9160fb7b3c11 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 24 Oct 2026 07:40:55 -0700 Subject: [PATCH] Links: the folder relink and IDML link tests expect Windows paths on Windows Two designcraft-engine tests fail on Windows on main. The code they test is unchanged. eps_relink_update_and_folder_relink_retain_source built the expected link as dir.join("new/replacement.eps"), which on Windows ends in new/replacement.eps, while links.relinkFolder stores the folder joined to the file name, ending in new\replacement.eps. The test now joins the folder and the file name separately. only_local_graphic_files_are_read_from_links allowed a read of the link only at the link's own text. For the link /dev/zero the import checks C:\dev\zero on Windows, because craft-docpath joins a root-relative path to the document's drive. The test now allows the path that crate::io::document_path resolves the link to. Open #1444 by AndreRese makes the same change to the relink test and a similar one to the IDML test. --- crates/engine/src/cmd/interchange.rs | 6 ++++-- crates/engine/src/cmd/links.rs | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/interchange.rs b/crates/engine/src/cmd/interchange.rs index bf0e011a0..12e1e1b13 100644 --- a/crates/engine/src/cmd/interchange.rs +++ b/crates/engine/src/cmd/interchange.rs @@ -511,8 +511,10 @@ mod tests { for link in links { let (idml, _) = linked_idml(link, false).unwrap(); let (doc, seen) = crate::io::touched(|| import(&idml, Some(&package)).unwrap()); - // Beside the package, and the link itself where it is on this computer. - assert!(seen.iter().all(|p| p.starts_with(&dir) || p == std::path::Path::new(link)), "{link}: {seen:?}"); + // Beside the package, and the link itself where it is on this computer (on Windows, + // `/dev/zero` is `\dev\zero` on the package's drive). + let itself = crate::io::document_path(link, Some(&package)).ok(); + assert!(seen.iter().all(|p| p.starts_with(&dir) || itself.as_ref() == Some(p)), "{link}: {seen:?}"); let asset = doc.assets.values().next().unwrap(); assert!(asset.data.is_empty(), "{link}"); assert_eq!(super::super::links::status(asset, None), "missing", "{link}"); diff --git a/crates/engine/src/cmd/links.rs b/crates/engine/src/cmd/links.rs index 70ad8dac1..ba3fef4f6 100644 --- a/crates/engine/src/cmd/links.rs +++ b/crates/engine/src/cmd/links.rs @@ -858,7 +858,7 @@ mod tests { assert_eq!(a.pixels, Some((60, 20))); assert_eq!(a.mime, "application/postscript"); assert_eq!(a.data.as_slice(), eps(30).as_bytes()); - let moved = dir.join("new/replacement.eps"); + let moved = dir.join("new").join("replacement.eps"); std::fs::rename(&replacement, &moved).unwrap(); assert_eq!(s.execute("links.relinkFolder", &json!({"dir": dir.join("new").to_string_lossy()})).unwrap()["relinked"], 1); assert_eq!(s.doc().unwrap().doc.assets[&aid].link.as_deref(), moved.to_str());