}
#[throws(AE)]
- pub fn otter<S:AsRef<str>>(&self, xargs: &[S]) {
+ pub fn otter<'s,S>(&self, xargs: &'s [S])
+ where &'s S: Into<String>
+ {
+ self.otter_rctx(&default(), xargs)?
+ }
+
+ #[throws(AE)]
+ pub fn otter_rctx<'s,S>(&self, rctx: &ResolveContext, xargs: &'s [S])
+ where &'s S: Into<String>
+ {
let ds = self;
let exe = ds.subst("@target@/debug/otter")?;
let specs = self.subst("@src@/specs")?;
- let mut args: Vec<&str> = vec![];
- args.extend(&["--config", CONFIG]);
- args.extend(&["--spec-dir", &specs]);
- args.extend(xargs.iter().map(AsRef::as_ref));
+ let mut args: Vec<String> = vec![];
+ args.push("--config" .to_owned()); args.push(rctx.resolve(&CONFIG));
+ args.push("--spec-dir".to_owned()); args.push(rctx.resolve(&specs) );
+ args.extend(xargs.iter().map(|s| s.into()));
let dbg = format!("running {} {:?}", &exe, &args);
debug!("{}", &dbg);
(||{
}
#[throws(AE)]
-pub fn prepare_game(ds: &DirSubst, table: &str) -> InstanceName {
+pub fn prepare_game(ds: &DirSubst, rctx: &ResolveContext, table: &str)
+ -> InstanceName {
let game_spec = ds.game_spec_path()?;
let subst = ds.also(&[
- ("table", table),
- ("game_spec", &game_spec),
+ ("table", table.to_owned()),
+ ("game_spec", rctx.resolve(&game_spec)),
]);
- ds.otter(&subst.ss(
+ ds.otter_rctx(rctx, &subst.ss(
"--account server: \
reset \
--reset-table @specs@/test.table.toml \
);
let instance_name =
- prepare_game(&ds, TABLE).context("setup game")?;
+ prepare_game(&ds, &default(), TABLE).context("setup game")?;
let wanted_tests = opts.tests.track();
spec: GameSpec,
alice: Player,
bob: Player,
+ rctx: ResolveContext,
}
impl Ctx {
["--account", "server:"].iter().cloned().map(Into::into)
.chain(args.iter().map(|s| s.as_ref().to_owned()))
.collect();
- self.su().ds.otter(&args)?;
+ self.su().ds.otter_rctx(&self.rctx, &args)?;
}
#[throws(AE)]
fn library_load(&mut self) {
- prepare_game(&self.su().ds, TABLE)?;
+ prepare_game(&self.su().ds, &self.rctx, TABLE)?;
let command = self.su().ds.ss(
"library-add @table@ wikimedia chess-blue-?"
#[throws(AE)]
fn hidden_hand(&mut self) {
- prepare_game(&self.su().ds, TABLE)?;
+ prepare_game(&self.su().ds, &default(), TABLE)?;
let mut alice = self.connect_player(&self.alice)?;
let mut bob = self.connect_player(&self.bob)?;
self.su_mut().mgmt_conn().fakerng_load(&[&"1",&"0"])?;
drop(mc);
let su_rc = Rc::new(RefCell::new(su));
- tests(Ctx { opts, spec, su_rc, alice, bob })?;
+ tests(Ctx { opts, spec, su_rc, alice, bob, rctx: default() })?;
}
info!("ok");
}