instance
}
-// ---------- core entrypoint, for wdriver too ----------
+// ==================== post-setup facilities ====================
+
+// -------------------- static users --------------------
+
+pub struct StaticUserSetup {
+ pub nick: &'static str,
+ pub url: String,
+}
+
+impl DirSubst {
+ #[throws(AE)]
+ pub fn setup_static_users
+ <W, F: FnMut(StaticUserSetup) -> Result<W, AE>>
+ (&mut self, layout: PresentationLayout, mut f: F)
+ -> Vec<W>
+ {
+ #[throws(AE)]
+ fn mk(su: &DirSubst, layout: PresentationLayout, u: StaticUser)
+ -> StaticUserSetup
+ {
+ let nick: &str = u.into();
+ let token = u.get_str("Token").expect("StaticUser missing Token");
+ let pl = AbbrevPresentationLayout(layout).to_string();
+ let subst = su.also([
+ ("nick", nick),
+ ("token", token),
+ ("pl", &pl),
+ ].iter());
+
+ su.otter(&subst
+ .ss("--super \
+ --account server:@nick@ \
+ --fixed-token @token@ \
+ join-game server::dummy")?)?;
+ let url = subst.subst("@url@/@pl@?@token@")?;
+ StaticUserSetup { nick, url }
+ }
+
+ StaticUser::iter().map(
+ |u| (||{
+ let ssu = mk(self, layout, u).context("create")?;
+ let w = f(ssu).context("set up")?;
+ Ok::<_,AE>(w)
+ })()
+ .with_context(|| format!("{:?}", u))
+ .context("make static user")
+ )
+ .collect::<Result<Vec<W>,AE>>()?
+ }
+}
+
+// ==================== core entrypoint, for wdriver too ====================
#[throws(AE)]
pub fn setup_core<O>(module_paths: &[&str]) ->
impl Setup {
#[throws(AE)]
pub fn setup_static_users(&mut self, instance: &Instance) -> Vec<Window> {
- #[throws(AE)]
- fn mk(su: &mut Setup, instance: &Instance, u: StaticUser) -> Window {
- let nick: &str = u.into();
- let token = u.get_str("Token").expect("StaticUser missing Token");
- let pl = AbbrevPresentationLayout(su.opts.layout).to_string();
- let subst = su.ds.also([
- ("nick", nick),
- ("token", token),
- ("pl", &pl),
- ].iter());
- su.ds.otter(&subst
- .ss("--super \
- --account server:@nick@ \
- --fixed-token @token@ \
- join-game server::dummy")?)?;
- let w = su.new_window(instance, nick)?;
- let url = subst.subst("@url@/@pl@?@token@")?;
- su.w(&w)?.get(url)?;
- su.w(&w)?.screenshot("initial", log::Level::Trace)?;
- w
- }
- StaticUser::iter().map(
- |u| mk(self, instance, u)
- .with_context(|| format!("{:?}", u))
- .context("make static user")
- )
- .collect::<Result<Vec<Window>,AE>>()?
+ self.core.ds.clone().setup_static_users(self.opts.layout, |sus|{
+ let w = self.new_window(instance, sus.nick)?;
+ self.w(&w)?.get(sus.url)?;
+ self.w(&w)?.screenshot("initial", log::Level::Trace)?;
+ Ok(w)
+ })?
}
}