Skip to content

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

Preflight: the missing-link test makes the temporary folder absolute

dotCooCooc1561f7ccf6b
diff --git a/crates/engine/src/cmd/preflight.rs b/crates/engine/src/cmd/preflight.rs
index 2d9698ba1..1f942a9c8 100644
--- a/crates/engine/src/cmd/preflight.rs
+++ b/crates/engine/src/cmd/preflight.rs
@@ -354,9 +354,10 @@ 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();
- // 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");
+ // On Windows, `/x` names no drive, so `document_path` refuses it when the document has no path. `TMPDIR` can be
+ // relative on macOS and Linux, so the temporary folder is made absolute.
+ let temp = std::path::absolute(std::env::temp_dir()).unwrap();
+ let link = temp.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();