chiark / gitweb /
tests: Rename always_context to did and use it a lot more
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Apr 2021 19:28:39 +0000 (20:28 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Apr 2021 22:12:28 +0000 (23:12 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/apitest.rs
wdriver/wdriver.rs
wdriver/wdt-altergame.rs
wdriver/wdt-hand.rs
wdriver/wdt-simple.rs

index a8ecaef495b0981581014bd7812685433b06e77c..e28ff9500fa97e3c0a820f3d4f0d4a974e9c44a4 100644 (file)
@@ -257,7 +257,7 @@ macro_rules! test {
 
 #[ext(pub)]
 impl<T,E> Result<T,E> {
-  fn always_context(self, msg: &'static str) -> anyhow::Result<T>
+  fn did(self, msg: &'static str) -> anyhow::Result<T>
   where Self: anyhow::Context<T,E>
   {
     let x = self.context(msg);
@@ -886,7 +886,7 @@ pub fn setup_core<O>(module_paths: &[&str], early_args: EarlyArgPredicate) ->
   let ds = prepare_tmpdir(&opts, &current_exe)?;
 
   let (mgmt_conn, server_child) =
-    prepare_gameserver(&cln, &ds).always_context("setup game server")?;
+    prepare_gameserver(&cln, &ds).did("setup game server")?;
 
   let mgmt_conn = mgmt_conn.for_game(
     TABLE.parse()?,
index 3ec5e80b53cb326dcd89930e3fc891341b9c5419..3bef850035cd91e502627f95feb264545c4e82a1 100644 (file)
@@ -757,13 +757,13 @@ pub fn setup(exe_module_path: &str) -> (Setup, Instance) {
       &mut |s: &OsStr| s.to_str().unwrap().starts_with("--test=")
     )?;
 
-  prepare_xserver(&cln, &core.ds).always_context("setup X server")?;
+  prepare_xserver(&cln, &core.ds).did("setup X server")?;
 
   let final_hook = FinalInfoCollection;
 
-  prepare_geckodriver(&opts, &cln).always_context("setup webdriver server")?;
+  prepare_geckodriver(&opts, &cln).did("setup webdriver server")?;
   let (driver, screenshot_count, windows_squirreled) =
-    prepare_thirtyfour(&core.ds).always_context("prepare web session")?;
+    prepare_thirtyfour(&core.ds).did("prepare web session")?;
 
   (Setup {
     core,
@@ -806,7 +806,7 @@ pub struct UsualSetup {
 impl UsualSetup {
   #[throws(AE)]
   pub fn new(exe_module_path: &str) -> UsualSetup {
-    let (mut su, inst) = setup(exe_module_path).always_context("setup")?;
+    let (mut su, inst) = setup(exe_module_path).did("usual setup")?;
     let [alice, bob] : [Window; 2] =
       su.setup_static_users(&inst)?.try_into().unwrap();
     let spec = su.ds.game_spec_data()?;
index 5cd66929a51f9b866123ba6805f322dda676ec51..026275003134f79be4ba37496cfc8d5724d4ffd1 100644 (file)
@@ -36,7 +36,7 @@ impl Ctx {
       }
       Ok::<_,AE>(())
     })()
-      .context(desc).context("check link")?
+      .context(desc).did("check link")?
   }
 
   #[throws(AE)]
@@ -51,7 +51,7 @@ impl Ctx {
       self.check_link(desc, Some(url))?;
       Ok::<_,AE>(())
     })()
-      .context(desc).context("test link")?
+      .context(desc).did("test link")?
   }
 
   #[throws(AE)]
@@ -61,7 +61,7 @@ impl Ctx {
       self.check_link(desc, None)?;
       Ok::<_,AE>(())
     })()
-      .context(desc).context("test remove link")?
+      .context(desc).did("test remove link")?
   }
 }
 
@@ -117,7 +117,8 @@ fn tests(UsualSetup { su, alice, ..}: UsualSetup) {
       .click_and_hold()
       .move_w(&alice, p2)?
       .release()
-      .perform()?;
+      .perform()
+      .did("click and hold while paused")?;
 
     let got_p2 = p.posg()?;
     assert_eq!(p2, got_p2);
index 008e5aa61e1d33e06a6a7c092dc71427c042d7bd..9a0014b982c68d6b3b672d0951943a214c9c41f2 100644 (file)
@@ -57,20 +57,20 @@ impl Ctx {
         .move_pos(&hand)?
         .click()
         .perform()
-        .context("select hand")?;
+        .did("select hand")?;
       w.synch()?;
 
       w.action_chain()
         .key_down('C')
         .key_up('C')
         .perform()
-        .context("claim hand")?;
+        .did("claim hand")?;
       w.synch()?;
 
       w.action_chain()
         .click()
         .perform()
-        .context("deselect")?;
+        .did("deselect")?;
 
       chk(&mut w, HAND, Some(ALICE))?;
 
@@ -112,19 +112,19 @@ impl Ctx {
         .move_pos(&hand)?
         .click()
         .perform()
-        .context("select hand")?;
+        .did("select hand")?;
       w.synch()?;
 
       w.action_chain()
         .key_down('C')
         .key_up('C')
         .perform()
-        .context("unclaim hand")?;
+        .did("unclaim hand")?;
 
       w.action_chain()
         .click()
         .perform()
-        .context("deselect")?;
+        .did("deselect")?;
 
       chk(&mut w, HAND, None)?;
     }
index 8c8f487ca30516d2ebbf0e438affc3fc0bce8848..896d8644b9c7d65b3adca70b039a0e73f1b1bc15 100644 (file)
@@ -71,7 +71,7 @@ impl Ctx {
         .key_down('l')
         .key_up('l')
         .perform()
-        .always_context("rotate")?;
+        .did("rotate")?;
 
       chk(&w)?;
       w.synch()?;
@@ -111,7 +111,7 @@ impl Ctx {
         .move_w(&w, try_end)?
         .release()
         .perform()
-        .always_context("drag off")?;
+        .did("drag off")?;
 
       w.synch()?;
       chk(&w, exp_end)?;
@@ -145,7 +145,7 @@ impl Ctx {
         .click()
         .release()
         .perform()
-        .always_context("unselect by clicking elsewhere")?;
+        .did("unselect by clicking elsewhere")?;
 
       chk(&w)?;
       w.synch()?;
@@ -190,7 +190,7 @@ impl Ctx {
         .click()
         .click()
         .perform()
-        .context("select and release")?;
+        .did("select and release")?;
 
       w.synch()?;
 
@@ -219,7 +219,7 @@ impl Ctx {
         .release()
 
         .perform()
-        .context("conflicting drag")?;
+        .did("conflicting drag")?;
     }
 
     paused.resume()?;
@@ -275,9 +275,9 @@ fn tests(UsualSetup { su, alice, bob, spec, ..}: UsualSetup) {
   test!(c, "drag", c.drag()?);
 
   test!(c, "drag-rotate-unselect", {
-    let pc = c.rotate().always_context("rotate")?;
-    c.drag_off(pc).always_context("drag off")?;
-    c.unselect(pc).always_context("unselect")?;
+    let pc = c.rotate().did("rotate")?;
+    c.drag_off(pc).did("drag off")?;
+    c.unselect(pc).did("unselect")?;
   });
 
   test!(c, "conflict", c.conflict()?);