From 84dad211f5fcda4267e73c21b5daa7aec28f467f Mon Sep 17 00:00:00 2001 From: iris-ai <4+iris-ai@noreply.localhost> Date: Sat, 19 Sep 2026 13:43:11 -0400 Subject: [PATCH] Avoid repeated plan generation and unused diagnostics in layout fuzzers --- tests/generated.rs | 12 ++++++++---- tests/scenario/mod.rs | 12 ++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/generated.rs b/tests/generated.rs index c7a03c6..fd25083 100644 --- a/tests/generated.rs +++ b/tests/generated.rs @@ -14,7 +14,7 @@ #[path = "scenario/mod.rs"] mod scenario; -use iris::random::{Edits, plan}; +use iris::random::{Edits, Plan, plan}; use scenario::{ALL, Case, diverges, env, over_seeds}; /// How deep the generator branches. The generator widens two to four ways per @@ -32,8 +32,11 @@ fn depth() -> usize { const SEEDS: [u64; 10] = [1, 2, 3, 5, 8, 10, 13, 20, 86, 98]; fn check(seed: u64, depth: usize, case: Case) { - let grown = plan(seed, depth, &Edits::default()); - if let Some(how) = diverges(&grown, case, seed) { + check_plan(&plan(seed, depth, &Edits::default()), seed, depth, case); +} + +fn check_plan(grown: &Plan, seed: u64, depth: usize, case: Case) { + if let Some(how) = diverges(grown, case, seed) { panic!( "seed {seed} at depth {depth} differs after {}: {how}\n\ reduce it with SHRINK_SEED={seed} SHRINK_DEPTH={depth} \ @@ -119,8 +122,9 @@ fn a_long_run_of_seeds_agrees() { None => (1..=env("IRIS_GENERATED_SEEDS", 100_u64)).collect(), }; over_seeds(seeds, |seed| { + let grown = plan(seed, depth, &Edits::default()); for case in ALL { - check(seed, depth, case); + check_plan(&grown, seed, depth, case); } }); } diff --git a/tests/scenario/mod.rs b/tests/scenario/mod.rs index 555d978..79767f5 100644 --- a/tests/scenario/mod.rs +++ b/tests/scenario/mod.rs @@ -444,12 +444,6 @@ pub fn diverges(plan: &Plan, case: Case, seed: u64) -> Option { cold.state.root = Some(root); cold.frame(); - let places: HashMap = tree - .ids - .iter() - .enumerate() - .map(|(i, &id)| (id, i)) - .collect(); let mut drawn = 0; for (i, (&w, &c)) in tree.ids.iter().zip(&cold_tree.ids).enumerate() { let (got, want) = (warm.region(&w), cold.region(&c)); @@ -457,6 +451,12 @@ pub fn diverges(plan: &Plan, case: Case, seed: u64) -> Option { if got == want { continue; } + let places: HashMap = tree + .ids + .iter() + .enumerate() + .map(|(i, &id)| (id, i)) + .collect(); // Where two trees disagree is rarely where the cause is, so the // ancestry comes with it, marking the widgets that own a region. let mut chain = Vec::new();