diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index a382326b..86c7cf41 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -13682,13 +13682,27 @@ mod tests { use std::io::Write; use std::process::{Command, Stdio}; + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes one AV1 OBU stream with ffmpeg and hands back its one 4:2:0 diff --git a/crates/ec-av1/src/encode.rs b/crates/ec-av1/src/encode.rs index b84fdf92..2c12a1e7 100644 --- a/crates/ec-av1/src/encode.rs +++ b/crates/ec-av1/src/encode.rs @@ -3063,13 +3063,27 @@ mod tests { use std::io::Write; use std::process::{Command, Stdio}; + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes an AV1 OBU stream with ffmpeg and hands back the three planes. diff --git a/crates/ec-av1/src/encoder.rs b/crates/ec-av1/src/encoder.rs index 06b07c32..0aabdf12 100644 --- a/crates/ec-av1/src/encoder.rs +++ b/crates/ec-av1/src/encoder.rs @@ -362,13 +362,27 @@ mod tests { use super::*; use std::process::{Command, Stdio}; + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } fn test_card(width: usize, height: usize, shift: usize) -> Picture { diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 20dbbc98..f1595d1d 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -867,13 +867,27 @@ mod tests { hash } + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes `frames` concatenated 4:2:0 frames out of one AV1 OBU stream. diff --git a/crates/ec-av1/src/tile.rs b/crates/ec-av1/src/tile.rs index ab0b3b7c..60fcc201 100644 --- a/crates/ec-av1/src/tile.rs +++ b/crates/ec-av1/src/tile.rs @@ -2983,13 +2983,27 @@ mod tests { } } + /// Whether ffmpeg is on PATH. Absence normally SKIPs, but + /// `EC_AV1_REQUIRE_FFMPEG=1` -- or `EC_AV1_REQUIRE_AOMENC=1`, since every + /// aomenc gate decodes its stream through ffmpeg and is meaningless + /// without it -- turns it into a hard failure. Without this the require + /// flag was silently short-circuited: `!have_ffmpeg()` is evaluated first + /// in `if !have_ffmpeg() || !have_aomenc()`, so a machine with no ffmpeg + /// printed SKIP and reported green (class gate-skips-on-its-own-failure). fn have_ffmpeg() -> bool { - Command::new("ffmpeg") + let present = Command::new("ffmpeg") .arg("-version") .stdout(Stdio::null()) .stderr(Stdio::null()) .status() - .is_ok_and(|s| s.success()) + .is_ok_and(|s| s.success()); + assert!( + present + || (std::env::var_os("EC_AV1_REQUIRE_FFMPEG").is_none() + && std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none()), + "EC_AV1_REQUIRE_FFMPEG/EC_AV1_REQUIRE_AOMENC is set but no working ffmpeg on PATH" + ); + present } /// Decodes an AV1 OBU stream with ffmpeg and hands back the planes.