Skip the AVI test when the AVI files have left the library
Browse files at this commit283d44593bbcb006ae2ca75ec7c1cfc264d486a0Parent: 3e4bd29- fix
- skip the AVI test when the AVI files have left the library
1 changed file +11 -12
- crates/ec-probe/tests/library.rs +11 -12
crates/ec-probe/tests/library.rsmodified+11 -12
| @@ -185,10 +185,11 @@ fn assert_avi_index_is_bounded(path: &Path) { | |||
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | fn avi_indexed_point(path: &Path, target: u64, after: bool) -> (ec_riff::AviIndexPoint, f64) { | 187 | fn avi_indexed_point(path: &Path, target: u64, after: bool) -> (ec_riff::AviIndexPoint, f64) { |
| 188 | - let reader = ec_riff::AviReader::new(File::open(path).expect("open AVI")) | 188 | + let reader = |
| 189 | - .expect("AVI index builds"); | 189 | + ec_riff::AviReader::new(File::open(path).expect("open AVI")).expect("AVI index builds"); |
| 190 | let stream = *reader.audio_streams().first().expect("AVI audio stream"); | 190 | let stream = *reader.audio_streams().first().expect("AVI audio stream"); |
| 191 | - let interval = f64::from(stream.length) * f64::from(stream.scale) / f64::from(stream.rate) | 191 | + let interval = f64::from(stream.length) * f64::from(stream.scale) |
| 192 | + / f64::from(stream.rate) | ||
| 192 | / reader.index_len() as f64; | 193 | / reader.index_len() as f64; |
| 193 | ( | 194 | ( |
| 194 | reader | 195 | reader |
| @@ -198,11 +199,7 @@ fn avi_indexed_point(path: &Path, target: u64, after: bool) -> (ec_riff::AviInde | |||
| 198 | ) | 199 | ) |
| 199 | } | 200 | } |
| 200 | 201 | ||
| 201 | -fn samples_to_avi_units( | 202 | +fn samples_to_avi_units(stream: ec_riff::AviAudioStream, samples: u64, round_up: bool) -> u64 { |
| 202 | - stream: ec_riff::AviAudioStream, | ||
| 203 | - samples: u64, | ||
| 204 | - round_up: bool, | ||
| 205 | -) -> u64 { | ||
| 206 | let denominator = u128::from(stream.scale) * u128::from(stream.sample_rate); | 203 | let denominator = u128::from(stream.scale) * u128::from(stream.sample_rate); |
| 207 | let numerator = u128::from(samples) * u128::from(stream.rate); | 204 | let numerator = u128::from(samples) * u128::from(stream.rate); |
| 208 | let units = if round_up { | 205 | let units = if round_up { |
| @@ -221,7 +218,6 @@ fn avi_codec_preroll(codec: CodecId, rate: u32) -> f64 { | |||
| 221 | } | 218 | } |
| 222 | } | 219 | } |
| 223 | 220 | ||
| 224 | - | ||
| 225 | fn decode_stream_to_eof( | 221 | fn decode_stream_to_eof( |
| 226 | reader: &mut Reader, | 222 | reader: &mut Reader, |
| 227 | stream: u32, | 223 | stream: u32, |
| @@ -385,8 +381,7 @@ fn assert_avi_seeks_match_reference(path: &Path) { | |||
| 385 | let ours = | 381 | let ours = |
| 386 | decode_window(&mut reader, audio.index, 2.0).expect("decode after seek"); | 382 | decode_window(&mut reader, audio.index, 2.0).expect("decode after seek"); |
| 387 | let theirs = reference_seek_window(path, at); | 383 | let theirs = reference_seek_window(path, at); |
| 388 | - let (lag, score) = | 384 | + let (lag, score) = best_frame_corr(&ours, &theirs, channels, frame_samples); |
| 389 | - best_frame_corr(&ours, &theirs, channels, frame_samples); | ||
| 390 | assert!( | 385 | assert!( |
| 391 | score >= 0.999, | 386 | score >= 0.999, |
| 392 | "{} @{:.0}% {label}: target {target:.3}s landed {at:.3}s lag {lag} frames corr vs reference decoder = {score}", | 387 | "{} @{:.0}% {label}: target {target:.3}s landed {at:.3}s lag {lag} frames corr vs reference decoder = {score}", |
| @@ -615,7 +610,11 @@ fn avi_audio_chunks_end_cleanly_on_real_files() { | |||
| 615 | assert!(packets > 0, "{}: no audio packets", path.display()); | 610 | assert!(packets > 0, "{}: no audio packets", path.display()); |
| 616 | assert!(frames > 0, "{}: no decoded audio", path.display()); | 611 | assert!(frames > 0, "{}: no decoded audio", path.display()); |
| 617 | } | 612 | } |
| 618 | - assert!(present > 0, "AVI files absent"); | 613 | + if present == 0 { |
| 614 | + // The library is his, so a file can leave it; the sibling AVI tests | ||
| 615 | + // skip the same way rather than failing a run on a deleted download. | ||
| 616 | + eprintln!("AVI files absent, skipping"); | ||
| 617 | + } | ||
| 619 | } | 618 | } |
| 620 | 619 | ||
| 621 | #[test] | 620 | #[test] |