Something went wrong. Try again.
Exploring the idea of generated web rendering engine.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101//! [`bin/relpos_generation_loop.rs`](../relpos_generation_loop.rs)'s counterpart for the//! overflow seam: compiles the hand-written candidates in//! `crates/generation/fixtures/overflow-candidates` into one batch crate, runs every//! candidate over the cached corpus, and gates each against the permanent regression set//! (`generation::overflow_runner::evaluate`). Requires `overflow_ground_truth_cache` to//! have already populated `corpus/overflow-ground-truth/`.//!//! Like the relative-positioning loop, this one never admits anything://! `specs/overflow-scrollbars.md` calls for this seam to be built model-first, so there is//! no `correct` fixture here to admit, only `baseline` (which seeds the regression set)//! and two deliberately wrong candidates this binary proves the gate rejects.
use anyhow::{bail, Result};use generation::candidate_crate;use generation::groundtruth::load_all;use generation::model::{CandidateSource, DirectoryCandidateSource};use generation::orchestrate::{repo_root, run_candidates, write_regression_set};use generation::overflow_runner::passing_case_ids;use layout::overflow::{resolve_baseline, OverflowResolver};
fn main() -> Result<()> { let repo_root = repo_root(); let cache_dir = repo_root.join("corpus/overflow-ground-truth"); let cases = load_all(&cache_dir)?; if cases.is_empty() { bail!( "no cached cases under {}; run the overflow_ground_truth_cache binary first", cache_dir.display() ); }
let fixtures_dir = repo_root.join("crates/generation/fixtures/overflow-candidates"); let candidates = DirectoryCandidateSource { dir: fixtures_dir }.candidates()?; println!( "candidates: {}", candidates.iter().map(|c| c.name.as_str()).collect::<Vec<_>>().join(", ") );
let crate_dir = repo_root.join("corpus/candidates/overflow-generated"); candidate_crate::write_for(candidate_crate::Seam::Overflow, &crate_dir, &repo_root, &candidates)?; let binary = candidate_crate::compile(&crate_dir, &crate_dir.join("target"))?;
let regression_set_path = repo_root.join("corpus/overflow-regression-set.json"); let report_out = repo_root.join("corpus/candidates/overflow-report.json");
// Seeded from the shipped (deliberately wrong) baseline's own passing cases -- the // cases where no box scrolls at all, which is the one thing the baseline gets right. let baseline_passing: Vec<String> = passing_case_ids(resolve_baseline as OverflowResolver, &cases); if !regression_set_path.exists() { write_regression_set(®ression_set_path, &baseline_passing)?; println!( "seeded the permanent regression set with {} case(s) baseline already passes", baseline_passing.len() ); }
let gated = run_candidates(&binary, &cache_dir, Some(®ression_set_path), &report_out)?;
println!("\n== per-candidate results =="); for candidate in &gated.candidates { println!( "{:<28} {}/{} passed, admitted={}, regressed={}", candidate.name, candidate.cases_passed, candidate.cases_run, candidate.admitted, candidate.regressed_cases.len(), ); let mut categories: Vec<_> = candidate.per_category.iter().collect(); categories.sort_by_key(|(name, _)| (*name).clone()); for (category, tally) in categories { println!(" {category:<28} {}/{}", tally.passed, tally.total); } }
// Prove the gate discriminates: every seeded-wrong candidate must fail some case. // Checked against cases_passed/cases_run rather than `admitted`, for the same reason // the relative-positioning loop checks it that way -- the baseline's passing set is // too narrow to register either seeded bug as a regression, since both only diverge // on cases where something scrolls and the baseline never passed one of those. let get = |name: &str| gated.candidates.iter().find(|c| c.name == name); let wrong_names = ["only_clipping_boxes_overflow", "decides_both_axes_together"]; let mut discrimination_ok = true; for name in wrong_names { match get(name) { Some(wrong) if wrong.cases_passed >= wrong.cases_run => { discrimination_ok = false; eprintln!("gate did not reject seeded-wrong candidate {name}"); } Some(_) => {} None => bail!("no candidate named {name:?} in the batch"), } } if !discrimination_ok { bail!("the generation loop did not reject every seeded-wrong candidate"); } println!("\ngate rejected every seeded-wrong candidate");
Ok(())}