chiark / gitweb /
wdt-simple: conflicts: Count conflicts, don't just check existence
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 Apr 2021 16:47:40 +0000 (17:47 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 Apr 2021 16:47:40 +0000 (17:47 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
wdriver/wdriver.rs
wdriver/wdt-hand.rs
wdriver/wdt-simple.rs

index 7c649475adf26eeb0d86ca699b040e0195738ed9..c07d2c9f30a886dd069d45a5a3b9e768bde81a9b 100644 (file)
@@ -447,8 +447,13 @@ impl<'g> WindowGuard<'g> {
 
 #[ext(pub)]
 impl Vec<String> {
-  fn find_conflict(&self) -> Option<&String> {
-    self.iter().find(|m| m.starts_with("Conflict!"))
+  fn find_conflicts(&self) -> Vec<String> {
+    self.iter().filter(|m| m.starts_with("Conflict!"))
+      .cloned().collect()
+  }
+
+  fn assert_no_conflicts(&self) {
+    assert_eq!(self.find_conflicts(), vec![] as Vec<String>);
   }
 }
 
index ab567a077e6d196ef1fe4e088b2ac4759307989e..9a77612172fc9fc3dc2ba83afe49e4ff26c75b03 100644 (file)
@@ -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();
     }
 
     {
index 6f0261bb8b48a595893885f2fd933b48ceba57f9..de9d8ba2d16a95abb92e3cf25ca4ac91e5238da2 100644 (file)
@@ -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)?;