Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

#1221: two path-format test failures on Windows

vangel7689ae151c03de
diff --git a/apps/effectcraft-cli/tests/cli.rs b/apps/effectcraft-cli/tests/cli.rs
index 62aefd5d6..bd5d50020 100644
--- a/apps/effectcraft-cli/tests/cli.rs
+++ b/apps/effectcraft-cli/tests/cli.rs
@@ -25,12 +25,19 @@ fn ok_json(args: &[&str]) -> Value {
v
}
+/// `std::fs::canonicalize` without Windows' `\\?\` verbatim prefix, which a child's `current_dir()` never reports.
+fn canonical(path: &std::path::Path) -> std::io::Result<PathBuf> {
+ let path = std::fs::canonicalize(path)?;
+ let plain = path.to_str().and_then(|s| s.strip_prefix(r"\\?\")).filter(|s| s.as_bytes().get(1) == Some(&b':'));
+ Ok(plain.map(PathBuf::from).unwrap_or(path))
+}
+
fn tmp(name: &str) -> PathBuf {
let d = std::env::temp_dir().join(format!("ec-cli-test-{}", std::process::id()));
std::fs::create_dir_all(&d).unwrap();
// macOS's `/var` is a symlink to `/private/var`: a child process resolves its working
// directory through `current_dir()`, which is canonical, so compare canonical paths.
- std::fs::canonicalize(&d).unwrap_or(d).join(name)
+ canonical(&d).unwrap_or(d).join(name)
}
#[test]
@@ -260,7 +267,7 @@ fn render_out_is_relative_to_the_working_directory() {
std::fs::create_dir_all(&proj).unwrap();
std::fs::create_dir_all(&elsewhere).unwrap();
// current_dir resolves aliases such as macOS /var -> /private/var.
- let root = root.canonicalize().unwrap();
+ let root = canonical(&root).unwrap();
let (proj, elsewhere) = (root.join("proj"), root.join("elsewhere"));
let project = proj.join("x.ecproj");
let p = project.to_str().unwrap();
diff --git a/crates/host/src/lib.rs b/crates/host/src/lib.rs
index 1e5311b09..bdb4e2bc3 100644
--- a/crates/host/src/lib.rs
+++ b/crates/host/src/lib.rs
@@ -290,7 +290,8 @@ mod tests {
let mut s = super::session();
s.exporter = Some(Arc::new(super::FileExporter { sink: Some(Arc::new(move |p: &str, d: Vec<u8>| g.lock().unwrap().push((p.to_string(), d)))) }));
s.execute("file.openDemoProject", json!({})).unwrap();
- let dir = "/no-such-dir-effectcraft-sink-test";
+ // Rooted without a drive letter is not absolute on Windows, where the engine joins it to the home drive.
+ let dir = if cfg!(windows) { "C:/no-such-dir-effectcraft-sink-test" } else { "/no-such-dir-effectcraft-sink-test" };
s.execute(
"renderQueue.add",
json!({"format": "gif", "output": format!("{dir}/a.gif"), "resolution": 0.0625, "timeSpan": "custom", "start": 0.0, "end": 0.2}),