From: Ian Jackson Date: Fri, 29 Jan 2021 23:22:00 +0000 (+0000) Subject: wdt: conflict test actually tests, and passes, yay! X-Git-Tag: otter-0.4.0~630 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=145fcc386fd8541468454ffb886baebbf58a82e1;p=otter.git wdt: conflict test actually tests, and passes, yay! Signed-off-by: Ian Jackson --- diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index 01aed135..9f44d455 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -218,12 +218,18 @@ impl Ctx { nix::sys::signal::kill(pid, nix::sys::signal::SIGCONT)?; #[derive(Debug)] - struct Got { + struct Got<'s> { + side: &'s Side<'s>, + yes: bool, now: Pos, log: Vec, held: Option, client: String, } + impl<'s> Deref for Got<'s> { + type Target = Side<'s>; + fn deref<'t>(&'t self) -> &'t Side<'s> { &self.side } + } let gots = sides.iter().map(|side|{ let mut w = su.w(side.window)?; @@ -243,15 +249,24 @@ impl Ctx { let held = w.piece_held(&pc)?; let client = w.client()?; + let yes = held.as_ref() == Some(&client); - Ok::<_,AE>(Got { now, log, held, client }) + Ok::<_,AE>(Got { side, now, log, held, client, yes }) }).collect::,AE>>()?; - dbg!(gots); -/* - let yesno = izip!(&sides, &gots).map(|side, got|{ - let yn = - }).collect::,AE>>.context("compare")?;*/ + dbg!(&gots); + + let y = gots.iter().filter(|got| got.yes).next().expect("y"); + let n = gots.iter().filter(|got| !got.yes).next().expect("n"); + ensure_eq!(y.now, y.try_end); + ensure_eq!(n.now, y.try_end); + ensure_eq!(n.now, y.try_end); + ensure_eq!(n.held, y.held); + + for got in &gots { + let conflict = got.log.iter().any(|m| m.starts_with("Conflict!")); + ensure_eq!(conflict, !got.yes); + } } }