From 6fd0800e2c7613a6d6d6d5d63522bb302e4b01d2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 21:12:12 -0800 Subject: [PATCH] image-codecs: tests pass with the tiff feature off Two tests encoded a TIFF without checking the `tiff` feature, so `cargo test -p craft-image-codecs` failed in a build that leaves TIFF out: `resolution_probe::tests::agrees_with_decode_for_encoded_files` and `fidelity::float_to_exr_and_tiff_is_clean`. Both now skip the TIFF case when the feature is off and still check their other formats. --- crates/image-codecs/src/resolution_probe_tests.rs | 3 ++- crates/image-codecs/tests/it/fidelity.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/image-codecs/src/resolution_probe_tests.rs b/crates/image-codecs/src/resolution_probe_tests.rs index 174a725479..f71184b66d 100644 --- a/crates/image-codecs/src/resolution_probe_tests.rs +++ b/crates/image-codecs/src/resolution_probe_tests.rs @@ -159,7 +159,8 @@ fn png_phys_in_metres_only_before_image_data() { fn agrees_with_decode_for_encoded_files() { let mut img = Image::from_raw(2, 1, ChannelLayout::Rgb, SampleType::U8, vec![10, 20, 30, 40, 50, 60]).unwrap(); img.meta.dpi = Some((300.0, 150.0)); - for format in [Format::Jpeg, Format::Png, Format::WebP, Format::Tiff] { + let formats = [Format::Jpeg, Format::Png, Format::WebP, Format::Tiff]; + for format in formats.into_iter().filter(|f| !matches!(f, Format::Tiff) || cfg!(feature = "tiff")) { let bytes = crate::encode(&img, format, &EncodeOptions::default()).unwrap(); let decoded = crate::decode_as(format, &bytes).unwrap().meta.dpi; assert_eq!(file_resolution(&bytes), decoded, "{format:?}"); diff --git a/crates/image-codecs/tests/it/fidelity.rs b/crates/image-codecs/tests/it/fidelity.rs index 63f453bf20..47a8717455 100644 --- a/crates/image-codecs/tests/it/fidelity.rs +++ b/crates/image-codecs/tests/it/fidelity.rs @@ -144,7 +144,8 @@ fn hdr_float_to_fits_clips() { #[cfg(all(feature = "exr", feature = "pnm"))] #[test] fn float_to_exr_and_tiff_is_clean() { - for f in [Format::OpenExr, Format::Tiff, Format::Pnm] { + let formats = [Format::OpenExr, Format::Tiff, Format::Pnm]; + for f in formats.into_iter().filter(|f| !matches!(f, Format::Tiff) || cfg!(feature = "tiff")) { assert!(warns(&test_image(ChannelLayout::Rgb, SampleType::F32), f).is_empty(), "{f:?}"); } }