From f5e1bda7ccdf3ed291c9bc10eacfcd85d762475e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 24 Oct 2026 01:14:04 -0700 Subject: [PATCH] Preflight: the missing-link test uses a path that is absolute on Windows too a_missing_link_shown_by_its_preview_is_still_reported stored the link /definitely/missing dir/photo.jpg in a document without a path. On Windows that path names no drive, so document_path refuses it as not absolute and the preflight message ends with "(the path is not valid)", and the test failed. The test now stores a link under std::env::temp_dir(), an absolute path with the default temporary-folder settings on Windows, macOS and Linux, and expects the message for that path. The preflight code is unchanged. --- crates/engine/src/cmd/preflight.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/preflight.rs b/crates/engine/src/cmd/preflight.rs index 19d64c1f..2d9698ba 100644 --- a/crates/engine/src/cmd/preflight.rs +++ b/crates/engine/src/cmd/preflight.rs @@ -354,11 +354,15 @@ mod placed_vector_tests { s.execute("file.place", &json!({"base64": base64_encode(&png), "name": "photo.jpg", "x": 72, "y": 72, "width": 20})).unwrap(); let doc = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc); let asset = doc.assets.values_mut().next().unwrap(); - std::sync::Arc::make_mut(asset).link = Some("/definitely/missing dir/photo.jpg".into()); + // The temporary folder is an absolute path with the default settings on Windows, macOS and Linux. On Windows, + // `/x` names no drive, so `document_path` refuses it when the document has no path. + let link = std::env::temp_dir().join(format!("dc-preflight-missing-{} dir", std::process::id())).join("photo.jpg"); + let link = link.to_string_lossy().into_owned(); + std::sync::Arc::make_mut(asset).link = Some(link.clone()); let r = s.execute("preflight.run", &json!({})).unwrap(); let missing: Vec<&str> = r["issues"].as_array().unwrap().iter().filter(|i| i["kind"] == "missingLink").map(|i| i["message"].as_str().unwrap()).collect(); - assert_eq!(missing, ["Missing link: /definitely/missing dir/photo.jpg"]); + assert_eq!(missing, [format!("Missing link: {link}")]); } }