From 459aae1e80ec825215dfd8860b89a160d6ca4b69 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 19:47:11 +0000 Subject: [PATCH] craft-pst, craft-exr, craft-cms, craft-prepress: smaller or sampled passes --- crates/cms/src/black_tests.rs | 6 ++++-- crates/exr/src/seek_tests.rs | 4 ++-- crates/prepress/Cargo.toml | 1 + crates/prepress/src/plates.rs | 3 ++- crates/pst/Cargo.toml | 1 + crates/pst/src/tests/salvage.rs | 6 ++++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/cms/src/black_tests.rs b/crates/cms/src/black_tests.rs index 8752cdaa2b..2d4864a990 100644 --- a/crates/cms/src/black_tests.rs +++ b/crates/cms/src/black_tests.rs @@ -70,10 +70,12 @@ fn the_destination_black_matches_the_source_lightness() { for intent in [Intent::RelativeColorimetric, Intent::Perceptual] { for bpc in [true, false] { let o = TransformOptions { intent, bpc, ..opts() }; - for (src, dst) in [(coated(), fogra()), (fogra(), coated())] { + // Both directions for one setting; the other settings in the forward one. + let directions = if intent == Intent::RelativeColorimetric && bpc { 2 } else { 1 }; + for (src, dst) in [(coated(), fogra()), (fogra(), coated())].into_iter().take(directions) { let bp = BlackPreserving::new(src, dst, o).unwrap(); let dst_black = lightness(dst, o, [0.0, 0.0, 0.0, 1.0]); - for k in [0.1f32, 0.3, 0.5, 0.7, 0.9, 1.0] { + for k in [0.1f32, 0.5, 0.9, 1.0] { let want = lightness(src, o, [0.0, 0.0, 0.0, k]); if want <= dst_black { assert_eq!(bp.map_k(k), 1.0, "darker than the destination's black clamps to K = 1"); diff --git a/crates/exr/src/seek_tests.rs b/crates/exr/src/seek_tests.rs index 0104922351..11892d10e3 100644 --- a/crates/exr/src/seek_tests.rs +++ b/crates/exr/src/seek_tests.rs @@ -1413,11 +1413,11 @@ fn groups_must_be_slots_of_one_part_each_in_one_group() { #[test] fn the_estimate_covers_what_the_read_does() { // A flat colour in ZIP16 (decodes to far more than it reads), lines of a ramp, and tiles. - let (w, h) = (1024usize, 600usize); + let (w, h) = (256usize, 160usize); let list = vec![AnyChannel::new("R", FlatSamples::F32(vec![0.25; w * h])), AnyChannel::new("G", FlatSamples::F32(vec![0.5; w * h]))]; let encoding = Encoding { compression: Compression::ZIP16, blocks: Blocks::ScanLines, line_order: LineOrder::Increasing }; let flat = file(vec![Layer::new((w, h), LayerAttributes::default(), encoding, AnyChannels::sort(list.into()))], (w, h)); - let ramp = file(vec![layer(None, (0, 0), (1024, 600), &["R", "G"], false, Compression::Uncompressed)], (1024, 600)); + let ramp = file(vec![layer(None, (0, 0), (256, 160), &["R", "G"], false, Compression::Uncompressed)], (256, 160)); let tiled = file(vec![layer(None, (0, 0), (300, 200), &["R", "G", "B"], true, Compression::PIZ)], (300, 200)); for bytes in [&flat, &ramp, &tiled] { let index = indexed(bytes); diff --git a/crates/prepress/Cargo.toml b/crates/prepress/Cargo.toml index 1ef0384366..8fd6c92f2d 100644 --- a/crates/prepress/Cargo.toml +++ b/crates/prepress/Cargo.toml @@ -20,6 +20,7 @@ linesweeper = { version = "0.5", optional = true } ttf-parser = { version = "=0.25.1", optional = true } [dev-dependencies] +craft-testkit = { workspace = true } craft-plate-test = { workspace = true } ttf-parser = "=0.25.1" diff --git a/crates/prepress/src/plates.rs b/crates/prepress/src/plates.rs index 8344e78b0f..0a5d1ed8f5 100644 --- a/crates/prepress/src/plates.rs +++ b/crates/prepress/src/plates.rs @@ -532,7 +532,8 @@ endstream endobj fn bands_reach_resolutions_past_the_plate_cap_and_can_stop() { let pdf = disc_and_spot(); // 40 pt at 3700 dpi is 2055 pixels a side: 4.2 MP, past `MAX_PLATE_PIXELS`. - assert!(plates(&pdf, 0, 3700.0, &Options::default()).unwrap().dpi < 3700.0); + // (The whole-page entry point reduces by `plate_scale`; the bands below are not reduced.) + assert!(plate_scale(40.0, 40.0, 3700.0 / 72.0) < 3700.0 / 72.0); let mut bands = Vec::new(); plates_in_bands(&pdf, 0, 3700.0, &Options::default(), |band| { let p = &band.plates; diff --git a/crates/pst/Cargo.toml b/crates/pst/Cargo.toml index 60ead7d8fa..9dff7fa17e 100644 --- a/crates/pst/Cargo.toml +++ b/crates/pst/Cargo.toml @@ -20,5 +20,6 @@ workspace = true [dependencies] [dev-dependencies] +craft-testkit = { workspace = true } craft-pst = { path = ".", features = ["test-support"] } proptest = { workspace = true } diff --git a/crates/pst/src/tests/salvage.rs b/crates/pst/src/tests/salvage.rs index 7d5d391ea9..b7f341b7ae 100644 --- a/crates/pst/src/tests/salvage.rs +++ b/crates/pst/src/tests/salvage.rs @@ -248,7 +248,9 @@ fn a_reader_that_fails_or_runs_out_ends_the_call() { } }; let mut failed = 0; - for (fail, short) in (1..=reads).flat_map(|n| [(n, false), (n, true)]) { + // The gate fails every divisor-th read; nightly fails each one. + let step = craft_testkit::hostile::divisor(); + for (fail, short) in (1..=reads).step_by(step).flat_map(|n| [(n, false), (n, true)]) { let Ok(mut pst) = Pst::open(Flaky { inner: Cursor::new(&bytes[..]), reads: 0, fail, short }) else { continue }; let got = answers(&mut pst, &folders, &items); failed += got.iter().filter(|r| r.is_err()).count(); @@ -257,7 +259,7 @@ fn a_reader_that_fails_or_runs_out_ends_the_call() { } assert!(failed > 0); let mut capped = 0; - for floor in (0..bytes.len() as u64 * 4).step_by(256) { + for floor in (0..bytes.len() as u64 * 4).step_by(256 * step) { let limits = Limits { read_multiple: 0, read_floor: floor, ..Default::default() }; let Ok(mut pst) = Pst::open_with(Cursor::new(&bytes[..]), limits) else { continue }; let got = answers(&mut pst, &folders, &items);