Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Links: the folder relink and IDML link tests expect Windows paths on Windows

dotCooCoo52e404754f76
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());