From 61aa438eb1c03b06bef2f8e2b057714fe0d1c8d5 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 5 Apr 2021 17:47:40 +0100 Subject: [PATCH] wdt-simple: conflicts: Count conflicts, don't just check existence Signed-off-by: Ian Jackson --- wdriver/wdriver.rs | 9 +++++++-- wdriver/wdt-hand.rs | 2 +- wdriver/wdt-simple.rs | 6 ++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wdriver/wdriver.rs b/wdriver/wdriver.rs index 7c649475..c07d2c9f 100644 --- a/wdriver/wdriver.rs +++ b/wdriver/wdriver.rs @@ -447,8 +447,13 @@ impl<'g> WindowGuard<'g> { #[ext(pub)] impl Vec { - fn find_conflict(&self) -> Option<&String> { - self.iter().find(|m| m.starts_with("Conflict!")) + fn find_conflicts(&self) -> Vec { + self.iter().filter(|m| m.starts_with("Conflict!")) + .cloned().collect() + } + + fn assert_no_conflicts(&self) { + assert_eq!(self.find_conflicts(), vec![] as Vec); } } diff --git a/wdriver/wdt-hand.rs b/wdriver/wdt-hand.rs index ab567a07..9a776121 100644 --- a/wdriver/wdt-hand.rs +++ b/wdriver/wdt-hand.rs @@ -102,7 +102,7 @@ impl Ctx { let mut w = su.w(side)?; w.synch()?; let log = w.retrieve_log((&mut |_: &'_ _| false) as LogIgnoreBeforeFn)?; - assert_eq!(log.find_conflict(), None); + log.assert_no_conflicts(); } { diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index 6f0261bb..de9d8ba2 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -245,8 +245,10 @@ impl Ctx { assert_eq!(n.held, y.held); for got in &gots { - let conflict = got.log.find_conflict().is_some(); - assert_eq!(conflict, !got.yes); + let conflicts = got.log.find_conflicts(); + assert_eq!(conflicts.len(), + if got.yes { 0 } else { 1}, + "wrong # conflicts {:?}", &conflicts); } let yw = su.w(&y.window)?; -- 2.30.2