Pin the four gates that turn a decode error into a SKIP
Browse files at this commit2cf598487ca55382264f0a4888fd9356f893c0a5Parent: 5e92401- test
- pin the four gates that turn a decode error into a SKIP
1 changed file +56 -1
crates/ec-av1/src/refusal_inventory.rsmodified+56 -1
| @@ -70,9 +70,27 @@ const REFUSALS: &[&str] = &[ | ||
| 70 | 70 | "filter intra on a HORZ/VERT strip (this decoder predicts square-only)", |
| 71 | 71 | ]; |
| 72 | 72 | |
| 73 | +/// Gates whose `Err` arm turns a decode failure into a printed SKIP rather than | |
| 74 | +/// a test failure. | |
| 75 | +/// | |
| 76 | +/// A gate named `..._decodes_pixel_exact` that cannot decode has failed, and | |
| 77 | +/// swallowing the error keeps the suite green while the gate proves nothing -- | |
| 78 | +/// the same vacuum as a gate whose feature never fires, arrived at from the | |
| 79 | +/// other side. These four predate the attempt-loop pattern the newer gates use | |
| 80 | +/// (encode several fixtures, require at least one to decode, hard-assert the | |
| 81 | +/// firing count). They are pinned here so the set cannot grow while they are | |
| 82 | +/// converted one at a time. | |
| 83 | +#[cfg(test)] | |
| 84 | +const GATES_THAT_SKIP_ON_A_DECODE_ERROR: &[&str] = &[ | |
| 85 | + "a_real_aomenc_filter_intra_stream_decodes_pixel_exact", | |
| 86 | + "a_real_aomenc_inter_sequence_with_deblocking_decodes_pixel_exact", | |
| 87 | + "a_real_aomenc_intra_stream_with_deblocking_decodes_pixel_exact", | |
| 88 | + "a_real_libaom_gradients_stream_with_cdef_decodes_pixel_exact", | |
| 89 | +]; | |
| 90 | + | |
| 73 | 91 | #[cfg(test)] |
| 74 | 92 | mod tests { |
| 75 | - use super::{CAPABILITY_CLAIMS, REFUSALS}; | |
| 93 | + use super::{CAPABILITY_CLAIMS, GATES_THAT_SKIP_ON_A_DECODE_ERROR, REFUSALS}; | |
| 76 | 94 | use std::collections::BTreeSet; |
| 77 | 95 | |
| 78 | 96 | /// Every distinct `unsupported(...)` reason on the decode path. |
| @@ -187,4 +205,41 @@ mod tests { | ||
| 187 | 205 | ); |
| 188 | 206 | } |
| 189 | 207 | } |
| 208 | + | |
| 209 | + /// No NEW gate may quietly turn a decode error into a skip. | |
| 210 | + #[test] | |
| 211 | + fn gates_that_swallow_a_decode_error_are_declared() { | |
| 212 | + let src = include_str!("stream.rs"); | |
| 213 | + let mut found: BTreeSet<String> = BTreeSet::new(); | |
| 214 | + for (i, _) in src.match_indices("\"SKIP ") { | |
| 215 | + let rest = &src[i + "\"SKIP ".len()..]; | |
| 216 | + let Some(colon) = rest.find(':') else { continue }; | |
| 217 | + let name = &rest[..colon]; | |
| 218 | + if !name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') { | |
| 219 | + continue; | |
| 220 | + } | |
| 221 | + // The tail of the message says what was skipped. Only "{e}" -- the | |
| 222 | + // decode error itself -- is the shape this test is about; "no | |
| 223 | + // ffmpeg"/"no aomenc" are tool absence, governed by | |
| 224 | + // EC_AV1_REQUIRE_AOMENC instead. | |
| 225 | + let Some(end) = rest.find("\"") else { continue }; | |
| 226 | + if rest[colon..end].contains("{e}") { | |
| 227 | + found.insert(name.to_owned()); | |
| 228 | + } | |
| 229 | + } | |
| 230 | + let listed: BTreeSet<&str> = GATES_THAT_SKIP_ON_A_DECODE_ERROR.iter().copied().collect(); | |
| 231 | + let added: Vec<&String> = found.iter().filter(|n| !listed.contains(n.as_str())).collect(); | |
| 232 | + assert!( | |
| 233 | + added.is_empty(), | |
| 234 | + "these gates turn a decode error into a printed SKIP and are not declared: \ | |
| 235 | + {added:#?}\nA gate that cannot decode has failed -- assert on the error, or use \ | |
| 236 | + the attempt-loop pattern (several fixtures, at least one must decode, firing count \ | |
| 237 | + hard-asserted)." | |
| 238 | + ); | |
| 239 | + let stale: Vec<&&str> = listed.iter().filter(|n| !found.contains(**n)).collect(); | |
| 240 | + assert!( | |
| 241 | + stale.is_empty(), | |
| 242 | + "{stale:#?} no longer swallow a decode error -- delete them from the list." | |
| 243 | + ); | |
| 244 | + } | |
| 190 | 245 | } |