Something went wrong. Try again.
Exploring the idea of generated web rendering engine.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586//! [`bin/ground_truth_cache.rs`](../ground_truth_cache.rs)'s counterpart for the//! floats/block-formatting-context seam: runs the oracle once over//! `harness::float_cases::enumerated`/`random`, writing each case's engine dumps to//! `corpus/float-ground-truth/` (gitignored, and deliberately its own directory, separate//! from `corpus/ground-truth/` -- the shared cache the width, margin-collapse and//! percentage-resolution seams read, none of which generate `float`).//!//! Unlike the shared cache binary, this one also votes each case before writing it//! (`harness::compare::vote`, the same three-engine agreement//! `generation::float_runner::score_case` recomputes at scoring time from a cache read)//! and drops any case the engines disagree on beyond tolerance outright, rather than//! writing it and leaving `Outcome::Untrustworthy` to filter it out later -- this seam is//! new enough (`specs/floats-bfc.md`) that a disagreeing case is worth a loud drop count//! up front, not a silent exclusion three steps downstream.
use std::path::PathBuf;
use anyhow::Result;use generation::groundtruth::CachedCase;use harness::float_cases;use harness::oracle::Oracle;
/// Mirrors `bin/absolute_ground_truth_cache.rs`'s own constants: modest, so the cache/// stays cheap to rebuild on one machine.const RANDOM_SAMPLE_SEED: u64 = 0xABC0FFEE;const RANDOM_SAMPLE_COUNT: usize = 96;
fn main() -> Result<()> { let repo_root = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .parent() .and_then(|p| p.parent()) .expect("crate sits two levels below the repository root") .to_path_buf(); let out_dir = repo_root.join("corpus/float-ground-truth");
let mut oracle = Oracle::start(&repo_root, None, None)?; println!("engines: {}", oracle.engines.join(", "));
let mut cases = float_cases::enumerated(); cases.extend(float_cases::random(RANDOM_SAMPLE_SEED, RANDOM_SAMPLE_COUNT));
let mut written = 0usize; let mut dropped = 0usize; for case in &cases { let (dumps, errors) = oracle.dump(&case.html)?; for (engine, msg) in &errors { eprintln!("{}: {engine} failed: {msg}", case.id); } let cached = CachedCase { case_id: case.id.clone(), seed: case.seed, categories: case.categories.iter().map(|c| format!("{c:?}")).collect(), html: case.html.clone(), dumps: dumps.into_iter().collect(), errors: errors.into_iter().collect(), };
match cached.vote() { Ok(vote_report) => { let disagreements: Vec<_> = vote_report.untrustworthy().collect(); if !disagreements.is_empty() { eprintln!( "{}: dropped, engines split on {} measurement(s) beyond tolerance", case.id, disagreements.len() ); dropped += 1; continue; } } Err(e) => { eprintln!("{}: dropped, no reliable vote ({e:?})", case.id); dropped += 1; continue; } }
cached.write(&out_dir)?; written += 1; }
println!("wrote {written} case(s) to {}, dropped {dropped} for engine disagreement", out_dir.display()); oracle.shutdown()?; Ok(())}