From 06a4182f2843818bf52029fbbe00b02d5f8c7aa0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:30:01 +0000 Subject: [PATCH 01/27] ci: opt-level 1 for pdf, pkcs7, odf and cms test builds --- .config/cargo-ci.toml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.config/cargo-ci.toml b/.config/cargo-ci.toml index 30eba421c..956491323 100644 --- a/.config/cargo-ci.toml +++ b/.config/cargo-ci.toml @@ -1,6 +1,8 @@ # The Workspace gate's additions to .config/cargo-dev.toml (scripts/ci-workspace-tests.sh passes both). The gate runs # every test of these crates, and their tests spend nearly all their time in sample and pixel loops, which run several -# times faster at opt-level 1; locally they stay at 0, so an edit to them rebuilds fast. +# times faster at opt-level 1; locally they stay at 0, so an edit to them rebuilds fast. craft-pdf (R6 hash and AES-CBC +# loops), craft-pkcs7 and craft-odf (PBKDF2 rounds, monomorphised in the crate) and craft-cms (CLUT builds) run their +# own hot loops in tests, so they take part too. [profile.dev.package.craft-audio-dsp] opt-level = 1 @@ -15,3 +17,15 @@ opt-level = 1 [profile.dev.package.craft-imaging] opt-level = 1 + +[profile.dev.package.craft-pdf] +opt-level = 1 + +[profile.dev.package.craft-pkcs7] +opt-level = 1 + +[profile.dev.package.craft-odf] +opt-level = 1 + +[profile.dev.package.craft-cms] +opt-level = 1 From 73ea1f1e345872252bcdeaaf33a9e6adba16d414 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:30:45 +0000 Subject: [PATCH 02/27] tests: ps number sample walks the divisor's fraction --- Cargo.lock | 1 + crates/proto/src/imap/limits_tests.rs | 6 +++--- crates/ps/Cargo.toml | 3 +++ crates/ps/src/write.rs | 11 ++++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 664f291e3..3dd282511 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3841,6 +3841,7 @@ name = "craft-ps" version = "0.1.0" dependencies = [ "craft-eps", + "craft-testkit", "flate2", "kurbo", "miniz_oxide 0.8.9", diff --git a/crates/proto/src/imap/limits_tests.rs b/crates/proto/src/imap/limits_tests.rs index 01e91e7de..f0afbd5dc 100644 --- a/crates/proto/src/imap/limits_tests.rs +++ b/crates/proto/src/imap/limits_tests.rs @@ -29,13 +29,13 @@ fn a_flood_of_long_lines_ends_the_command() { // 600 lines of 60 KB are more than the 32 MB one command may bring. The gate sends lines that // are not parsed (the cap counts the text read); nightly sends the lines of a real listing. let full = craft_testkit::hostile::divisor() == 1; - let server = - flood(600, |n| if full { format!("* {n} FETCH (UID {} FLAGS ({pad}))\r\n", n + 1) } else { format!("* OK {pad}\r\n") }) + "A0001 OK done\r\n"; + let ok_lines = format!("* OK {pad}\r\n").repeat(600); + let server = if full { flood(600, |n| format!("* {n} FETCH (UID {} FLAGS ({pad}))\r\n", n + 1)) } else { ok_lines.clone() } + "A0001 OK done\r\n"; let mut s = Script::new(server); let err = opened(&mut s, 1000, 2000).uid_fetch_flags("1:*").unwrap_err(); assert!(matches!(err, ProtoError::Protocol(ref m) if m.to_string().contains("too much")), "{err:?}"); // The same in a list. - let server = flood(600, |n| if full { format!("* LIST () \"/\" \"{n}{pad}\"\r\n") } else { format!("* OK {pad}\r\n") }) + "A0001 OK done\r\n"; + let server = if full { flood(600, |n| format!("* LIST () \"/\" \"{n}{pad}\"\r\n")) } else { ok_lines } + "A0001 OK done\r\n"; let mut s = Script::new(server); assert!(matches!(opened(&mut s, 0, 0).list(), Err(ProtoError::Protocol(_)))); } diff --git a/crates/ps/Cargo.toml b/crates/ps/Cargo.toml index 2f0316e59..cee8ce5c1 100644 --- a/crates/ps/Cargo.toml +++ b/crates/ps/Cargo.toml @@ -24,6 +24,9 @@ skrifa = { workspace = true, optional = true } kurbo = { workspace = true, optional = true } flate2 = { version = "1.1.10", default-features = false, features = ["rust_backend"], optional = true } +[dev-dependencies] +craft-testkit = { workspace = true } + [[example]] name = "eps2pdf" required-features = ["read"] diff --git a/crates/ps/src/write.rs b/crates/ps/src/write.rs index 4405a0393..b14b3169c 100644 --- a/crates/ps/src/write.rs +++ b/crates/ps/src/write.rs @@ -602,9 +602,13 @@ mod tests { #[test] fn numbers_match_base_formatter() { - let mut integer_path = 0usize; + // The gate walks every `divisor()`-th value (offset by `places` so the places differ); nightly walks all. + let step = craft_testkit::hostile::divisor(); + let (mut integer_path, mut visited) = (0usize, 0usize); + let samples = number_samples(); for places in 0..=12 { - for v in number_samples() { + for v in samples.iter().copied().skip(places % step).step_by(step) { + visited += 1; let mut expected = String::from("x "); base_push_num_places(&mut expected, v, places); let mut got = String::from("x "); @@ -616,7 +620,8 @@ mod tests { } } // The comparison covers the integer path, not only the fallback. - assert!(integer_path > 200_000, "{integer_path} values took the integer path"); + eprintln!("DIAG numbers_match_base_formatter: visited {visited}, integer path {integer_path}"); + assert!(integer_path * 20 > visited, "{integer_path} of {visited} values took the integer path"); } #[test] From f83ff2d49f3cdd814f5861c64890ed9ddff60bd0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:30:54 +0000 Subject: [PATCH 03/27] tests: pages picture bound scrolls past the budget by half --- crates/pages/tests/it/views.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index fb02cdc9c..3ddb1e268 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -512,7 +512,8 @@ fn a_page_gap_change_keeps_the_scroll_offset() { #[trial] fn the_pictures_a_view_holds_stay_bounded_as_it_scrolls_through_many_pages() { let budget = TextureStoreOptions::pages().budget.max_entries; - let count = 2 * budget; + // Past the budget by half again: the store has to evict for the bound to be tested. + let count = budget + budget / 2; let state = Rc::new(RefCell::new(state_with(|s| { s.continuous = true; s.fit = Fit::None; @@ -539,6 +540,7 @@ fn the_pictures_a_view_holds_stay_bounded_as_it_scrolls_through_many_pages() { assert!(drawn > 0, "the view drew pages"); // The pages of the last two passes, in view and one row either side, are never evicted. let bound = budget + 2 * (drawn + 2); + eprintln!("DIAG pictures_bounded: budget {budget}, count {count}, held {held}, drawn {drawn}"); assert!(held > 0 && held <= bound, "{held} pictures held over {count} pages scrolled through, at most {bound} expected"); } From ef8cd1c27b4c3eac40290571dfdcf83612e8e137 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:31:09 +0000 Subject: [PATCH 04/27] tests: midi event flood body built once --- crates/midi/tests/it/lenient.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/midi/tests/it/lenient.rs b/crates/midi/tests/it/lenient.rs index e32811545..67b88a49c 100644 --- a/crates/midi/tests/it/lenient.rs +++ b/crates/midi/tests/it/lenient.rs @@ -117,12 +117,20 @@ fn names_instruments_and_lyrics() { assert_eq!((read.smf.tracks.len(), read.instruments), (2, vec!["Sax".to_string(), String::new()])); } +/// Three bytes a note-on under running status: more events than are read. Built once for the tests that need it. +fn event_flood_body() -> &'static [u8] { + static BODY: std::sync::OnceLock> = std::sync::OnceLock::new(); + BODY.get_or_init(|| { + let mut body = vec![0x00, 0x90, 60, 100]; + body.extend((0..MAX_EVENTS + 1).flat_map(|i| [0x00, (i % 128) as u8, 1])); + body + }) +} + #[test] fn a_file_of_any_size_is_read_into_a_bounded_number_of_events_and_warnings() { - // Three bytes a note-on under running status: more events than are read. - let mut body = vec![0x00, 0x90, 60, 100]; - body.extend((0..MAX_EVENTS + 1000).flat_map(|i| [0x00, (i % 128) as u8, 1])); - let LenientRead { smf, warnings, over_limit, .. } = read_smf_lenient(&file(1, 96, &[&body])).unwrap(); + let body = event_flood_body(); + let LenientRead { smf, warnings, over_limit, .. } = read_smf_lenient(&file(1, 96, &[body])).unwrap(); assert_eq!(smf.tracks[0].sequence.notes.len(), MAX_EVENTS); assert!(warnings.iter().any(|w| w.contains("more events")), "{warnings:?}"); assert!(over_limit, "the event limit left events out"); @@ -140,10 +148,9 @@ fn a_file_of_any_size_is_read_into_a_bounded_number_of_events_and_warnings() { fn a_limit_reached_after_the_warnings_are_full_is_still_reported() { // MAX_WARNINGS damaged tracks fill the warnings; the track after them holds more events than are // read, so its warning is dropped, and over_limit is what says the file was cut. - let mut body = vec![0x00, 0x90, 60, 100]; - body.extend((0..MAX_EVENTS + 1000).flat_map(|i| [0x00, (i % 128) as u8, 1])); + let body = event_flood_body(); let mut tracks = vec![&[0x00, 60][..]; MAX_WARNINGS]; - tracks.push(&body); + tracks.push(body); let LenientRead { warnings, over_limit, .. } = read_smf_lenient(&file(1, 96, &tracks)).unwrap(); assert_eq!(warnings.len(), MAX_WARNINGS); assert!(!warnings.iter().any(|w| w.contains("more events")), "the test needs the limit's warning dropped: {warnings:?}"); From d105734cf81c1bd0dd0ce9b00aacf41559a9199d Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:31:24 +0000 Subject: [PATCH 05/27] material-graph: evaluate_all skips nodes already run as inputs, removing the double evaluation and thumbnail of every node --- crates/material-graph/src/graph.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/material-graph/src/graph.rs b/crates/material-graph/src/graph.rs index f4fc04eb3..df24f6cb2 100644 --- a/crates/material-graph/src/graph.rs +++ b/crates/material-graph/src/graph.rs @@ -2014,6 +2014,11 @@ impl Graph { let mut seen = HashSet::new(); order.retain(|i| seen.insert(*i)); for id in order { + // already run (and thumbnailed) as an input of an earlier node of this call; its result was freed after its + // readers finished, so running it again would only compute and thumbnail the same node a second time + if cache.thumbs.as_ref().is_some_and(|t| t.contains_key(&id)) { + continue; + } match eval_node(self, id, &ctx, &[], &mut cache).and_then(|value| value.into_host(id, ec)) { Ok(t) => { if Some(id) == first || keep.contains(&id) { From d1b4304952896c360a18ec630fed729b0d8d3dba Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:31:29 +0000 Subject: [PATCH 06/27] tests: xcf, mime and crw sweeps run the divisor's fraction --- Cargo.lock | 3 +++ crates/crw/Cargo.toml | 1 + crates/crw/tests/robust.rs | 6 ++++-- crates/mime/Cargo.toml | 1 + crates/mime/tests/hostile.rs | 3 ++- crates/xcf/Cargo.toml | 3 +++ crates/xcf/src/tests.rs | 3 ++- 7 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dd282511..33ed1761f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2301,6 +2301,7 @@ dependencies = [ name = "craft-crw" version = "0.1.0" dependencies = [ + "craft-testkit", "serde", "serde_json", "sha2 0.10.9", @@ -3404,6 +3405,7 @@ dependencies = [ "chardetng", "chrono", "craft-codepage", + "craft-testkit", "encoding_rs", "proptest", ] @@ -4772,6 +4774,7 @@ dependencies = [ name = "craft-xcf" version = "0.1.0" dependencies = [ + "craft-testkit", "flate2", "thiserror 2.0.21", ] diff --git a/crates/crw/Cargo.toml b/crates/crw/Cargo.toml index e44839e70..9c58c6834 100644 --- a/crates/crw/Cargo.toml +++ b/crates/crw/Cargo.toml @@ -15,6 +15,7 @@ workspace = true thiserror = { workspace = true } [dev-dependencies] +craft-testkit = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } # Pinned digests of the decoded CC0 sample files (tests/samples.rs); not a product dependency. diff --git a/crates/crw/tests/robust.rs b/crates/crw/tests/robust.rs index b12df3a8d..8368ceb3d 100644 --- a/crates/crw/tests/robust.rs +++ b/crates/crw/tests/robust.rs @@ -61,11 +61,13 @@ fn crw() -> Vec { #[test] fn every_truncation_and_single_byte_mutation_survives() { let good = crw(); - for n in 0..good.len() { + // The gate runs every divisor-th position; nightly runs all. + let step = craft_testkit::hostile::divisor(); + for n in (0..good.len()).step_by(step) { let _ = header(&good[..n], &Limits::default()); let _ = decode(&good[..n], &Limits::default()); } - for i in 0..good.len() { + for i in (0..good.len()).step_by(step) { let mut bad = good.clone(); bad[i] ^= 0xa5; let _ = decode(&bad, &Limits::default()); diff --git a/crates/mime/Cargo.toml b/crates/mime/Cargo.toml index 524bca8fb..60702e109 100644 --- a/crates/mime/Cargo.toml +++ b/crates/mime/Cargo.toml @@ -24,4 +24,5 @@ chardetng = { version = "1", optional = true } detect = ["dep:chardetng"] [dev-dependencies] +craft-testkit = { workspace = true } proptest = { workspace = true } diff --git a/crates/mime/tests/hostile.rs b/crates/mime/tests/hostile.rs index 36c8327db..5b677eaf6 100644 --- a/crates/mime/tests/hostile.rs +++ b/crates/mime/tests/hostile.rs @@ -145,7 +145,8 @@ fn mutations_read() { }; const INTERESTING: &[u8] = b"\0\r\n\t \"\\()<>;:=?-_%*'/@,.\x7f\x80\xff"; for original in [sample(), archive()] { - for round in 0..4000u32 { + // The gate runs a divisor's fraction of the rounds; nightly runs all. + for round in 0..4000 / craft_testkit::hostile::divisor() as u32 { let mut bytes = original.clone(); for _ in 0..=(round % 4) { let at = (next() as usize) % bytes.len().max(1); diff --git a/crates/xcf/Cargo.toml b/crates/xcf/Cargo.toml index ffaff8abb..fbdd12153 100644 --- a/crates/xcf/Cargo.toml +++ b/crates/xcf/Cargo.toml @@ -13,3 +13,6 @@ workspace = true [dependencies] flate2 = { version = "1", default-features = false, features = ["rust_backend"] } thiserror = { workspace = true } + +[dev-dependencies] +craft-testkit = { workspace = true } diff --git a/crates/xcf/src/tests.rs b/crates/xcf/src/tests.rs index e2f4701b5..1d47413d6 100644 --- a/crates/xcf/src/tests.rs +++ b/crates/xcf/src/tests.rs @@ -405,7 +405,8 @@ fn corrupted_files_never_panic() { let bytes = img.write(); assert!(read_all(&bytes).is_ok()); let mut state = 0x9e37_79b9_u32; - for _ in 0..2000 { + // The gate runs a divisor's fraction of the rounds; nightly runs all. + for _ in 0..2000 / craft_testkit::hostile::divisor() { let mut b = bytes.clone(); for _ in 0..3 { state ^= state << 13; From 7a41f7902639b150a2fa8186c243b522604a8bba Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:31:46 +0000 Subject: [PATCH 07/27] tests: heif damage sweep runs the divisor's fraction --- Cargo.lock | 1 + crates/heif/Cargo.toml | 1 + crates/heif/src/tests_synthetic.rs | 6 ++++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 33ed1761f..e89a92493 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2946,6 +2946,7 @@ dependencies = [ name = "craft-heif" version = "0.1.0" dependencies = [ + "craft-testkit", "heic-rs", "proptest", "rayon", diff --git a/crates/heif/Cargo.toml b/crates/heif/Cargo.toml index b79b8f989..8b505eaf2 100644 --- a/crates/heif/Cargo.toml +++ b/crates/heif/Cargo.toml @@ -20,6 +20,7 @@ heic-rs = { version = "=0.1.4", default-features = false, features = ["std", "pa rayon = { workspace = true, optional = true } [dev-dependencies] +craft-testkit = { workspace = true } proptest = { workspace = true } [features] diff --git a/crates/heif/src/tests_synthetic.rs b/crates/heif/src/tests_synthetic.rs index dbd4ca70b..8d4f9fd96 100644 --- a/crates/heif/src/tests_synthetic.rs +++ b/crates/heif/src/tests_synthetic.rs @@ -186,7 +186,9 @@ fn grid_tiles_are_held_to_the_pixel_budget_together() { fn truncated_and_corrupted_files_are_errors_not_panics() { let bytes = build(&Spec { props: vec![FULL_601, Prop::Irot(1)], thumbnail: Some(&grey), ..Spec::new(64, 64, &grey) }); let full = decode(&bytes, &Options::default()).unwrap(); - for cut in (0..bytes.len()).step_by(7) { + // The gate runs a divisor's fraction of the cuts and flips; nightly runs all. + let divisor = craft_testkit::hostile::divisor(); + for cut in (0..bytes.len()).step_by(7 * divisor) { let b = &bytes[..cut]; // Cut inside the photo: an error. Cut in the trailing thumbnail: the whole photo. if let (Ok(_), Ok(d)) = (probe(b), decode(b, &Options::default())) { @@ -197,7 +199,7 @@ fn truncated_and_corrupted_files_are_errors_not_panics() { } // Flip bits all over the file: any outcome but a panic. let mut state = 0x2545_f491_u32; - for _ in 0..400 { + for _ in 0..400 / divisor { let mut b = bytes.clone(); for _ in 0..3 { state ^= state << 13; From a403cc18db351424c3d78e55c99a8dc2696737e9 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:31:53 +0000 Subject: [PATCH 08/27] material-graph tests: the grey transform and blend sweeps run a sample at the gate and every case nightly --- crates/material-graph/Cargo.toml | 3 ++ crates/material-graph/src/graph.rs | 44 ++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/crates/material-graph/Cargo.toml b/crates/material-graph/Cargo.toml index 9bae5c7f6..1cc2fed77 100644 --- a/crates/material-graph/Cargo.toml +++ b/crates/material-graph/Cargo.toml @@ -15,3 +15,6 @@ workspace = true libm = "0.2.16" # Data-parallel loops (MIT OR Apache-2.0). rayon = { workspace = true } + +[dev-dependencies] +craft-testkit = { workspace = true } diff --git a/crates/material-graph/src/graph.rs b/crates/material-graph/src/graph.rs index df24f6cb2..8fc6067f7 100644 --- a/crates/material-graph/src/graph.rs +++ b/crates/material-graph/src/graph.rs @@ -5464,6 +5464,38 @@ mod grey_tests { pub(super) static GREY_RUNS: std::cell::Cell = const { std::cell::Cell::new(0) }; } + /// A sample of a sweep of `total` cases: all of them when `craft_testkit::hostile::divisor()` is 1 (nightly), at the + /// gate every `per_div * divisor - 1`-th (an odd stride, so every axis of a nested loop varies). + struct Sweep { + stride: usize, + total: usize, + seen: usize, + visited: usize, + } + + impl Sweep { + fn new(total: usize, per_div: usize) -> Sweep { + #[cfg(not(target_arch = "wasm32"))] + let div = craft_testkit::hostile::divisor(); + #[cfg(target_arch = "wasm32")] + let div = 1; + Sweep { stride: if div == 1 { 1 } else { per_div * div - 1 }, total, seen: 0, visited: 0 } + } + + /// Whether the next case of the sweep is in the sample. + fn take(&mut self) -> bool { + let take = self.seen % self.stride == 0; + self.seen += 1; + self.visited += usize::from(take); + take + } + + /// What `full` grey runs over all the cases comes to over the cases visited. + fn share(&self, full: usize) -> usize { + full * self.visited / self.total + } + } + fn bits(outs: &BTreeMap) -> Vec<(String, Vec)> { outs.iter().map(|(k, t)| (k.clone(), t.px.iter().flat_map(|p| p.map(f32::to_bits)).collect())).collect() } @@ -5537,6 +5569,7 @@ mod grey_tests { "m00=-1 m01=0 m10=0 m11=1", ]; let bgs = ["", "bg_r=0.5 bg_g=0.5 bg_b=0.5 bg_a=1", "bg_r=0.2 bg_g=0.3 bg_b=0.2 bg_a=1", "bg_a=0.5"]; + let mut sweep = Sweep::new(2 * mats.len() * bgs.len() * 3 * 4 * 4, 16); let n = greys(|| { for compiled in [false, true] { for m in mats { @@ -5549,6 +5582,9 @@ mod grey_tests { (" osize_log2_x=4 osize_log2_y=5", " ofmt=5"), (" osize_log2_x=6 osize_log2_y=6", " ofmt=6 offset_x=0.13 offset_y=-0.3"), ] { + if !sweep.take() { + continue; + } let body = format!("node 10 transform_matrix in=@2 {m} {bg} {tiles} {filt}{osz}{fmt}\noutput out 10\n"); same(&body, 32, compiled); } @@ -5558,7 +5594,7 @@ mod grey_tests { } } }); - assert!(n > 300, "{n} grey runs"); + assert!(n > sweep.share(300), "{n} grey runs in {} of {} cases", sweep.visited, sweep.total); } #[test] @@ -5668,6 +5704,7 @@ mod grey_tests { #[test] fn blend_grey_is_rgba() { + let mut sweep = Sweep::new(2 * 26 * 5 * 10, 16); let n = greys(|| { for compiled in [false, true] { for mode in (0..=21).chain(32..=35) { @@ -5684,6 +5721,9 @@ mod grey_tests { ("0.6", " ofmt=1 tile_x=0.25"), ("0.6", " ofmt=7"), ] { + if !sweep.take() { + continue; + } let body = format!("node 10 blend fg=@1 bg=@2 mode={mode} alpha_mode={am} opacity={op}{extra}\noutput out 10\n"); same(&body, 24, compiled); } @@ -5691,7 +5731,7 @@ mod grey_tests { } } }); - assert!(n > 300, "{n} grey runs"); + assert!(n > sweep.share(300), "{n} grey runs in {} of {} cases", sweep.visited, sweep.total); } #[test] From 7f544f8c9b353e17c364a63a44103597e18d0505 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:32:03 +0000 Subject: [PATCH 09/27] tests: xmp attribute scan ratio at smaller sizes --- crates/metadata/src/xmp_merge.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/metadata/src/xmp_merge.rs b/crates/metadata/src/xmp_merge.rs index 33714269a..76759f680 100644 --- a/crates/metadata/src/xmp_merge.rs +++ b/crates/metadata/src/xmp_merge.rs @@ -512,10 +512,10 @@ mod tests { assert_eq!(found.descs[0].attrs.len(), n + 2, "every attribute is read"); took }; - let (n, small_packet, large_packet) = (50_000, packet(50_000), packet(200_000)); + let (n, small_packet, large_packet) = (20_000, packet(20_000), packet(80_000)); // interleaved, so a burst of load slows both sizes rather than one; the fastest run of each counts let (mut small, mut large) = (std::time::Duration::MAX, std::time::Duration::MAX); - for _ in 0..5 { + for _ in 0..3 { small = small.min(run(&small_packet, n)); large = large.min(run(&large_packet, 4 * n)); } From 750fdbc36127900f1b024ed778e90e45e260229f Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:32:30 +0000 Subject: [PATCH 10/27] material-graph tests: sample the per-kind sweeps at the gate, shorter chains on smaller stacks, a smaller cancelled run, one pass fewer in kind_versions --- crates/material-graph/tests/it/deep.rs | 20 ++++++++---- crates/material-graph/tests/it/determinism.rs | 9 +++--- .../material-graph/tests/it/kind_versions.rs | 32 +++++++++++++------ crates/material-graph/tests/it/main.rs | 18 +++++++++++ crates/material-graph/tests/it/nodes.rs | 10 +++--- crates/material-graph/tests/it/seam.rs | 6 ++-- 6 files changed, 67 insertions(+), 28 deletions(-) diff --git a/crates/material-graph/tests/it/deep.rs b/crates/material-graph/tests/it/deep.rs index 2cb775111..1fe1e23f1 100644 --- a/crates/material-graph/tests/it/deep.rs +++ b/crates/material-graph/tests/it/deep.rs @@ -8,6 +8,12 @@ use std::fmt::Write; /// The stack of a thread spawned without asking for one (Rust's default), and of rayon's workers. const NORMAL_STACK: usize = 2 << 20; +/// Stacks too small for a walk that recurses once per node: a frame takes at least tens of bytes (an unoptimised one about +/// a kilobyte), so the chains below overflow them if the evaluator recurses, and the chain length needs no more work than +/// that. +const SMALL_STACK: usize = 128 << 10; +const MEDIUM_STACK: usize = 512 << 10; + /// The stack a function as deep as allowed is run with: the normal one in an optimised build (measured: 2040 nodes in a /// row take under 1 MB); an unoptimised build's frames are about fifteen times larger. const FUNCTION_STACK: usize = if cfg!(debug_assertions) { 32 << 20 } else { NORMAL_STACK }; @@ -51,22 +57,22 @@ fn nested(levels: u32) -> String { } #[test] -fn a_chain_of_a_hundred_thousand_nodes_evaluates_on_a_normal_stack() { - let g = Graph::parse(&image_chain(100_000)).expect("parses"); +fn a_long_chain_evaluates_on_a_small_stack() { + let g = Graph::parse(&image_chain(10_000)).expect("parses"); let shallow = Graph::parse(&image_chain(2)).expect("parses"); let (deep, two) = - on_stack(NORMAL_STACK, move || (g.evaluate(None).map_err(|e| e.to_string()), shallow.evaluate(None).map_err(|e| e.to_string()))); + on_stack(MEDIUM_STACK, move || (g.evaluate(None).map_err(|e| e.to_string()), shallow.evaluate(None).map_err(|e| e.to_string()))); let (deep, two) = (deep.expect("evaluates"), two.expect("evaluates")); // an even number of inverts is the gradient again, as two are assert_eq!(deep["o"].px, two["o"].px); } #[test] -fn every_node_of_a_long_chain_gets_a_thumbnail_on_a_normal_stack() { - let g = Graph::parse(&image_chain(20_000)).expect("parses"); - let all = on_stack(NORMAL_STACK, move || g.evaluate_all(16, &[20_000])); +fn every_node_of_a_long_chain_gets_a_thumbnail_on_a_small_stack() { + let g = Graph::parse(&image_chain(300)).expect("parses"); + let all = on_stack(SMALL_STACK, move || g.evaluate_all(16, &[300])); assert!(all.errors.is_empty(), "{:?}", all.errors.iter().next()); - assert_eq!(all.thumbs.len(), 20_001); + assert_eq!(all.thumbs.len(), 301); } #[test] diff --git a/crates/material-graph/tests/it/determinism.rs b/crates/material-graph/tests/it/determinism.rs index 404359064..563af3833 100644 --- a/crates/material-graph/tests/it/determinism.rs +++ b/crates/material-graph/tests/it/determinism.rs @@ -38,13 +38,14 @@ fn in_pool(threads: usize, f: impl FnOnce() -> R + Send) -> R { #[test] fn one_thread_and_eight_render_the_same_bytes() { - let graphs = demo_graphs(); - assert!(graphs.len() > 100, "only {} demo graphs", graphs.len()); + let all = demo_graphs(); + assert!(all.len() > 100, "only {} demo graphs", all.len()); + let graphs = crate::sampled(all, 0); let one = in_pool(1, || graphs.iter().map(|(_, g)| render(g)).collect::>()); let eight = in_pool(8, || graphs.iter().map(|(_, g)| render(g)).collect::>()); let differ: Vec<&str> = graphs.iter().zip(one.iter().zip(&eight)).filter(|(_, (a, b))| a != b).map(|((k, _), _)| *k).collect(); assert!(differ.is_empty(), "these kinds render differently on 1 and 8 threads: {differ:?}"); - assert!(one.iter().filter(|r| r.is_ok()).count() > 100, "most demo graphs must render"); + assert!(one.iter().filter(|r| r.is_ok()).count() * 10 > graphs.len() * 8, "most demo graphs must render"); } #[test] @@ -52,7 +53,7 @@ fn cached_and_uncached_evaluations_give_the_same_bytes() { let cache = Arc::new(NodeCache::new(256)); let mut differ = Vec::new(); let mut not_reused = Vec::new(); - for (kind, g) in demo_graphs() { + for (kind, g) in crate::sampled(demo_graphs(), 0) { let keep: Vec = g.nodes.keys().copied().collect(); let fresh = g.evaluate_all(SIDE, &keep); let first = g.evaluate_all_cached(&EvalContext::default(), SIDE, &keep, &cache, None, &mut |_| {}); diff --git a/crates/material-graph/tests/it/kind_versions.rs b/crates/material-graph/tests/it/kind_versions.rs index 3c2391517..417a24b14 100644 --- a/crates/material-graph/tests/it/kind_versions.rs +++ b/crates/material-graph/tests/it/kind_versions.rs @@ -53,11 +53,15 @@ fn a_fix_in_one_operation_leaves_most_kinds_alone() { files.iter().for_each(|f| println!(" {}", f.name)); } assert!(files.len() > 20, "{} of {} files reachable", files.len(), all.len()); + let started = std::time::Instant::now(); let tree = SourceTree::scan(&files, DISPATCHERS); + eprintln!("DIAG kind_versions first scan {:?}", started.elapsed()); let kinds: Vec = tree.kinds().map(str::to_string).collect(); assert!(kinds.len() > 100, "the kinds were found: {}", kinds.len()); let versions = |t: &SourceTree| kinds.iter().map(|k| t.kind_version(k, SHARED).unwrap()).collect::>(); + let started = std::time::Instant::now(); let before = versions(&tree); + eprintln!("DIAG kind_versions first versions {:?}", started.elapsed()); let distinct: std::collections::BTreeSet<_> = before.iter().collect(); if std::env::var_os("TC_VERSIONS_DUMP").is_some() { for k in &kinds { @@ -72,24 +76,34 @@ fn a_fix_in_one_operation_leaves_most_kinds_alone() { } assert!(distinct.len() > kinds.len() / 2, "{} distinct versions of {} kinds", distinct.len(), kinds.len()); - let changed_by = |file: &str, from: &str, to: &str| { + let changed_by_all = |edits: &[(&str, &str, &str)]| { let edited: Vec = files .iter() .map(|f| { - let text = if f.name == file { f.text.replacen(from, to, 1) } else { f.text.clone() }; - assert!(f.name != file || text != f.text, "{from} is in {file}"); + let mut text = f.text.clone(); + for (file, from, to) in edits.iter().filter(|e| e.0 == f.name) { + let next = text.replacen(from, to, 1); + assert!(next != text, "{from} is in {file}"); + text = next; + } SourceFile { text, ..f.clone() } }) .collect(); - let after = versions(&SourceTree::scan(&edited, DISPATCHERS)); + let started = std::time::Instant::now(); + let scanned = SourceTree::scan(&edited, DISPATCHERS); + let scan = started.elapsed(); + let after = versions(&scanned); + eprintln!("DIAG kind_versions edit of {:?}: scan {scan:?}, versions {:?}", edits.iter().map(|e| e.0).collect::>(), started.elapsed() - scan); kinds.iter().zip(before.iter().zip(&after)).filter(|(_, (a, b))| a != b).map(|(k, _)| k.clone()).collect::>() }; + let changed_by = |file: &str, from: &str, to: &str| changed_by_all(&[(file, from, to)]); - let added = changed_by("src/compiled_ops.rs", "pub fn compute(kind: &str", "fn __added_helper() -> u8 { 1 }\npub fn compute(kind: &str"); - assert_eq!(added, Vec::::new(), "an added function nothing uses changes nothing"); - - let comment = changed_by("src/atomic.rs", "\"levels_mid\" => {", "\"levels_mid\" => { // a comment\n"); - assert_eq!(comment, Vec::::new(), "a comment changes nothing"); + // an added function nothing uses, and a comment: both change nothing (edits in two files, one pass) + let unchanged = changed_by_all(&[ + ("src/compiled_ops.rs", "pub fn compute(kind: &str", "fn __added_helper() -> u8 { 1 }\npub fn compute(kind: &str"), + ("src/atomic.rs", "\"levels_mid\" => {", "\"levels_mid\" => { // a comment\n"), + ]); + assert_eq!(unchanged, Vec::::new(), "an unused added function and a comment change nothing"); // a fix inside one node's arm let arm = changed_by("src/atomic.rs", "\"levels_mid\" => {", "\"levels_mid\" => { let _fixed = 1;"); diff --git a/crates/material-graph/tests/it/main.rs b/crates/material-graph/tests/it/main.rs index 3b2886dcf..e82a66b45 100644 --- a/crates/material-graph/tests/it/main.rs +++ b/crates/material-graph/tests/it/main.rs @@ -14,3 +14,21 @@ mod kind_versions; mod nodes; mod seam; mod vector; + +/// The gate's share of a sweep over `items`: every `craft_testkit::hostile::divisor()`-th one from `offset` (all of them +/// nightly, where the divisor is 1), so tests sweeping the same list with different offsets together reach more of it. +fn sampled(items: impl IntoIterator, offset: usize) -> Vec { + let div = divisor(); + items.into_iter().enumerate().filter(|(i, _)| (i + offset) % div == 0).map(|(_, t)| t).collect() +} + +fn divisor() -> usize { + #[cfg(not(target_arch = "wasm32"))] + { + craft_testkit::hostile::divisor() + } + #[cfg(target_arch = "wasm32")] + { + 1 + } +} diff --git a/crates/material-graph/tests/it/nodes.rs b/crates/material-graph/tests/it/nodes.rs index a92e39566..0b769d293 100644 --- a/crates/material-graph/tests/it/nodes.rs +++ b/crates/material-graph/tests/it/nodes.rs @@ -309,7 +309,7 @@ fn node_parameters_survive_extreme_values() { use craft_material_graph::graph::{SPECS, demo_graph_for}; let mut problems = Vec::new(); let mut ran = 0usize; - for sp in SPECS { + for sp in crate::sampled(SPECS, 0) { let Some(text) = demo_graph_for(sp.kind) else { continue }; let doc = sp.doc.split_once(':').map(|x| x.1).unwrap_or(""); let names: Vec = doc @@ -338,7 +338,7 @@ fn node_parameters_survive_extreme_values() { } problems.sort(); problems.dedup(); - assert!(ran > 500, "only {ran} parameter cases ran"); + assert!(ran > 500 / crate::divisor(), "only {ran} parameter cases ran"); assert!(problems.is_empty(), "{} parameter problems:\n{}", problems.len(), problems.join("\n")); } @@ -446,17 +446,17 @@ fn large_sizes_are_accepted() { fn a_cancelled_evaluation_stops_early() { use craft_material_graph::context::{Cancel, EvalContext}; let mut g = Graph::parse(EXAMPLE).unwrap(); - g.size = 1024; + g.size = 256; let keep: Vec = g.output_nodes().iter().map(|o| o.2).collect(); let job = EvalContext::with_cancel(Cancel::new()); let t0 = std::time::Instant::now(); - let full = g.evaluate_all_in(&job, 1024, &keep); + let full = g.evaluate_all_in(&job, 256, &keep); let full_time = t0.elapsed(); assert!(!full.kept.is_empty(), "a current job must deliver its outputs"); // a newer job exists: the old one is cancelled from the start job.cancel.cancel(); let t1 = std::time::Instant::now(); - let r = g.evaluate_all_in(&job, 1024, &keep); + let r = g.evaluate_all_in(&job, 256, &keep); assert!(r.kept.is_empty(), "a cancelled run must not deliver outputs"); assert!( t1.elapsed() < full_time / 4 + std::time::Duration::from_millis(50), diff --git a/crates/material-graph/tests/it/seam.rs b/crates/material-graph/tests/it/seam.rs index f5f39c96f..ed68e63f2 100644 --- a/crates/material-graph/tests/it/seam.rs +++ b/crates/material-graph/tests/it/seam.rs @@ -18,7 +18,7 @@ fn seam(t: &Tex) -> (f32, f32) { #[test] fn every_node_is_seamless() { let mut bad = Vec::new(); - for sp in SPECS { + for sp in crate::sampled(SPECS, 0) { let Some(text) = demo_graph_for(sp.kind) else { continue }; let g = Graph::parse(&text).unwrap(); let out = match g.evaluate(Some(seam_size())) { @@ -83,7 +83,7 @@ fn filters_commute_with_wrapped_shifts() { "quantize", ]; let mut bad = Vec::new(); - for c in filters { + for c in crate::sampled(filters.iter(), 0) { let kind = c.split(' ').next().unwrap(); let mut line = format!("node 1 {c}"); // (the nodes that read no `in` are given their inputs in the line) @@ -144,7 +144,7 @@ fn filters_commute_with_wrapped_shifts() { fn every_node_is_seamless_when_not_square() { let mut bad = Vec::new(); for (wide, name) in [(true, "2:1"), (false, "1:2")] { - for sp in SPECS { + for sp in crate::sampled(SPECS, 4) { let Some(text) = demo_graph_for(sp.kind) else { continue }; let mut g = Graph::parse(&text).unwrap(); let s = g.size; From 6bbe36ea79f86616235b534567d142c5284d9de0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:02 +0000 Subject: [PATCH 11/27] psd test: the every-triangle mesh is refused at a 512 px output --- crates/psd/src/float.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/psd/src/float.rs b/crates/psd/src/float.rs index 658538bc2..ad10fbafe 100644 --- a/crates/psd/src/float.rs +++ b/crates/psd/src/float.rs @@ -781,7 +781,8 @@ mod tests { #[test] fn a_mesh_that_makes_every_triangle_cover_the_output_is_refused() { // A 48×48 custom mesh whose patch corners scatter over the four corners of the - // content, so most of the 4608 triangles span the whole 2048² output. + // content, so most of the 4608 triangles span the whole output (the work budget grows with + // the output's pixels, so the size only sets how much is filled before it runs out). let (cols, rows) = (48usize, 48usize); let stride = cols * 3 + 1; let mut mesh = vec![[0.0, 0.0]; stride * (rows * 3 + 1)]; @@ -794,9 +795,9 @@ mod tests { } } let warp = crate::smart::Warp { style: "warpCustom".into(), bounds: [0.0, 0.0, 16.0, 16.0], cols, rows, mesh, ..Default::default() }; - let s = so([[0.0, 0.0], [2048.0, 0.0], [2048.0, 2048.0], [0.0, 2048.0]], Some(warp)); + let s = so([[0.0, 0.0], [512.0, 0.0], [512.0, 512.0], [0.0, 512.0]], Some(warp)); let content = FloatImage { width: 16, height: 16, data: vec![[1.0, 0.0, 0.0, 1.0]; 256] }; - assert!(s.render_placed(&content, 1.0, Some((2048, 2048))).is_none()); + assert!(s.render_placed(&content, 1.0, Some((512, 512))).is_none()); } #[test] From 4c3fcafa01bbc1eeb158b70812ecc78b6df1ca38 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:02 +0000 Subject: [PATCH 12/27] svg test: the entity expansion bomb at a limit 256 times smaller --- crates/svg/src/guard.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/svg/src/guard.rs b/crates/svg/src/guard.rs index e2a11ae6a..c9575f599 100644 --- a/crates/svg/src/guard.rs +++ b/crates/svg/src/guard.rs @@ -487,7 +487,10 @@ mod tests { #[test] fn a_repeated_large_entity_is_too_large_and_a_namespace_entity_is_not() { - let big = "x".repeat(1 << 20); + // (the limit is passed in: the same arithmetic as `MAX_ENTITY_EXPANSION` over entities 256 times smaller, which + // only expand to 16 references' worth, so the strings the test builds and scans stay small) + let big = "x".repeat(1 << 16); + let expansion_too_large = |svg: &str| entities_expand_past(svg, 16 << 16); let refs = "&a;".repeat(20); let bomb = format!("]>"); assert!(expansion_too_large(&bomb)); @@ -500,6 +503,7 @@ mod tests { let ampersands = format!("]>", "&".repeat(1 << 20)); let start = std::time::Instant::now(); assert!(!expansion_too_large(&ersands)); + eprintln!("DIAG svg ampersand run read in {:?}", start.elapsed()); // A quadratic read would take hours; the bound is loose for a loaded machine. assert!(start.elapsed() < std::time::Duration::from_secs(120), "{:?}", start.elapsed()); } From 878b4ee8113638e20a20e9f8aebdf6f0e99cd145 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:06 +0000 Subject: [PATCH 13/27] image-codecs tests: the gate flips and overwrites one value per sampled byte, rotating --- crates/image-codecs/tests/it/malformed.rs | 7 +++++-- crates/image-codecs/tests/it/tiff_pages.rs | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/image-codecs/tests/it/malformed.rs b/crates/image-codecs/tests/it/malformed.rs index 7ccb7819b..bd6bd605b 100644 --- a/crates/image-codecs/tests/it/malformed.rs +++ b/crates/image-codecs/tests/it/malformed.rs @@ -99,9 +99,12 @@ fn byte_overwrites_in_header_never_panic() { let step = craft_media_testkit::hostile::divisor(); for (k, (f, bytes)) in samples().into_iter().enumerate() { for i in (0..bytes.len().min(64)).filter(|i| (i + k) % step == 0) { - for v in [0x00, 0x7F, 0xFF] { + // nightly writes every value to each byte; the gate one per byte, rotating, so the sampled bytes together see all + let values = [0x00, 0x7F, 0xFF]; + let one = [values[(i / step) % 3]]; + for v in if step == 1 { &values[..] } else { &one[..] } { let mut b = bytes.clone(); - b[i] = v; + b[i] = *v; no_panic(f, &b); } } diff --git a/crates/image-codecs/tests/it/tiff_pages.rs b/crates/image-codecs/tests/it/tiff_pages.rs index a01523191..ec30eff2c 100644 --- a/crates/image-codecs/tests/it/tiff_pages.rs +++ b/crates/image-codecs/tests/it/tiff_pages.rs @@ -840,7 +840,11 @@ fn zoo_decodes_and_never_panics_when_cut_or_corrupted() { poke(&f[..cut]); } for i in (0..f.len()).filter(|i| (i + k) % step == 0) { - for flip in [0xffu8, 0x80, 0x01] { + // nightly flips each byte three ways; the gate one way per byte, rotating, so the sampled bytes together see all + let flips = [0xffu8, 0x80, 0x01]; + let one = [flips[(i / step) % 3]]; + for flip in if step == 1 { &flips[..] } else { &one[..] } { + let flip = *flip; let mut g = f.clone(); g[i] ^= flip; poke(&g); From 336611c0f300233f7a752dd1cd9d12cdfb4d49c0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:22 +0000 Subject: [PATCH 14/27] suite: unhinted test faces, one story per kind at the gate, shared fixtures for click paths and disabled/read-only drives, no density shot equal to the default --- .../ui-contract/src/runtime/egui/fixture.rs | 16 ++++++- crates/ui-contract/src/testing/suite.rs | 2 + .../src/testing/suite/activation.rs | 23 +++++++++- crates/ui-contract/src/testing/suite/nodes.rs | 19 ++++++++ crates/ui-contract/src/testing/suite/size.rs | 44 +++++++++---------- .../ui-contract/src/testing/suite/variants.rs | 18 +++++--- 6 files changed, 89 insertions(+), 33 deletions(-) diff --git a/crates/ui-contract/src/runtime/egui/fixture.rs b/crates/ui-contract/src/runtime/egui/fixture.rs index 9f13a1171..7d196d76d 100644 --- a/crates/ui-contract/src/runtime/egui/fixture.rs +++ b/crates/ui-contract/src/runtime/egui/fixture.rs @@ -416,7 +416,21 @@ pub(crate) fn bare_context() -> Context { /// one build to the next. fn test_fonts() -> egui::FontDefinitions { static FONTS: std::sync::OnceLock = std::sync::OnceLock::new(); - FONTS.get_or_init(crate::fonts::deflated_default_definitions).clone() + FONTS + .get_or_init(|| { + let mut definitions = crate::fonts::deflated_default_definitions(); + // A fixture reads text through the AccessKit tree and the painted bounds, never the atlas pixels, and + // hinting changes only how outlines are rasterized (advances and layout do not read it). Without it no + // face builds a hinting instance and no glyph runs the hinter. An app's own stack (`UiFonts::install`) + // keeps hinting, which the review renders use. + for data in definitions.font_data.values_mut() { + let mut face = (**data).clone(); + face.tweak.hinting = Some(false); + *data = Arc::new(face); + } + definitions + }) + .clone() } /// A paragraph of `text` wrapped to the available width. diff --git a/crates/ui-contract/src/testing/suite.rs b/crates/ui-contract/src/testing/suite.rs index 037d70f80..2320c56a1 100644 --- a/crates/ui-contract/src/testing/suite.rs +++ b/crates/ui-contract/src/testing/suite.rs @@ -173,6 +173,8 @@ fn panic_text(payload: Box) -> String { /// The cases of `group` over the stories of the type `probe` describes, and with `check_exemptions` the check that /// each exemption names a known case. `home`: the stories are the package's that registers the type ([`Subject::home`]). fn run_group(probe: Probe, group: &'static Group, check_exemptions: bool, home: bool, stories: Vec) -> Result<(), Failed> { + // The cases that read the type as a whole look at one story of each kind at the gate; the others keep every story. + let stories = if matches!(group.name, "reads" | "variants" | "containers") { nodes::sampled_stories(stories) } else { stories }; let subject = Subject::new(&probe, stories, home); let mut failures = Vec::new(); if check_exemptions && home { diff --git a/crates/ui-contract/src/testing/suite/activation.rs b/crates/ui-contract/src/testing/suite/activation.rs index 719ca9754..dd74cfdea 100644 --- a/crates/ui-contract/src/testing/suite/activation.rs +++ b/crates/ui-contract/src/testing/suite/activation.rs @@ -25,6 +25,13 @@ pub(super) const CASES: &[Case] = &[ Case::new("press-removal", ANY, removal_cancels_a_press), ]; +/// Whether a click path left the component as it found it: no node state changed and no layer opened. The paths of one +/// part share a fixture while this holds; a path that moved something starts the next in a fresh fixture, so +/// a path never sees another's effect. +fn left_as_found(fixture: &Fixture, before: &HashMap, layers: usize) -> bool { + signature(fixture.tree()) == *before && crate::runtime::overlay::open_entries(fixture.ctx()).len() == layers +} + /// Enter, Space, AccessKit `Click` and a primary click each give exactly one click on a component that reports /// clicks and carries no value (value types are checked by the values case). fn each_activation_clicks_once(subject: &Subject) -> Result<(), String> { @@ -37,14 +44,20 @@ fn each_activation_clicks_once(subject: &Subject) -> Result<(), String> { if !matches!(plan, Plan::Activate) || !fixture.tree().declares_key(root.node, Declared::Click) { continue; } + // The variants share one fixture while each leaves the component as it found it ([`left_as_found`]). + let mut shared: Option = None; for variant in variants(plan, subject.probe) { - let mut fixture = input_fixture(story); + let mut fixture = shared.take().unwrap_or_else(|| input_fixture(story)); + let (before, layers) = (signature(fixture.tree()), crate::runtime::overlay::open_entries(fixture.ctx()).len()); fixture.take_outputs(); run(&mut fixture, plan, variant); let clicks = fixture.take_outputs().iter().filter(|output| output.activated()).count(); if clicks != 1 { return Err(format!("{}: {} gave {clicks} clicks", story.name, variant_name(plan, variant))); } + if left_as_found(&fixture, &before, layers) { + shared = Some(fixture); + } } } Ok(()) @@ -82,12 +95,15 @@ fn each_part_activates_once(subject: &Subject) -> Result<(), String> { (2, "Enter", keys[0].1 && declares(Declared::Focus)), (3, "Space", keys[1].1 && declares(Declared::Focus)), ]; + // The paths of a part share one fixture while each leaves the component as it found it ([`left_as_found`]). + let mut shared: Option = None; for (path, name, _) in paths.into_iter().filter(|(_, _, has)| *has) { - let mut fixture = input_fixture(story); + let mut fixture = shared.take().unwrap_or_else(|| input_fixture(story)); let Some(target) = fixture.root_id().and_then(|id| fixture.part(id, part)) else { continue }; if fixture.tree().data_of(target.node).is_some_and(|node| node.is_disabled()) { continue; } + let (before, layers) = (signature(fixture.tree()), crate::runtime::overlay::open_entries(fixture.ctx()).len()); fixture.take_outputs(); match path { 0 => { @@ -107,6 +123,9 @@ fn each_part_activates_once(subject: &Subject) -> Result<(), String> { if clicks != 1 { return Err(format!("{}: {name} on the part {part:?} gave {clicks} clicks", story.name)); } + if left_as_found(&fixture, &before, layers) { + shared = Some(fixture); + } } } } diff --git a/crates/ui-contract/src/testing/suite/nodes.rs b/crates/ui-contract/src/testing/suite/nodes.rs index 20cf49b1e..81321a4d1 100644 --- a/crates/ui-contract/src/testing/suite/nodes.rs +++ b/crates/ui-contract/src/testing/suite/nodes.rs @@ -3,6 +3,7 @@ use crate::runtime::access::Role; use crate::runtime::egui::access::{AccessTree, Declared, NodeKey}; use crate::testing::fixture::{Fixture, Target}; +use crate::testing::story::Story; use craft_behavior::PartRef; /// `node` and every node below it. @@ -160,3 +161,21 @@ pub(super) fn sampled_actions(tree: &AccessTree, mut pairs: Vec<(NodeKey, Declar } sets.iter().flat_map(|set| sample(set)).collect() } + +/// `stories` cut, when [`samples_repeats`], to the first story of each distinct kind: stories that cover the same +/// required states, drive the same way, give the same disabled reason and set command states alike differ only in +/// what they show, which the cases that read the type as a whole (`reads`, `variants`, `containers`) see through +/// the first of them. The nightly run keeps every story. +pub(super) fn sampled_stories(stories: Vec) -> Vec { + if !samples_repeats() { + return stories; + } + let kind = |story: &Story| (story.covers, std::mem::discriminant(&story.drive), story.disabled_text, story.commands.is_some()); + let mut kept: Vec = Vec::new(); + for story in stories { + if !kept.iter().any(|known| kind(known) == kind(&story)) { + kept.push(story); + } + } + kept +} diff --git a/crates/ui-contract/src/testing/suite/size.rs b/crates/ui-contract/src/testing/suite/size.rs index a17c1c4ba..e13d818b5 100644 --- a/crates/ui-contract/src/testing/suite/size.rs +++ b/crates/ui-contract/src/testing/suite/size.rs @@ -101,32 +101,28 @@ pub fn text_size_case(story: &Story) -> Result<(), String> { /// The text-size case for `story`, whose settled default shot is `base`. fn text_size_from(story: &Story, base: Shot) -> Result<(), String> { - let variants: [(&str, Shot); 4] = [ - ( - "text size", + // The shot at the default density is the base shot, so a density is shot only when it is not the default. + let densities = [("compact density", Size::Compact), ("comfortable density", Size::Comfortable)]; + let mut variants: Vec<(&str, Shot)> = vec![( + "text size", + shot(story, &|f| { + f.text_size(TextSize::Large); + }), + )]; + for (name, density) in densities.into_iter().filter(|(_, density)| *density != Size::default()) { + variants.push(( + name, shot(story, &|f| { - f.text_size(TextSize::Large); + f.density(density); }), - ), - ( - "compact density", - shot(story, &|f| { - f.density(Size::Compact); - }), - ), - ( - "comfortable density", - shot(story, &|f| { - f.density(Size::Comfortable); - }), - ), - ( - "scale 2", - shot(story, &|f| { - f.scale(Scale(2.0)); - }), - ), - ]; + )); + } + variants.push(( + "scale 2", + shot(story, &|f| { + f.scale(Scale(2.0)); + }), + )); let (before, after) = (base.shown.size(), |shot: &Shot| shot.shown.size()); for (name, grown) in &variants { let size = after(grown); diff --git a/crates/ui-contract/src/testing/suite/variants.rs b/crates/ui-contract/src/testing/suite/variants.rs index dabbeabae..08dc605d9 100644 --- a/crates/ui-contract/src/testing/suite/variants.rs +++ b/crates/ui-contract/src/testing/suite/variants.rs @@ -36,12 +36,15 @@ fn acted(fixture: &mut Fixture, before: &crate::testing::story::StorySnapshot) - fn disabled_changes_nothing(subject: &Subject) -> Result<(), String> { for story in &subject.stories { let plan = subject.base(story).plan; + // One fixture takes every drive: a disabled story that acts on one is an error at once, so a drive that + // passes leaves it as it was for the next. + let mut driven = for_input(Fixture::story_scoped(story, |scope| scope.enabled = Some(false))); for variant in variants(plan, subject.probe).into_iter().filter(|variant| !cancels(plan, *variant)) { - let mut fixture = for_input(Fixture::story_scoped(story, |scope| scope.enabled = Some(false))); + let fixture = &mut driven; let before = fixture.data().snapshot(); fixture.take_outputs(); - run(&mut fixture, plan, variant); - if acted(&mut fixture, &before) { + run(fixture, plan, variant); + if acted(fixture, &before) { return Err(format!("{}: a disabled story acted on drive {variant}", story.name)); } } @@ -87,12 +90,15 @@ fn read_only_changes_nothing(subject: &Subject) -> Result<(), String> { } for story in &subject.stories { let plan = subject.base(story).plan; + // One fixture takes every drive: a read-only story that acts on one is an error at once, so a drive that + // passes leaves it as it was for the next. + let mut driven = for_input(Fixture::story_scoped(story, |scope| scope.read_only = Some(true))); for variant in variants(plan, subject.probe).into_iter().filter(|variant| !cancels(plan, *variant)) { - let mut fixture = for_input(Fixture::story_scoped(story, |scope| scope.read_only = Some(true))); + let fixture = &mut driven; let before = fixture.data().snapshot(); fixture.take_outputs(); - run(&mut fixture, plan, variant); - if acted(&mut fixture, &before) { + run(fixture, plan, variant); + if acted(fixture, &before) { return Err(format!("{}: a read-only story acted on drive {variant}", story.name)); } } From a5409599a08882c88323989f2bc6745f561ab4ff Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:29 +0000 Subject: [PATCH 15/27] develop crystal tests: smaller grids, one extra tile for the eviction fill, two seeds for the held draw, margins printed --- crates/develop/src/tests_crystal.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/develop/src/tests_crystal.rs b/crates/develop/src/tests_crystal.rs index bb6a7bddc..ac25d3c4e 100644 --- a/crates/develop/src/tests_crystal.rs +++ b/crates/develop/src/tests_crystal.rs @@ -103,8 +103,8 @@ fn reference_render_has_unit_variance_and_no_mean() { fn small_render_is_the_downscaled_reference() { for (size, rough) in [(0.0, 50.0), (25.0, 50.0), (100.0, 50.0), (25.0, 0.0), (25.0, 100.0)] { let t = tile_of(size, rough); - for k in [2usize, 4, 8] { - let n = 48; + for k in [2usize, 8] { + let n = 32; let full = patch(&t, REF_LONG, n * k, 0); let down: Vec = (0..n * n) .map(|q| { @@ -120,6 +120,7 @@ fn small_render_is_the_downscaled_reference() { .collect(); let small = patch(&t, REF_LONG / k as f64, n, 0); let worst = down.iter().zip(&small).map(|(a, b)| (a - b).abs()).fold(0.0, f32::max); + eprintln!("DIAG downscale size {size} roughness {rough} 1/{k}: worst {worst} (limit 2e-3)"); assert!(worst < 2e-3, "size {size} roughness {rough} 1/{k}: differs by {worst}"); } } @@ -129,7 +130,7 @@ fn small_render_is_the_downscaled_reference() { fn strength_matches_the_target_at_mid_grey() { for (a, s, r) in [(50.0, 25.0, 50.0), (25.0, 25.0, 50.0), (50.0, 0.0, 50.0), (50.0, 100.0, 50.0), (50.0, 25.0, 0.0)] { let g = CrystalGrain::new(&Grain { amount: a, size: s, roughness: r, seed: 3 }, REF_LONG).expect("grain"); - let n = 320; + let n = 200; let lum: Vec = (0..n * n) .map(|k| { let (x, y) = ((k % n) as f32 + 0.5, (k / n) as f32 + 0.5); @@ -138,6 +139,7 @@ fn strength_matches_the_target_at_mid_grey() { }) .collect(); let want = strength_levels(a, s, r); + eprintln!("DIAG strength {a}/{s}/{r}: deviation {:.4} (limit 0.06)", std(&lum) / want - 1.0); assert!((std(&lum) / want - 1.0).abs() < 0.06, "{a}/{s}/{r}: {} levels, want {want}", std(&lum)); } } @@ -153,7 +155,7 @@ fn tones_keep_their_mean() { for (amount, size, levels) in cases { let g = CrystalGrain::new(&Grain { amount, size, roughness: 50.0, seed: 3 }, REF_LONG).expect("grain"); for &level in levels { - let n = 256; + let n = 160; let mut sum = 0.0f64; for k in 0..n * n { let (x, y) = ((k % n) as f32 + 0.5, (k / n) as f32 + 0.5); @@ -161,6 +163,7 @@ fn tones_keep_their_mean() { sum += (e[1].clamp(0.0, 1.0) * 255.0) as f64; } let shift = sum / (n * n) as f64 - level as f64; + eprintln!("DIAG tones {amount}/{size} level {level}: shift {shift:+.3} (limit 0.5)"); assert!(shift.abs() < 0.5, "{amount}/{size}: level {level} moved {shift:+.2}"); } } @@ -443,8 +446,10 @@ fn a_waiting_render_gets_the_tile_the_cache_evicted() { keep(&OWN, key, drawn.clone()); // other renders' tiles push it out of the cache before the waiter wakes // (each its own tile: a waiter that took another key's would fail the check below) + // (one tile of another seed under every key: a different `Arc` from the drawn one, drawn once) + let other_tile = Arc::new(CrystalTile::new(look, seed + 1).expect("tile")); for other in 1..=CACHE as u32 { - keep(&OWN, key_of(look, seed + other), Arc::new(CrystalTile::new(look, seed + other).expect("tile"))); + keep(&OWN, key_of(look, seed + other), other_tile.clone()); } assert!(cached(&OWN, key).is_none(), "the tile is still cached"); drop(marker); @@ -477,7 +482,8 @@ fn renders_that_miss_a_tile_together_draw_it_once() { static OWN: Cache = Mutex::new(Vec::new()); const N: usize = 8; // the first render's draw waits for the other seven to miss the tile too - const SEEDS: u32 = 5; + // (each seed is a full trial, as the draw is held until the others wait, so a few are enough) + const SEEDS: u32 = 2; HOLDS.lock().unwrap_or_else(PoisonError::into_inner).push((std::ptr::from_ref(&OWN) as usize, N - 1, SEEDS as usize)); let look = CrystalLook::new(0.0, 50.0); for seed in 0x0d4a_1000..0x0d4a_1000 + SEEDS { @@ -502,7 +508,8 @@ fn renders_that_miss_a_tile_together_draw_it_once() { fn width_matches_lightroom_classic() { let lrc = [(0.0, 50.0, 0.5), (25.0, 50.0, 1.13), (100.0, 50.0, 3.38), (25.0, 0.0, 0.86), (25.0, 100.0, 1.54)]; for (s, r, want) in lrc { - let got = half_width(&patch(&tile_of(s, r), REF_LONG, 360, 0), 360); + let got = half_width(&patch(&tile_of(s, r), REF_LONG, 256, 0), 256); + eprintln!("DIAG width size {s} roughness {r}: {got:.3} want {want} (limit 10 percent)"); assert!((got / want - 1.0).abs() < 0.1, "size {s} roughness {r}: width {got:.3}, want {want}"); } } From f5e3fda873e8b91186145f29ba01b2183738ceef Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:33:40 +0000 Subject: [PATCH 16/27] craft-dialogs: one trial per chooser scenario --- crates/dialogs/src/ui/chooser/tests.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/crates/dialogs/src/ui/chooser/tests.rs b/crates/dialogs/src/ui/chooser/tests.rs index 9b92f573f..0e38060c3 100644 --- a/crates/dialogs/src/ui/chooser/tests.rs +++ b/crates/dialogs/src/ui/chooser/tests.rs @@ -117,7 +117,7 @@ fn saved(path: impl AsRef) -> Option> { // `a_selected_folder_never_replaces_the_typed_save_name` and `a_removed_selected_file_keeps_its_exact_save_path`, with // `~` and "not found". The extension is the service's policy now, so the chooser answers the name as typed. #[trial] -fn the_chooser_lists_and_accepts_like_a_file_panel() { +fn a_typed_folder_is_entered_and_a_new_name_is_saved_as_typed() { // A typed folder is entered and its name used up; a new name is answered as typed. let mut save = Chooser::open(PickRequest::save("document").directory("/d")); save.type_name("drafts"); @@ -126,7 +126,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() { save.type_name("chapter"); save.click("Save"); assert_eq!(save.answer(), saved("/d/drafts/chapter"), "a new name is saved to as typed"); +} +#[trial] +fn a_listed_file_is_replaced_only_after_the_question() { // A listed file is replaced only after the question, asked once. let mut replace = Chooser::open(PickRequest::save("document").directory("/d/drafts")); replace.type_name("old.docx"); @@ -134,7 +137,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() { assert_eq!(replace.answer(), None, "the chooser asks before replacing"); replace.click("Replace"); assert_eq!(replace.answer(), saved("/d/drafts/old.docx")); +} +#[trial] +fn a_selected_file_keeps_its_exact_name_for_open_and_for_the_save_question() { // A selected file keeps its exact name, leading space and all, for Open and for Save's question. let mut open = Chooser::open(PickRequest::open("document").directory("/d")); open.click(" report.docx"); @@ -147,7 +153,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() { assert_eq!(save.answer(), None, "Save asks before replacing the selected file"); save.click("Replace"); assert_eq!(save.answer(), saved("/d/ report.docx")); +} +#[trial] +fn a_removed_selected_file_keeps_its_exact_save_path() { // A selected file removed meanwhile still names the exact path, and nothing is asked. let mut removed = Chooser::open(PickRequest::save("document").file_name("Draft.docx").directory("/d")); removed.click(" report.docx"); @@ -155,7 +164,10 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() { removed.refocus(); removed.click("Save"); assert_eq!(removed.answer(), saved("/d/ report.docx"), "the removed selection keeps its path, not `report.docx`"); +} +#[trial] +fn a_selected_folder_is_entered_and_never_becomes_the_save_name() { // A selected folder is entered and never becomes the save name; once it is gone, the typed name is saved to. let mut folder = Chooser::open(PickRequest::save("document").file_name("chapter.docx").directory("/d")); folder.click("Chapters"); @@ -168,13 +180,19 @@ fn the_chooser_lists_and_accepts_like_a_file_panel() { gone.refocus(); gone.click("Save"); assert_eq!(gone.answer(), saved("/d/chapter.docx"), "the removed folder is not saved over as `Chapters.docx`"); +} +#[trial] +fn the_home_root_and_a_typed_path_elsewhere_open() { // `~` is the Home root; a typed path elsewhere is listed, then opened. let mut home = Chooser::open(PickRequest::open("document").directory("/d")); home.type_name("~/Letters/aunt.txt"); home.click("Open"); assert_eq!(home.answer(), picked("/home/u/Letters/aunt.txt")); +} +#[trial] +fn a_missing_name_on_open_is_refused_and_said() { // A missing name on Open is refused and said. let mut missing = Chooser::open(PickRequest::open("document").directory("/d")); missing.type_name("missing.docx"); From 4a303613dfb791c2898cd0138624e24c21ff593a Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:34:10 +0000 Subject: [PATCH 17/27] craft-menu: review row-count test over 400 entries --- crates/menu/tests/it/shortcuts/review.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/menu/tests/it/shortcuts/review.rs b/crates/menu/tests/it/shortcuts/review.rs index 2ab0953a7..8f5b3e806 100644 --- a/crates/menu/tests/it/shortcuts/review.rs +++ b/crates/menu/tests/it/shortcuts/review.rs @@ -44,15 +44,15 @@ fn review_rig() -> Rig { rig } -/// Only the lines in view are drawn: the review of 2,000 entries holds a few include boxes, not 2,000. +/// Only the lines in view are drawn: a review of several hundred entries holds a few include boxes, not one per entry. #[trial] fn a_large_review_draws_only_the_rows_in_view() { - let commands: Vec = (0..2000).map(|i| command(&format!("Entry {i}"), "Cmd+K")).collect(); + let commands: Vec = (0..400).map(|i| command(&format!("Entry {i}"), "Cmd+K")).collect(); let mut rig = Rig::new(keymap(Platform::Mac), options(), None); rig.review(set(&commands), ImportOptions::default()); let drawn = rig.names_with(Role::CHECK_BOX, "").len(); assert!(drawn > 0, "the lines in view carry include boxes"); - assert!(drawn < 100, "{drawn} include boxes drawn for 2,000 entries"); + assert!(drawn < 100, "{drawn} include boxes drawn for 400 entries"); } /// Start, include and a picked target re-plan the import; a pick and No equivalent reach the app. From 5742ac10df178ecb6fa75d5960116c44a658bf8f Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:34:17 +0000 Subject: [PATCH 18/27] audio-dsp test: DIAG for the slow effects of the extreme-settings tail --- crates/audio-dsp/src/effects.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/audio-dsp/src/effects.rs b/crates/audio-dsp/src/effects.rs index 862ee0f46..679b7c5f9 100644 --- a/crates/audio-dsp/src/effects.rs +++ b/crates/audio-dsp/src/effects.rs @@ -291,6 +291,7 @@ mod tests { std::thread::scope(|scope| { for e in crate::testutil::sampled_effects() { scope.spawn(move || { + let started = std::time::Instant::now(); for setting in [0.0f32, 1.0] { let mut fx = (e.create)(SR, 2); for p in e.params { @@ -318,6 +319,9 @@ mod tests { ); } } + if started.elapsed() > std::time::Duration::from_secs(1) { + eprintln!("DIAG extreme settings: {} took {:?}", e.id, started.elapsed()); + } }); } }); From f24ff76636cdd933112f50918d94be233c3fc92b Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:35:27 +0000 Subject: [PATCH 19/27] material-graph test: rustfmt --- crates/material-graph/tests/it/kind_versions.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/material-graph/tests/it/kind_versions.rs b/crates/material-graph/tests/it/kind_versions.rs index 417a24b14..0b6f85743 100644 --- a/crates/material-graph/tests/it/kind_versions.rs +++ b/crates/material-graph/tests/it/kind_versions.rs @@ -93,7 +93,11 @@ fn a_fix_in_one_operation_leaves_most_kinds_alone() { let scanned = SourceTree::scan(&edited, DISPATCHERS); let scan = started.elapsed(); let after = versions(&scanned); - eprintln!("DIAG kind_versions edit of {:?}: scan {scan:?}, versions {:?}", edits.iter().map(|e| e.0).collect::>(), started.elapsed() - scan); + eprintln!( + "DIAG kind_versions edit of {:?}: scan {scan:?}, versions {:?}", + edits.iter().map(|e| e.0).collect::>(), + started.elapsed() - scan + ); kinds.iter().zip(before.iter().zip(&after)).filter(|(_, (a, b))| a != b).map(|(k, _)| k.clone()).collect::>() }; let changed_by = |file: &str, from: &str, to: &str| changed_by_all(&[(file, from, to)]); From b0a11ffc74e8cf2f9fb7689b09a3d329620dee48 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:41:18 +0000 Subject: [PATCH 20/27] Cargo.lock: craft-testkit dev-dependency of craft-material-graph --- Cargo.lock | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.lock b/Cargo.lock index e89a92493..1624a52ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3250,6 +3250,7 @@ dependencies = [ name = "craft-material-graph" version = "0.1.0" dependencies = [ + "craft-testkit", "libm", "rayon", ] From 3a425aeffe42e05a132b87103746d11cfced6655 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 22:51:38 +0000 Subject: [PATCH 21/27] material-graph tests: is_multiple_of for the sweep samples --- crates/material-graph/src/graph.rs | 2 +- crates/material-graph/tests/it/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/material-graph/src/graph.rs b/crates/material-graph/src/graph.rs index 8fc6067f7..57891ba48 100644 --- a/crates/material-graph/src/graph.rs +++ b/crates/material-graph/src/graph.rs @@ -5484,7 +5484,7 @@ mod grey_tests { /// Whether the next case of the sweep is in the sample. fn take(&mut self) -> bool { - let take = self.seen % self.stride == 0; + let take = self.seen.is_multiple_of(self.stride); self.seen += 1; self.visited += usize::from(take); take diff --git a/crates/material-graph/tests/it/main.rs b/crates/material-graph/tests/it/main.rs index e82a66b45..a7828f053 100644 --- a/crates/material-graph/tests/it/main.rs +++ b/crates/material-graph/tests/it/main.rs @@ -19,7 +19,7 @@ mod vector; /// nightly, where the divisor is 1), so tests sweeping the same list with different offsets together reach more of it. fn sampled(items: impl IntoIterator, offset: usize) -> Vec { let div = divisor(); - items.into_iter().enumerate().filter(|(i, _)| (i + offset) % div == 0).map(|(_, t)| t).collect() + items.into_iter().enumerate().filter(|(i, _)| (i + offset).is_multiple_of(div)).map(|(_, t)| t).collect() } fn divisor() -> usize { From ad53534c96f3fdf8a50f1f5a32592ef3a7c1635f Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 23:02:29 +0000 Subject: [PATCH 22/27] craft-ps test: places stays u32 in the sampled formatter sweep --- crates/ps/src/write.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ps/src/write.rs b/crates/ps/src/write.rs index b14b3169c..09793a8eb 100644 --- a/crates/ps/src/write.rs +++ b/crates/ps/src/write.rs @@ -607,7 +607,7 @@ mod tests { let (mut integer_path, mut visited) = (0usize, 0usize); let samples = number_samples(); for places in 0..=12 { - for v in samples.iter().copied().skip(places % step).step_by(step) { + for v in samples.iter().copied().skip(places as usize % step).step_by(step) { visited += 1; let mut expected = String::from("x "); base_push_num_places(&mut expected, v, places); From 4a9cd1f8c52ca7acd6dec000da6f326c250e82c2 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 00:04:24 +0000 Subject: [PATCH 23/27] develop crystal test: tones keep their 256-pixel sample (160 moved the mean past the limit) --- crates/develop/src/tests_crystal.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/develop/src/tests_crystal.rs b/crates/develop/src/tests_crystal.rs index ac25d3c4e..a01ca4dc1 100644 --- a/crates/develop/src/tests_crystal.rs +++ b/crates/develop/src/tests_crystal.rs @@ -155,7 +155,7 @@ fn tones_keep_their_mean() { for (amount, size, levels) in cases { let g = CrystalGrain::new(&Grain { amount, size, roughness: 50.0, seed: 3 }, REF_LONG).expect("grain"); for &level in levels { - let n = 160; + let n = 256; let mut sum = 0.0f64; for k in 0..n * n { let (x, y) = ((k % n) as f32 + 0.5, (k / n) as f32 + 0.5); @@ -163,7 +163,6 @@ fn tones_keep_their_mean() { sum += (e[1].clamp(0.0, 1.0) * 255.0) as f64; } let shift = sum / (n * n) as f64 - level as f64; - eprintln!("DIAG tones {amount}/{size} level {level}: shift {shift:+.3} (limit 0.5)"); assert!(shift.abs() < 0.5, "{amount}/{size}: level {level} moved {shift:+.2}"); } } From 25073123e8ddfa99649f715d1031918646f40ec0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 00:04:24 +0000 Subject: [PATCH 24/27] Revert "material-graph: evaluate_all skips nodes already run as inputs, removing the double evaluation and thumbnail of every node" This reverts commit d105734cf81c1bd0dd0ce9b00aacf41559a9199d. --- crates/material-graph/src/graph.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crates/material-graph/src/graph.rs b/crates/material-graph/src/graph.rs index 57891ba48..f16573d51 100644 --- a/crates/material-graph/src/graph.rs +++ b/crates/material-graph/src/graph.rs @@ -2014,11 +2014,6 @@ impl Graph { let mut seen = HashSet::new(); order.retain(|i| seen.insert(*i)); for id in order { - // already run (and thumbnailed) as an input of an earlier node of this call; its result was freed after its - // readers finished, so running it again would only compute and thumbnail the same node a second time - if cache.thumbs.as_ref().is_some_and(|t| t.contains_key(&id)) { - continue; - } match eval_node(self, id, &ctx, &[], &mut cache).and_then(|value| value.into_host(id, ec)) { Ok(t) => { if Some(id) == first || keep.contains(&id) { From 6673e63ad20fc3b800bd433a0bb7c9180547d0c2 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 01:06:35 +0000 Subject: [PATCH 25/27] CI: macOS and Windows cache entries are named by the dependency settings alone, so next restores main's The macOS and Windows legs cache dependencies only, but their entries were named by the hash of every profile override, workspace crates' included. next's cargo-ci.toml and cargo-dev.toml set other workspace-crate levels than main's, so next's pushes never found main's entries and built every dependency from source (Windows 40-52 minutes, macOS 29-36, against 10-15 with an entry). `deps-profile` hashes `[profile.dev]` and `[profile.dev.package."*"]` of both files; every other override names a workspace crate (test_profile_overrides_name_only_workspace_members). It is the same on main, next and #3405 today. The Linux leg, which keeps workspace crates, keeps the full hash. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/workspace.yml | 18 +++++++++++++++++- scripts/test-workspace-tests.py | 8 ++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index bc6077bfa..e1891613b 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -44,6 +44,7 @@ jobs: filter: ${{ steps.select.outputs.filter }} audit: ${{ steps.audit.outputs.audit }} profile: ${{ steps.audit.outputs.profile }} + deps-profile: ${{ steps.audit.outputs.deps-profile }} steps: - name: Harden runner uses: step-security/harden-runner@v2.22.4 @@ -67,6 +68,10 @@ jobs: # passes (scripts/ci-workspace-tests.sh), which names the Workspace legs' cache entries: # rust-cache's key does not hash these files, and an entry built with other overrides would be # rebuilt in full on every run. Other events than a pull request check out only these files. + # The macOS and Windows legs cache dependencies only, so `deps-profile` hashes only the + # settings that reach a dependency: `[profile.dev]` and `[profile.dev.package."*"]`. Every + # other override names a workspace crate (scripts/test-workspace-tests.py), so changing one + # keeps those entries, and next's runs restore main's. - uses: actions/checkout@v7.0.1 if: github.event_name != 'pull_request' with: @@ -83,6 +88,16 @@ jobs: run: | echo "audit=$(bash scripts/ci-workspace-tests.sh audit)" >> "$GITHUB_OUTPUT" echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT" + echo "deps-profile=$(python3 -I - <<'PY' + import hashlib, json, tomllib + kept = [] + for path in (".config/cargo-dev.toml", ".config/cargo-ci.toml"): + with open(path, "rb") as file: + dev = tomllib.load(file)["profile"]["dev"] + kept.append([dev, dev.pop("package", {}).get("*", {})]) + print(hashlib.sha256(json.dumps(kept, sort_keys=True).encode()).hexdigest()[:12]) + PY + )" >> "$GITHUB_OUTPUT" # The Linux leg keeps the compiled workspace crates between runs (`cache-workspace-crates`): each # main run saves a rolling cache entry of its own, every run restores the newest one, and Cargo @@ -172,7 +187,8 @@ jobs: with: os: '["windows-latest","macos-latest"]' lint-cache: false - cache-version: *cache-version + # Named by the dependency settings alone (`deps-profile`), so next restores main's entries. + cache-version: v2-${{ needs.platforms.outputs.deps-profile }} timeout-minutes: *timeout tools: *tools craft-fonts-ref: *craft-fonts diff --git a/scripts/test-workspace-tests.py b/scripts/test-workspace-tests.py index 77cdccd2e..0bc036e0d 100644 --- a/scripts/test-workspace-tests.py +++ b/scripts/test-workspace-tests.py @@ -313,9 +313,13 @@ class WorkspaceTests(unittest.TestCase): # Only the Linux leg splits into a build job and shards, and only for the audit. self.assertEqual(source.count("test-shards:"), 1) self.assertIn("test-shards: ${{ needs.platforms.outputs.audit == 'true' && 3 || 0 }}", source) - # Every Workspace leg's cache entry is named after the profile overrides it was built with. + # The Linux leg's entry, which keeps workspace crates, is named after every profile override; + # the macOS and Windows legs' dependency-only entries after the settings that reach a + # dependency, so next restores main's (test_profile_overrides_name_only_workspace_members). self.assertIn("cache-version: &cache-version v2-${{ needs.platforms.outputs.profile }}\n", source) - self.assertIn(" cache-version: *cache-version\n", source) + self.assertIn(" cache-version: v2-${{ needs.platforms.outputs.deps-profile }}\n", source) + self.assertIn(" deps-profile: ${{ steps.audit.outputs.deps-profile }}\n", source) + self.assertNotIn(" cache-version: *cache-version\n", source) # Only the Linux leg keeps workspace crates; the cache budget has no room for the others. self.assertEqual(source.count("cache-workspace-crates: true"), 1) self.assertIn(" msrv:", source) From 0075c7e7fd6b5a6012c34372ca0d7522984e66d4 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Wed, 25 Nov 2026 01:10:42 +0000 Subject: [PATCH 26/27] CI: a failed deps-profile hash stops the step instead of naming every entry v2- Co-Authored-By: Claude Opus 5.5 --- .github/workflows/workspace.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index e1891613b..11b1d9def 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -88,7 +88,8 @@ jobs: run: | echo "audit=$(bash scripts/ci-workspace-tests.sh audit)" >> "$GITHUB_OUTPUT" echo "profile=$(cat .config/cargo-dev.toml .config/cargo-ci.toml | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT" - echo "deps-profile=$(python3 -I - <<'PY' + # An assignment, so a failure stops the step (`bash -e`) instead of naming every entry `v2-`. + deps=$(python3 -I - <<'PY' import hashlib, json, tomllib kept = [] for path in (".config/cargo-dev.toml", ".config/cargo-ci.toml"): @@ -97,7 +98,8 @@ jobs: kept.append([dev, dev.pop("package", {}).get("*", {})]) print(hashlib.sha256(json.dumps(kept, sort_keys=True).encode()).hexdigest()[:12]) PY - )" >> "$GITHUB_OUTPUT" + ) + echo "deps-profile=$deps" >> "$GITHUB_OUTPUT" # The Linux leg keeps the compiled workspace crates between runs (`cache-workspace-crates`): each # main run saves a rolling cache entry of its own, every run restores the newest one, and Cargo From 728c797b14f636e69cba51c0d6e3177d64d9918d Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 01:09:59 +0000 Subject: [PATCH 27/27] Iconic column trial: the rule between icon groups spans more than half the rail, asserted as a relation --- crates/ui-panels/src/docking/iconic/trials.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-panels/src/docking/iconic/trials.rs b/crates/ui-panels/src/docking/iconic/trials.rs index 3b0485222..b3d65d665 100644 --- a/crates/ui-panels/src/docking/iconic/trials.rs +++ b/crates/ui-panels/src/docking/iconic/trials.rs @@ -708,7 +708,8 @@ fn icon_groups_apart_by_a_rule_show_one_level_rule_between_them() { let between: Vec<_> = level.iter().filter(|(a, _, _)| a.y > last.bottom() && a.y < next.top()).collect(); let [(a, b, ink)] = between.as_slice() else { panic!("one rule between the groups: {level:?}") }; let (left, right) = (a.x.min(b.x), a.x.max(b.x)); - assert!(left > 0.0 && right < RAIL && right - left > RAIL / 2.0, "the rule reaches across the column, short of its sides: {a:?} to {b:?}"); + let span = right - left; + assert!(left > 0.0 && right < RAIL && span > RAIL - span, "the rule reaches across the column, short of its sides: {a:?} to {b:?}"); let [r, g, bl, al] = border.0; assert_eq!(*ink, egui::Color32::from_rgba_unmultiplied(r, g, bl, al), "the rule is in line.border"); }