Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
test: discard every part of an inconclusive real-capture analysis
Richie McIlroyaead3ae0c5d3
diff --git a/crates/verify/src/report.rs b/crates/verify/src/report.rsindex 88135075b..9ecabe828 100644--- a/crates/verify/src/report.rs+++ b/crates/verify/src/report.rs@@ -94,7 +94,55 @@ pub struct Case {counts: BTreeMap<(String, String), f64>,}+/// A case's analysis state, for discarding one analysis (see+/// [`Case::rollback`]).+pub struct CaseCheckpoint {+ problems: usize,+ problem_classes: usize,+ streams: usize,+ notes: usize,+ classes: BTreeSet<String>,+ class_problems: BTreeMap<String, String>,+ unobserved: BTreeMap<String, String>,+ measures: BTreeMap<String, cap_verify_expect::Metrics>,+ counts: BTreeMap<(String, String), f64>,+}++impl CaseCheckpoint {+ /// Problems recorded before the checkpoint.+ pub fn problems(&self) -> usize {+ self.problems+ }+}+impl Case {+ pub fn checkpoint(&self) -> CaseCheckpoint {+ CaseCheckpoint {+ problems: self.problems.len(),+ problem_classes: self.problem_classes.len(),+ streams: self.streams.len(),+ notes: self.notes.len(),+ classes: self.classes.clone(),+ class_problems: self.class_problems.clone(),+ unobserved: self.unobserved.clone(),+ measures: self.measures.clone(),+ counts: self.counts.clone(),+ }+ }++ /// Restores everything an analysis since `checkpoint` recorded.+ pub fn rollback(&mut self, checkpoint: CaseCheckpoint) {+ self.problems.truncate(checkpoint.problems);+ self.problem_classes.truncate(checkpoint.problem_classes);+ self.streams.truncate(checkpoint.streams);+ self.notes.truncate(checkpoint.notes);+ self.classes = checkpoint.classes;+ self.class_problems = checkpoint.class_problems;+ self.unobserved = checkpoint.unobserved;+ self.measures = checkpoint.measures;+ self.counts = checkpoint.counts;+ }+pub fn new(id: impl Into<String>) -> Self {let id = id.into();eprintln!("[cap-verify] case {id} ({})", platform());diff --git a/crates/verify/tests/recording.rs b/crates/verify/tests/recording.rsindex 825f91063..33c4a3a16 100644--- a/crates/verify/tests/recording.rs+++ b/crates/verify/tests/recording.rs@@ -1228,29 +1228,19 @@ async fn run_case(case.note(format!("artifacts kept at {}", scratch.display()));return Ok(());}- let before = (- case.problems.len(),- case.problem_classes.len(),- case.classes.clone(),- case.streams.len(),- case.notes.len(),- );+ let before = case.checkpoint();IMPLICATED.with(|m| m.borrow_mut().clear());analyze(&recorded, reference, case)?;let implicated = IMPLICATED.with(|m| std::mem::take(&mut *m.borrow_mut()));let excuse = (!product_failed)- .then(|| frozen_failures(case, before.0, &implicated, &freezes))+ .then(|| frozen_failures(case, before.problems(), &implicated, &freezes)).flatten();let Some(reason) = excuse else {break (recorded, reference);};// Every unexpected failure lies inside a machine freeze: the// recording cannot tell Cap from the host. Discard the analysis.- case.problems.truncate(before.0);- case.problem_classes.truncate(before.1);- case.classes = before.2;- case.streams.truncate(before.3);- case.notes.truncate(before.4);+ case.rollback(before);let reason = format!("{reason}; evidence {}", sentinel_evidence.display());keep_stimulus_log(&attempt_scratch, &stem);if tries < 2 {