Tests: oracle and fixture files go in an exclusively owned temporary directory (#3497)

This commit is contained in:
Dylan M. Taylor
2026-11-11 14:35:19 -05:00
committed by GitHub
parent bed71484a8
commit f0e49012dc
10 changed files with 20 additions and 13 deletions
Generated
+3
View File
@@ -1480,6 +1480,7 @@ name = "effectcraft-av1enc"
version = "0.24.0"
dependencies = [
"filmcraft-av1",
"tempfile",
]
[[package]]
@@ -1593,6 +1594,7 @@ dependencies = [
"image",
"log",
"rayon",
"tempfile",
"thiserror 2.0.21",
"web-time",
]
@@ -1769,6 +1771,7 @@ dependencies = [
"log",
"rayon",
"serde_json",
"tempfile",
"thiserror 2.0.21",
]
+1
View File
@@ -12,4 +12,5 @@ workspace = true
[dependencies]
[dev-dependencies]
tempfile = { workspace = true }
filmcraft-av1 = { workspace = true }
+2 -2
View File
@@ -57,8 +57,8 @@ fn check(name: &str, cfg: EncoderConfig, pics: &[Pic]) -> Vec<u32> {
recons.push(enc.last_reconstruction().expect("reconstruction"));
levels.push(enc.last_loop_filter_level().expect("level"));
}
let dir = std::env::temp_dir().join(format!("effectcraft-av1enc-{}-{name}", std::process::id()));
std::fs::create_dir_all(&dir).expect("temp dir");
let guard = tempfile::tempdir().expect("temp dir");
let dir = guard.path().to_path_buf();
let input = dir.join("in.ivf");
let output = dir.join("out.yuv");
std::fs::write(&input, ivf(w, h, &packets)).expect("write ivf");
+1
View File
@@ -31,6 +31,7 @@ thiserror = { workspace = true }
log = { workspace = true }
[dev-dependencies]
tempfile = { workspace = true }
effectcraft-media = { workspace = true }
effectcraft-effects = { workspace = true }
effectcraft-color = { workspace = true }
+2 -1
View File
@@ -342,7 +342,8 @@ fn ffmpeg_oracle_decodes_ogg_opus() {
}
}
let (enc, packets) = encode(&pcm, channels, rate);
let path = std::env::temp_dir().join(format!("effectcraft-opusenc-{}-{channels}.opus", std::process::id()));
let guard = tempfile::tempdir().unwrap();
let path = guard.path().join("out.opus");
std::fs::write(&path, ogg_opus(&enc, &packets, len)).unwrap();
let out = Command::new("ffmpeg")
.args(["-v", "error", "-i"])
+2 -2
View File
@@ -389,8 +389,8 @@ fn wav_and_aiff_channels_and_formats() {
#[test]
fn cancelled_export_removes_only_files_it_opened() {
use effectcraft_export::ExportError;
let dir = std::env::temp_dir().join(format!("ec-cancel-owned-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let guard = tempfile::tempdir().unwrap();
let dir = guard.path().to_path_buf();
let (p, cid) = project(FrameRate::new(25, 1), |_, _| {});
struct Overflow;
impl StorageQuota for Overflow {
+4 -4
View File
@@ -130,8 +130,8 @@ fn ffmpeg_decodes_our_stream() {
ivf.extend_from_slice(&(frame.len() as u32).to_le_bytes());
ivf.extend_from_slice(&0u64.to_le_bytes());
ivf.extend_from_slice(&frame);
let dir = std::env::temp_dir().join(format!("effectcraft-vp9-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let guard = tempfile::tempdir().unwrap();
let dir = guard.path().to_path_buf();
let path = dir.join("a.ivf");
std::fs::write(&path, &ivf).unwrap();
let out = std::process::Command::new("ffmpeg")
@@ -291,8 +291,8 @@ fn ffmpeg_matches(w: usize, h: usize, frames: &[Vec<u8>], recon: &[[Vec<u8>; 3]]
ivf.extend_from_slice(&(t as u64).to_le_bytes());
ivf.extend_from_slice(f);
}
let dir = std::env::temp_dir().join(format!("effectcraft-vp9-{name}-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let guard = tempfile::Builder::new().prefix(&format!("effectcraft-vp9-{name}-")).tempdir().unwrap();
let dir = guard.path().to_path_buf();
let path = dir.join("a.ivf");
std::fs::write(&path, &ivf).unwrap();
let out = std::process::Command::new("ffmpeg")
+2 -2
View File
@@ -276,8 +276,8 @@ pub(super) fn wat_plugin(id: &str, api: i32, render: &str) -> String {
#[test]
fn plugin_loading_reports_bad_modules_and_survives_failing_renders() {
let dir = std::env::temp_dir().join(format!("effectcraft-host-plugins-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let guard = tempfile::tempdir().unwrap();
let dir = guard.path().to_path_buf();
let files = [
("a-good.wasm", wat_plugin("org.test.host.good", 1, "i32.const 0").into_bytes()),
("b-garbage.wasm", b"\0asm\x01\0\0\0garbage".to_vec()),
+1
View File
@@ -38,5 +38,6 @@ thiserror = { workspace = true }
log = { workspace = true }
[dev-dependencies]
tempfile = { workspace = true }
# (tests render comps that read layers through effects; already a dependency of effectcraft-render)
effectcraft-effects = { workspace = true }
+2 -2
View File
@@ -747,8 +747,8 @@ fn sequence_gaps_hold_the_previous_frame() {
/// parallax project's 21120-px plates were decoded and resampled for every frame at Quarter).
#[test]
fn stills_at_reduced_sizes_are_resampled_once() {
let dir = std::env::temp_dir().join(format!("ec-still-size-{}", std::process::id()));
std::fs::create_dir_all(&dir).expect("temp dir");
let guard = tempfile::tempdir().expect("temp dir");
let dir = guard.path().to_path_buf();
let p = dir.join("plate.png");
let px = |x: u32, y: u32| {
image::Rgba([(x * 7 % 256) as u8, (y * 13 % 256) as u8, ((x ^ y) % 256) as u8, if (x + y).is_multiple_of(5) { 0 } else { 255 - (x % 128) as u8 }])