diff --git a/crates/ec-hw/tests/gpu.rs b/crates/ec-hw/tests/gpu.rs index c575496a..58fa0b68 100644 --- a/crates/ec-hw/tests/gpu.rs +++ b/crates/ec-hw/tests/gpu.rs @@ -366,13 +366,23 @@ fn compare_against_ffmpeg(files: &[PathBuf], codec: Codec, ten_bit: bool) { } } +/// The fixture's own name. Never the whole path: a checkout directory called +/// `edith_codecs-av1fast` made every `.ivf` — VP9 included — select as an AV1 +/// fixture, and the VP9 streams then came back as `obu_forbidden_bit is set`. +fn name_of(p: &Path) -> String { + p.file_name() + .unwrap_or_default() + .to_string_lossy() + .to_string() +} + /// The 4:2:0 fixtures of one kind; the 4:4:4 and monochrome ones are the /// profiles this GPU does not decode, and have their own test. fn profile_420(pattern: &str, codec: &str) -> Vec { fixtures(pattern) .into_iter() .filter(|p| { - let name = p.to_string_lossy().to_string(); + let name = name_of(p); name.contains(codec) && !name.contains("444") && !name.contains("monochrome") }) .collect() @@ -381,17 +391,36 @@ fn profile_420(pattern: &str, codec: &str) -> Vec { fn eight_bit(pattern: &str, codec: &str) -> Vec { profile_420(pattern, codec) .into_iter() - .filter(|p| !p.to_string_lossy().contains("10bit")) + .filter(|p| !name_of(p).contains("10bit")) .collect() } fn ten_bit(pattern: &str, codec: &str) -> Vec { profile_420(pattern, codec) .into_iter() - .filter(|p| p.to_string_lossy().contains("10bit")) + .filter(|p| name_of(p).contains("10bit")) .collect() } +/// The selection must not depend on where the repository is checked out. +#[test] +fn fixture_selection_ignores_the_checkout_path() { + for p in eight_bit(".ivf", "av1") { + let name = name_of(&p); + assert!( + name.starts_with("av1") && !name.contains("10bit"), + "{name} is not an 8-bit AV1 fixture" + ); + } + for p in ten_bit(".ivf", "vp9") { + let name = name_of(&p); + assert!( + name.starts_with("vp9") && name.contains("10bit"), + "{name} is not a 10-bit VP9 fixture" + ); + } +} + #[test] fn h264_matches_ffmpeg() { compare_against_ffmpeg(&fixtures(".264"), Codec::H264, false); diff --git a/crates/ec-image/tests/differential.rs b/crates/ec-image/tests/differential.rs index 9b7cd6ed..5fcea124 100644 --- a/crates/ec-image/tests/differential.rs +++ b/crates/ec-image/tests/differential.rs @@ -11,6 +11,15 @@ use image::GenericImageView; use std::path::{Path, PathBuf}; +/// The fixture's own name — never the whole path, which carries the checkout +/// directory and has matched fixture keywords by accident. +fn name_of(p: &std::path::Path) -> String { + p.file_name() + .unwrap_or_default() + .to_string_lossy() + .to_string() +} + fn fixtures() -> PathBuf { Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/stills") } @@ -115,7 +124,7 @@ fn png_decodes_pixel_exactly() { fn webp_lossless_decodes_pixel_exactly() { let files: Vec = corpus("webp") .into_iter() - .filter(|p| p.to_string_lossy().contains("lossless")) + .filter(|p| name_of(p).contains("lossless")) .collect(); if files.is_empty() && skip("webp") { return; @@ -183,7 +192,7 @@ fn jpeg_matches_the_incumbent_within_rounding() { fn webp_lossy_reconstructs_at_least_as_well_as_the_incumbent() { let files: Vec = corpus("webp") .into_iter() - .filter(|p| p.to_string_lossy().contains("lossy")) + .filter(|p| name_of(p).contains("lossy")) .collect(); if files.is_empty() && skip("webp") { return; @@ -235,7 +244,7 @@ fn header_dimensions_match_the_incumbent() { let mut checked = 0; for extension in ["png", "jpg", "webp"] { for path in corpus(extension) { - if path.to_string_lossy().contains("animated") { + if name_of(&path).contains("animated") { continue; } let bytes = std::fs::read(&path).unwrap(); diff --git a/crates/ec-mp4/tests/mp4.rs b/crates/ec-mp4/tests/mp4.rs index bb610b31..58ecbc9e 100644 --- a/crates/ec-mp4/tests/mp4.rs +++ b/crates/ec-mp4/tests/mp4.rs @@ -246,7 +246,7 @@ fn every_fixture_demuxes_into_the_streams_ffprobe_reports() { rates[i], avg_rates[i] ); - if path.to_string_lossy().contains("23.976") { + if name_of(&path).contains("23.976") { assert_eq!( video.frame_rate, Some(TimeBase::new(24_000, 1001)), diff --git a/crates/ec-ogg/tests/ogg.rs b/crates/ec-ogg/tests/ogg.rs index 072a9416..78a49393 100644 --- a/crates/ec-ogg/tests/ogg.rs +++ b/crates/ec-ogg/tests/ogg.rs @@ -19,6 +19,15 @@ use ec_core::{ }; use ec_ogg::{Mapping, OggDemuxer, OggMuxer, granule_of, granule_side_data}; +/// The fixture's own name — never the whole path, which carries the checkout +/// directory and has matched fixture keywords by accident. +fn name_of(p: &std::path::Path) -> String { + p.file_name() + .unwrap_or_default() + .to_string_lossy() + .to_string() +} + fn fixtures() -> PathBuf { Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/audio") } @@ -327,7 +336,7 @@ fn page_size_does_not_change_the_audio() { let files = ogg_fixtures(); let Some(path) = files .iter() - .find(|p| p.to_string_lossy().contains("vorbis-ogg-stereo-48000")) + .find(|p| name_of(p).contains("vorbis-ogg-stereo-48000")) else { eprintln!("fixtures absent — skipping"); return; @@ -341,7 +350,7 @@ fn damage_costs_one_page_and_no_more() { let files = ogg_fixtures(); let Some(path) = files .iter() - .find(|p| p.to_string_lossy().contains("vorbis-ogg-stereo-44100")) + .find(|p| name_of(p).contains("vorbis-ogg-stereo-44100")) else { eprintln!("fixtures absent — skipping"); return; @@ -458,7 +467,7 @@ fn reads_flac_in_ogg() { let files = ogg_fixtures(); let Some(source) = files .iter() - .find(|p| p.to_string_lossy().contains("vorbis-ogg-stereo-44100")) + .find(|p| name_of(p).contains("vorbis-ogg-stereo-44100")) else { eprintln!("fixtures absent — skipping"); return;