Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Decoder tests: clips made at once by two tests no longer collide

gelenmedya1cd4e4d0cc98
diff --git a/crates/rustdecoder/tests/audio_codecs.rs b/crates/rustdecoder/tests/audio_codecs.rs
index 36180c39..316102dd 100644
--- a/crates/rustdecoder/tests/audio_codecs.rs
+++ b/crates/rustdecoder/tests/audio_codecs.rs
@@ -68,6 +68,7 @@ fn make(name: &str, rate: u32, channels: u32, acodec: &[&str]) -> PathBuf {
return out;
}
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30"]);
match channels {
@@ -90,7 +91,11 @@ fn make(name: &str, rate: u32, channels: u32, acodec: &[&str]) -> PathBuf {
};
let ok = c.args(["-t", "3"]).args(video).args(acodec).arg(&tmp).status().expect("ffmpeg").success();
assert!(ok, "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/common/av.rs b/crates/rustdecoder/tests/common/av.rs
index 314de89a..39353ea1 100644
--- a/crates/rustdecoder/tests/common/av.rs
+++ b/crates/rustdecoder/tests/common/av.rs
@@ -26,6 +26,7 @@ fn make_av_clip_codec(name: &str, rate: u32, stereo: bool, acodec: &[&str], h264
return out;
}
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30"]);
c.args(["-f", "lavfi", "-i"]).arg(format!("sine=f=440:r={rate}:d=3"));
@@ -46,7 +47,11 @@ fn make_av_clip_codec(name: &str, rate: u32, stereo: bool, acodec: &[&str], h264
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/common/contclips.rs b/crates/rustdecoder/tests/common/contclips.rs
index 2a85a824..b7d8a7ab 100644
--- a/crates/rustdecoder/tests/common/contclips.rs
+++ b/crates/rustdecoder/tests/common/contclips.rs
@@ -17,6 +17,7 @@ pub fn make_av(name: &str, video: &[&str], audio: &[&str], mux: &[&str]) -> Path
return out;
}
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-f", "lavfi", "-i", "sine=f=440:r=48000:d=3", "-t", "3"]);
c.args(video);
@@ -28,7 +29,11 @@ pub fn make_av(name: &str, video: &[&str], audio: &[&str], mux: &[&str]) -> Path
c.args(mux).arg(&tmp);
let status = c.status().expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/common/fragclips.rs b/crates/rustdecoder/tests/common/fragclips.rs
index 6e011963..880cb5e4 100644
--- a/crates/rustdecoder/tests/common/fragclips.rs
+++ b/crates/rustdecoder/tests/common/fragclips.rs
@@ -18,6 +18,7 @@ pub fn make_frag(name: &str, video: &[&str], mux: &[&str]) -> PathBuf {
return out;
}
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-f", "lavfi", "-i", "sine=f=440:r=48000:d=3", "-t", "3", "-vf", "noise=alls=6:allf=t"])
.args(video)
@@ -28,6 +29,10 @@ pub fn make_frag(name: &str, video: &[&str], mux: &[&str]) -> PathBuf {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/common/mkvclips.rs b/crates/rustdecoder/tests/common/mkvclips.rs
index 24cd15ac..53f456cf 100644
--- a/crates/rustdecoder/tests/common/mkvclips.rs
+++ b/crates/rustdecoder/tests/common/mkvclips.rs
@@ -18,12 +18,17 @@ pub fn make_mkv(name: &str, video: &[&str], audio: &[&str], mux: &[&str]) -> Pat
}
let ext = out.extension().unwrap().to_str().unwrap().to_string();
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-f", "lavfi", "-i", "sine=f=440:r=48000:d=3", "-t", "3"]);
c.args(video).args(audio).args(mux).args(["-f", if ext == "webm" { "webm" } else { "matroska" }]).arg(&tmp);
let status = c.status().expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/common/mod.rs b/crates/rustdecoder/tests/common/mod.rs
index d18f611c..08491b4f 100644
--- a/crates/rustdecoder/tests/common/mod.rs
+++ b/crates/rustdecoder/tests/common/mod.rs
@@ -36,6 +36,7 @@ pub fn make_clip(name: &str, pix_fmt: &str, x265: &str, noise: bool) -> PathBuf
return out;
}
let tmp = out.with_extension("part.mp4");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-t", "3"]);
if noise {
@@ -48,7 +49,11 @@ pub fn make_clip(name: &str, pix_fmt: &str, x265: &str, noise: bool) -> PathBuf
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
@@ -59,6 +64,7 @@ pub fn make_rotated(clip: &std::path::Path, name: &str, ccw_degrees: i32) -> Pat
return out;
}
let tmp = out.with_extension("part.mp4");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-display_rotation", &ccw_degrees.to_string(), "-i"])
.arg(clip)
@@ -67,7 +73,11 @@ pub fn make_rotated(clip: &std::path::Path, name: &str, ccw_degrees: i32) -> Pat
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not rotate {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
@@ -80,6 +90,7 @@ pub fn make_h264_clip(name: &str, x264: &str, noise: bool) -> PathBuf {
return out;
}
let tmp = out.with_extension("part.mp4");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-t", "3"]);
if noise {
@@ -87,6 +98,10 @@ pub fn make_h264_clip(name: &str, x264: &str, noise: bool) -> PathBuf {
}
let status = c.args(["-c:v", "libx264", "-pix_fmt", "yuv420p", "-x264-params"]).arg(format!("log-level=error:{x264}")).arg(&tmp).status().expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/common/tracks.rs b/crates/rustdecoder/tests/common/tracks.rs
index 3c6727c7..b52a1388 100644
--- a/crates/rustdecoder/tests/common/tracks.rs
+++ b/crates/rustdecoder/tests/common/tracks.rs
@@ -18,6 +18,7 @@ pub fn make(name: &str, freqs: &[u32], acodec: &[&str], extra: &[&str]) -> PathB
return out;
}
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=320x180:rate=25"]);
for f in freqs {
@@ -34,7 +35,11 @@ pub fn make(name: &str, freqs: &[u32], acodec: &[&str], extra: &[&str]) -> PathB
}
let st = c.arg(&tmp).status().expect("ffmpeg");
assert!(st.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/deinterlace.rs b/crates/rustdecoder/tests/deinterlace.rs
index 06cbfe3f..6135260a 100644
--- a/crates/rustdecoder/tests/deinterlace.rs
+++ b/crates/rustdecoder/tests/deinterlace.rs
@@ -20,6 +20,7 @@ fn interlaced_clip() -> std::path::PathBuf {
return out;
}
let tmp = out.with_extension("part.mp4");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let st = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=60", "-t", "2", "-vf", "interlace=scan=tff", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-profile:v", "high"])
.args(["-x264-params", "tff=1:bframes=2:keyint=30", "-r", "30"])
@@ -27,7 +28,11 @@ fn interlaced_clip() -> std::path::PathBuf {
.status()
.expect("ffmpeg");
assert!(st.success());
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/dnx.rs b/crates/rustdecoder/tests/dnx.rs
index 3ffef202..e452e002 100644
--- a/crates/rustdecoder/tests/dnx.rs
+++ b/crates/rustdecoder/tests/dnx.rs
@@ -34,6 +34,7 @@ fn make(s: &Spec) -> PathBuf {
return out;
}
let tmp = out.with_extension("part.mov");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i"])
.arg(format!("testsrc2=size={}x{}:rate={}", s.size.0, s.size.1, s.rate))
@@ -44,7 +45,11 @@ fn make(s: &Spec) -> PathBuf {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {}", s.name);
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/gpu_av1.rs b/crates/rustdecoder/tests/gpu_av1.rs
index 02ce29a2..bdc900a4 100644
--- a/crates/rustdecoder/tests/gpu_av1.rs
+++ b/crates/rustdecoder/tests/gpu_av1.rs
@@ -42,6 +42,7 @@ fn make_clip(c: &Clip) -> PathBuf {
}
let ext = out.extension().unwrap().to_string_lossy().to_string();
let tmp = out.with_file_name(format!("part-{}", c.name));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let vf = match c.vf {
"" => "noise=alls=6:allf=t".to_string(),
"clean" => "null".to_string(),
@@ -57,7 +58,11 @@ fn make_clip(c: &Clip) -> PathBuf {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {}", c.name);
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/gpu_h264.rs b/crates/rustdecoder/tests/gpu_h264.rs
index aeef6e19..2920cb07 100644
--- a/crates/rustdecoder/tests/gpu_h264.rs
+++ b/crates/rustdecoder/tests/gpu_h264.rs
@@ -47,6 +47,7 @@ fn make_clip(c: &Clip) -> PathBuf {
return out;
}
let tmp = out.with_extension("part.mp4");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let vf = if c.vf.is_empty() { "noise=alls=6:allf=t".to_string() } else { format!("noise=alls=6:allf=t,{}", c.vf) };
let mut cmd = Command::new("ffmpeg");
cmd.args(["-y", "-v", "error", "-f", "lavfi", "-i"]).arg(format!("testsrc2=size={}:rate=30", c.size)).args(["-t", &c.secs.to_string(), "-vf", &vf]);
@@ -66,7 +67,11 @@ fn make_clip(c: &Clip) -> PathBuf {
return PathBuf::new();
}
assert!(status.success(), "ffmpeg could not make {}", c.name);
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
@@ -280,6 +285,7 @@ fn to_transport_stream(src: &Path, name: &str) -> Option<PathBuf> {
let out = temp_dir().join(name);
if !out.exists() {
let tmp = out.with_extension("part");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let m2ts = name.ends_with(".m2ts");
let mut cmd = Command::new("ffmpeg");
cmd.args(["-y", "-v", "error", "-i"]).arg(src).args(["-c", "copy", "-f", "mpegts"]);
@@ -290,7 +296,11 @@ fn to_transport_stream(src: &Path, name: &str) -> Option<PathBuf> {
if !cmd.status().is_ok_and(|s| s.success()) {
return None;
}
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
}
Some(out)
}
diff --git a/crates/rustdecoder/tests/gpu_hevc.rs b/crates/rustdecoder/tests/gpu_hevc.rs
index f6bbf665..2e3da9ea 100644
--- a/crates/rustdecoder/tests/gpu_hevc.rs
+++ b/crates/rustdecoder/tests/gpu_hevc.rs
@@ -30,6 +30,7 @@ fn make_clip(name: &str, pix_fmt: &str, x265: &str) -> PathBuf {
return out;
}
let tmp = out.with_extension("part.mp4");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-t", "3"])
.args(["-vf", "noise=alls=6:allf=t"])
@@ -39,7 +40,11 @@ fn make_clip(name: &str, pix_fmt: &str, x265: &str) -> PathBuf {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/gpu_mpeg2.rs b/crates/rustdecoder/tests/gpu_mpeg2.rs
index 8c78370b..64f43234 100644
--- a/crates/rustdecoder/tests/gpu_mpeg2.rs
+++ b/crates/rustdecoder/tests/gpu_mpeg2.rs
@@ -34,6 +34,7 @@ fn make_clip(c: &Clip) -> PathBuf {
return out;
}
let tmp = out.with_file_name(format!("part-{}", c.name));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i"])
.arg(format!("testsrc2=size={}:rate=25", c.size))
@@ -45,7 +46,11 @@ fn make_clip(c: &Clip) -> PathBuf {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {}", c.name);
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/gpu_vp9.rs b/crates/rustdecoder/tests/gpu_vp9.rs
index bf9c34eb..e939a93b 100644
--- a/crates/rustdecoder/tests/gpu_vp9.rs
+++ b/crates/rustdecoder/tests/gpu_vp9.rs
@@ -49,6 +49,7 @@ fn make_clip(c: &Clip) -> PathBuf {
return out;
}
let tmp = out.with_file_name(format!("part-{}", c.name));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let vf = match c.vf {
"" => "noise=alls=6:allf=t".to_string(),
"clean" => "null".to_string(),
@@ -76,7 +77,11 @@ fn make_clip(c: &Clip) -> PathBuf {
run(None, &log, &tmp, "webm")
};
assert!(status.success(), "ffmpeg could not make {}", c.name);
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
@@ -286,12 +291,17 @@ fn joined(name: &str, first: &str, second: &str) -> Option<PathBuf> {
let q = |p: &Path| format!("file '{}'\n", p.to_string_lossy().replace('\\', "/"));
std::fs::write(&list, format!("{}{}", q(&a), q(&b))).unwrap();
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg").args(["-y", "-v", "error", "-f", "concat", "-safe", "0", "-i"]).arg(&list).args(["-c", "copy", "-f", "webm"]).arg(&tmp).status().expect("ffmpeg");
let _ = std::fs::remove_file(&list);
if !status.success() {
return None;
}
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
Some(out)
}
diff --git a/crates/rustdecoder/tests/mxf.rs b/crates/rustdecoder/tests/mxf.rs
index 26c36888..08e21ed9 100644
--- a/crates/rustdecoder/tests/mxf.rs
+++ b/crates/rustdecoder/tests/mxf.rs
@@ -42,6 +42,7 @@ fn make(s: &Spec) -> PathBuf {
return out;
}
let tmp = out.with_extension("part.mxf");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let mut c = Command::new("ffmpeg");
c.args(["-y", "-v", "error", "-f", "lavfi", "-i"]).arg(format!("testsrc2=size={}x{}:rate=25", s.size.0, s.size.1));
if let Some((_, ch)) = s.audio {
@@ -54,7 +55,11 @@ fn make(s: &Spec) -> PathBuf {
}
let status = c.args(["-f", s.format]).arg(&tmp).status().expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {}", s.name);
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/par.rs b/crates/rustdecoder/tests/par.rs
index c43f0df5..82acaf32 100644
--- a/crates/rustdecoder/tests/par.rs
+++ b/crates/rustdecoder/tests/par.rs
@@ -25,6 +25,7 @@ fn make(name: &str, codec: &[&str], vf: &str, extra: &[&str]) -> PathBuf {
return out;
}
let tmp = out.with_file_name(format!("part-{name}"));
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-t", "1", "-vf", vf])
.args(codec)
@@ -34,7 +35,11 @@ fn make(name: &str, codec: &[&str], vf: &str, extra: &[&str]) -> PathBuf {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {name}");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}
diff --git a/crates/rustdecoder/tests/playback_av.rs b/crates/rustdecoder/tests/playback_av.rs
index 0f4e728c..5202e52c 100644
--- a/crates/rustdecoder/tests/playback_av.rs
+++ b/crates/rustdecoder/tests/playback_av.rs
@@ -512,6 +512,7 @@ fn clip_prores() -> Option<PathBuf> {
return Some(out);
}
let tmp = out.with_file_name("part-av_prores_pcm_st48.mov");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = std::process::Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-f", "lavfi", "-i", "sine=f=440:r=48000:d=3", "-f", "lavfi", "-i", "sine=f=660:r=48000:d=3"])
.args(["-filter_complex", "[1:a][2:a]amerge=inputs=2[a]", "-map", "0:v", "-map", "[a]", "-t", "3"])
@@ -520,7 +521,11 @@ fn clip_prores() -> Option<PathBuf> {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make the ProRes clip");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
Some(out)
}
@@ -581,6 +586,7 @@ fn clip_dnxhr() -> Option<PathBuf> {
return Some(out);
}
let tmp = out.with_file_name("part-av_dnxhr_pcm_st48.mov");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = std::process::Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-f", "lavfi", "-i", "sine=f=440:r=48000:d=3", "-f", "lavfi", "-i", "sine=f=660:r=48000:d=3"])
.args(["-filter_complex", "[1:a][2:a]amerge=inputs=2[a]", "-map", "0:v", "-map", "[a]", "-t", "3"])
@@ -589,7 +595,11 @@ fn clip_dnxhr() -> Option<PathBuf> {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make the DNxHR clip");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
Some(out)
}
diff --git a/crates/rustdecoder/tests/player.rs b/crates/rustdecoder/tests/player.rs
index 897f4d8e..2b5168c4 100644
--- a/crates/rustdecoder/tests/player.rs
+++ b/crates/rustdecoder/tests/player.rs
@@ -262,6 +262,7 @@ fn clip_prores() -> Option<std::path::PathBuf> {
let out = temp_dir().join("p_prores_hq.mov");
if !out.exists() {
let tmp = out.with_file_name("part-p_prores_hq.mov");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = std::process::Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-t", "3", "-vf", "noise=alls=6:allf=t"])
.args(["-c:v", "prores_ks", "-profile:v", "3", "-pix_fmt", "yuv422p10le", "-f", "mov"])
@@ -269,7 +270,11 @@ fn clip_prores() -> Option<std::path::PathBuf> {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make the ProRes clip");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
}
Some(out)
}
@@ -319,6 +324,7 @@ fn clip_dnxhr() -> Option<std::path::PathBuf> {
let out = temp_dir().join("p_dnxhr_hq.mov");
if !out.exists() {
let tmp = out.with_file_name("part-p_dnxhr_hq.mov");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = std::process::Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", "testsrc2=size=640x360:rate=30", "-t", "3", "-vf", "noise=alls=6:allf=t"])
.args(["-c:v", "dnxhd", "-profile:v", "dnxhr_hq", "-pix_fmt", "yuv422p", "-f", "mov"])
@@ -326,7 +332,11 @@ fn clip_dnxhr() -> Option<std::path::PathBuf> {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make the DNxHR clip");
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
}
Some(out)
}
diff --git a/crates/rustdecoder/tests/present.rs b/crates/rustdecoder/tests/present.rs
index ac11ea74..725e6a1f 100644
--- a/crates/rustdecoder/tests/present.rs
+++ b/crates/rustdecoder/tests/present.rs
@@ -197,6 +197,7 @@ fn flat_clip(name: &str, y: u32, transfer: &str) -> std::path::PathBuf {
let out = temp_dir().join(name);
if !out.exists() {
let tmp = out.with_extension("part.mp4");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let st = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i", &format!("color=c=black:s=640x360:r=30:d=1,format=yuv420p10le,geq=lum={y}:cb=512:cr=512")])
.args(["-c:v", "libx265", "-pix_fmt", "yuv420p10le", "-x265-params"])
@@ -205,7 +206,11 @@ fn flat_clip(name: &str, y: u32, transfer: &str) -> std::path::PathBuf {
.status()
.expect("ffmpeg");
assert!(st.success());
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
}
out
}
diff --git a/crates/rustdecoder/tests/prores.rs b/crates/rustdecoder/tests/prores.rs
index 0c5c2235..68d04c8c 100644
--- a/crates/rustdecoder/tests/prores.rs
+++ b/crates/rustdecoder/tests/prores.rs
@@ -36,6 +36,7 @@ fn make(s: &Spec) -> PathBuf {
return out;
}
let tmp = out.with_extension("part.mov");
+ let tmp = tmp.with_file_name(format!("{}{:?}-{}", std::process::id(), std::thread::current().id(), tmp.file_name().unwrap().to_string_lossy()));
let status = Command::new("ffmpeg")
.args(["-y", "-v", "error", "-f", "lavfi", "-i"])
.arg(format!("testsrc2=size={}x{}:rate=25", s.size.0, s.size.1))
@@ -46,7 +47,11 @@ fn make(s: &Spec) -> PathBuf {
.status()
.expect("ffmpeg");
assert!(status.success(), "ffmpeg could not make {}", s.name);
- std::fs::rename(&tmp, &out).unwrap();
+ // (another test making the same clip at the same time may have put it there first)
+ if std::fs::rename(&tmp, &out).is_err() {
+ let _ = std::fs::remove_file(&tmp);
+ assert!(out.exists(), "could not put {} in place", out.display());
+ }
out
}