pub pause: humantime::Duration,
#[structopt(flatten)]
- pub tests: WantedTests,
+ pub tests: WantedTestsOpt,
}
#[derive(Clone,Debug)]
#[derive(StructOpt)]
-pub struct WantedTests {
- pub tests: Vec<String>,
+pub struct WantedTestsOpt {
+ tests: Vec<String>,
+}
+
+#[derive(Debug)]
+pub struct TrackWantedTests {
+ wanted: WantedTestsOpt,
+ found: BTreeSet<String>,
+}
+
+impl WantedTestsOpt {
+ pub fn track(&self) -> TrackWantedTests {
+ TrackWantedTests { wanted: self.clone(), found: default() }
+ }
+}
+
+impl TrackWantedTests {
+ pub fn wantp(&mut self, tname: &str) -> bool {
+ self.found.insert(tname.to_owned());
+ let y =
+ self.wanted.tests.is_empty() ||
+ self.wanted.tests.iter().any(|s| s==tname);
+ y
+ }
+}
+
+impl Drop for TrackWantedTests {
+ fn drop(&mut self) {
+ let missing_tests = self.wanted.tests.iter().cloned()
+ .filter(|s| !self.found.contains(s))
+ .collect::<Vec<_>>();
+
+ if !missing_tests.is_empty() {
+ for f in &self.found {
+ eprintln!("fyi: test that exists: {}", f);
+ }
+ for m in &missing_tests {
+ eprintln!("warning: unknown test requested: {}", m);
+ }
+ }
+ }
}
#[derive(Clone,Debug)]
pub mgmt_conn: MgmtChannel,
pub opts: Opts,
pub server_child: process::Child,
- found_tests: BTreeSet<String>,
+ wanted_tests: TrackWantedTests,
driver: T4d,
current_window: WindowState,
screenshot_count: ScreenShotCount,
impl Setup {
pub fn want_test(&mut self, tname: &str) -> bool {
- self.found_tests.insert(tname.to_owned());
- let y =
- self.opts.tests.tests.is_empty() ||
- self.opts.tests.tests.iter().any(|s| s==tname);
- y
+ self.wanted_tests.wantp(tname)
}
#[throws(AE)]
})()
.context("screenshots, in Setup::drop")
.just_warn();
-
- let missing_tests = self.opts.tests.tests.iter().cloned()
- .filter(|s| !self.found_tests.contains(s))
- .collect::<Vec<_>>();
-
- if !missing_tests.is_empty() {
- for f in &self.found_tests {
- eprintln!("fyi: test that exists: {}", f);
- }
- for m in &missing_tests {
- eprintln!("warning: unknown test requested: {}", m);
- }
- }
}
}
let (driver, screenshot_count, windows_squirreled) =
prepare_thirtyfour().always_context("prepare web session")?;
+ let wanted_tests = opts.tests.track();
+
(Setup {
ds,
mgmt_conn,
server_child,
driver,
opts,
- found_tests: default(),
+ wanted_tests,
screenshot_count,
current_window: None,
windows_squirreled,