mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-24 10:09:32 -06:00
Merge pull request #1254 from vangel76/fix-1221-windows-test-paths
#1221: two path-format test failures on Windows
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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}),
|
||||
|
||||
Reference in New Issue
Block a user