From: Ian Jackson Date: Fri, 29 Jan 2021 19:09:22 +0000 (+0000) Subject: wdt: wip test selection X-Git-Tag: otter-0.4.0~649 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=d59292a15a4a4952566c701f337c09657e019f4b;p=otter.git wdt: wip test selection This is very incomplete but it doesn't cause any *trouble* per se. Signed-off-by: Ian Jackson --- diff --git a/wdriver.rs b/wdriver.rs index 3ac7379a..e49f2bd8 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -930,7 +930,32 @@ fn check_window_name_sanity(name: &str) -> &str { name } +#[macro_export] +macro_rules! test { + ($c:expr, $tname:expr, $s:stmt) => { + if $c.su.want_test($tname) { + debug!("{} starting", $tname); + $s + info!("{} completed", $tname); + } else { + trace!("{} skipped", $tname); + } + } +} + +#[macro_export] +macro_rules! ctx_with_setup { + {$ctx:ident} => { + impl Deref for $ctx { + type Target = self::Setup; + fn deref(&self) -> &self::Setup { &self.su } + } + } +} + impl Setup { + pub fn want_test(&self, _tname: &str) -> bool { true } + #[throws(AE)] pub fn new_window<'s>(&'s mut self, instance: &Instance, name: &str) -> Window { diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index e43a9c8d..46f4c200 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -10,6 +10,7 @@ struct Ctx { bob: Window, spec: otter::spec::GameSpec, } +ctx_with_setup!{Ctx} impl Ctx { #[throws(AE)] @@ -228,10 +229,14 @@ fn main(){ let mut c = Ctx { su, alice, bob, spec }; - c.drag().always_context("drag")?; - let pc = c.rotate().always_context("rotate")?; - c.drag_off(pc).always_context("drag off")?; - c.unselect(pc).always_context("unselect")?; + test!(c, "drag", c.drag().always_context("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")?; + }); + c.conflict().always_context("conflict handling")?; debug!("finishing");