chiark / gitweb /
apitest: Consolidate reset_game and provide in UsualCtx
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 18 May 2021 00:02:38 +0000 (01:02 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 18 May 2021 00:10:38 +0000 (01:10 +0100)
We are going to want to do some extra tracking

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-bundles.rs
apitest/at-otter.rs
apitest/main.rs

index 34c7059ddeddc82c8d0901c12be2b974f9f0fbd1..141ea1e30c33d6967888b865c60af1f677340e76 100644 (file)
@@ -45,7 +45,7 @@ impl Ctx {
     self.check_library_item("lemon","example-lemon","a lemon")?;
 
     self.otter(&ds.ss("clear-game @table@")?)?;
-    self.otter(&ds.ss("reset @table@ demo")?)?;
+    self.reset_game(&ds.ss("reset @table@ demo")?)?;
   }
 }
 
index cbb78079f526a07f525a99bbc845462953149aa6..b8b306c2b16d3a983ca1c21373787abfe3ce4fdb 100644 (file)
@@ -146,7 +146,7 @@ impl Ctx {
                a_pieces[a_pawns[0]].pos);
 
     let command = self.su().ds.ss("reset @table@ demo")?;
-    self.otter(&command)?;
+    self.reset_game(&command)?;
   }
 
   #[throws(Explode)]
@@ -178,7 +178,7 @@ impl Ctx {
       if !(py || gy) { break }
       let command = self.su().ds.also(&[("game",&game),("perm",&perm)])
         .ss("reset --reset-table @perm@ @table@ @game@")?;
-      self.otter(&command).context(perm).context(game)?;
+      self.reset_game(&command).context(perm).context(game)?;
     }
   }
 
index d230f64496d3cfb2941bd71d0f1eeda04d06cd63..955d827c6cf57f912135962a8ca2537cf8e2d8e6 100644 (file)
@@ -498,6 +498,11 @@ impl UsualCtx {
     prepare_game(&self.su().ds, &self.prctx, TABLE)?;
   }
 
+  #[throws(AE)]
+  pub fn reset_game<S:AsRef<str>>(&mut self, args: &[S]) -> OtterOutput {
+    self.otter(args)?
+  }
+
   #[throws(Explode)]
   fn some_library_add(&mut self, command: &[String]) -> Vec<String> {
     let add_err = self.otter(command)