chiark / gitweb /
apitest: Provide UsualCtx::ds
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 May 2021 18:39:52 +0000 (19:39 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 21 May 2021 18:39:52 +0000 (19:39 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/at-bundles.rs
apitest/at-otter.rs
apitest/main.rs

index e1d057774e18951063dbecce16a57b19940f9acc..3fbf195e8bef2f33a4310a8b6af5cc2376f8d36c 100644 (file)
@@ -20,7 +20,7 @@ impl Ctx {
       "big-bundle","duped-example", "chess-purple-cannon", "a purple cannon",
       &mut |ctx|
     {
-      let cmd = ctx.su().ds.gss("reset modded-spec")?;
+      let cmd = ctx.ds().gss("reset modded-spec")?;
       ctx.reset_game(&cmd)?;
 
       let alice = ctx.connect_player(&ctx.alice)?;
@@ -50,7 +50,7 @@ impl Ctx {
   fn reset_with_bundles(&mut self) {
     self.clear_reset_to_demo()?;
 
-    let cmd = self.su().ds.gss(
+    let cmd = self.ds().gss(
       "reset demo-in-test-bundle @examples@/test-bundle.zip"
     )?;
     self.reset_game(&cmd)?;
index 2b80e81bbc0b95fabf75518e998100277d6234f8..bbcba3d1f02654f371167745b86c81264172dfe5 100644 (file)
@@ -11,7 +11,7 @@ impl Ctx {
   fn library_load(&mut self) {
     self.prepare_game()?;
 
-    let command = self.su().ds.gss(
+    let command = self.ds().gss(
       "library-list chess-yellow-?"
     )?;
     let output: String = self.otter(&command)?.into();
@@ -20,7 +20,7 @@ impl Ctx {
              .is_some(),
              "got: {}", &output);
 
-    let command = self.su().ds.gss(
+    let command = self.ds().gss(
       "library-add --lib wikimedia chess-blue-?"
     )?;
     let added = self.some_library_add(&command)?;
@@ -145,7 +145,7 @@ impl Ctx {
     assert_eq!(b_pieces[b_pawns[1]].pos,
                a_pieces[a_pawns[0]].pos);
 
-    let command = self.su().ds.gss("reset demo")?;
+    let command = self.ds().gss("reset demo")?;
     self.reset_game(&command)?;
   }
 
@@ -162,7 +162,7 @@ impl Ctx {
       }
     }
     let specs = |mid, def| {
-      let sv = self.su().ds.also(&[("mid",mid),("def",def)]);
+      let sv = self.ds().also(&[("mid",mid),("def",def)]);
       let def = sv.subst("@specs@/@def@.@mid@.toml").unwrap();
       let pat = sv.subst("@specs@/*.@mid@.toml").unwrap();
       let ents = glob::glob(&pat).unwrap()
@@ -176,7 +176,7 @@ impl Ctx {
       let (py, perm) = perms.next();
       let (gy, game) = games.next();
       if !(py || gy) { break }
-      let command = self.su().ds.also(&[("game",&game),("perm",&perm)])
+      let command = self.ds().also(&[("game",&game),("perm",&perm)])
         .gss("reset --reset-table @perm@ @game@")?;
       self.reset_game(&command).context(perm).context(game)?;
     }
index 964c4f6137622b7be45564ed1292ac725908f209..fba1923c10dcac94978c61a4b055e9d4f00867f1 100644 (file)
@@ -30,6 +30,7 @@ struct UsualCtx {
 impl UsualCtx {
   pub fn su(&self) -> std::cell::Ref<SetupCore>{ RefCell::borrow(&self.su_rc) }
   pub fn su_mut(&self) -> RefMut<SetupCore> { self.su_rc.borrow_mut() }
+  pub fn ds(&self) -> DirSubst { RefCell::borrow(&self.su_rc).ds.clone() }
 
   pub fn wanted_tests(&self) -> TrackWantedTestsGuard {
     TrackWantedTestsGuard(self.su_mut())