From: Ian Jackson Date: Sun, 21 Feb 2021 22:45:30 +0000 (+0000) Subject: apitest: Make SetupCore part of wdriver::Setup X-Git-Tag: otter-0.4.0~390 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=361fd037848658c1da843936fb644389c02769d1;p=otter.git apitest: Make SetupCore part of wdriver::Setup NFC Signed-off-by: Ian Jackson --- diff --git a/apitest.rs b/apitest.rs index 14a112b6..55c980fc 100644 --- a/apitest.rs +++ b/apitest.rs @@ -40,7 +40,7 @@ pub use std::io::{self, BufRead, BufReader, ErrorKind, Write}; pub use std::iter; pub use std::mem; pub use std::net::TcpStream; -pub use std::ops::Deref; +pub use std::ops::{Deref, DerefMut}; pub use std::os::unix::process::CommandExt; pub use std::os::unix::fs::DirBuilderExt; pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode?? @@ -107,6 +107,7 @@ pub struct Opts { pub tests: WantedTestsOpt, } +#[derive(Debug)] pub struct SetupCore { pub ds: DirSubst, pub mgmt_conn: MgmtChannel, diff --git a/wdriver.rs b/wdriver.rs index 4646d557..9773fb64 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -47,10 +47,7 @@ type WindowState = Option; #[derive(Debug)] pub struct Setup { pub opts: Opts, - pub ds: DirSubst, - pub mgmt_conn: MgmtChannel, - pub server_child: process::Child, - wanted_tests: TrackWantedTests, + pub core: SetupCore, driver: T4d, current_window: WindowState, screenshot_count: ScreenShotCount, @@ -58,6 +55,14 @@ pub struct Setup { windows_squirreled: Vec, // see Drop impl } +impl Deref for Setup { + type Target = SetupCore; + fn deref(&self) -> &SetupCore { &self.core } +} +impl DerefMut for Setup { + fn deref_mut(&mut self) -> &mut SetupCore { &mut self.core } +} + #[derive(Debug)] pub struct Window { pub name: String, @@ -665,14 +670,10 @@ impl Drop for Setup { #[throws(AE)] pub fn setup(exe_module_path: &str) -> (Setup, Instance) { - let (opts, cln, instance, apitest::SetupCore { - ds, - mgmt_conn, - server_child, - wanted_tests - }) = apitest::setup_core(&[exe_module_path, "otter_webdriver_tests"])?; + let (opts, cln, instance, core) = + apitest::setup_core(&[exe_module_path, "otter_webdriver_tests"])?; - prepare_xserver(&cln, &ds).always_context("setup X server")?; + prepare_xserver(&cln, &core.ds).always_context("setup X server")?; let final_hook = FinalInfoCollection; @@ -681,12 +682,9 @@ pub fn setup(exe_module_path: &str) -> (Setup, Instance) { prepare_thirtyfour().always_context("prepare web session")?; (Setup { - ds, - mgmt_conn, - server_child, + core, driver, opts, - wanted_tests, screenshot_count, current_window: None, windows_squirreled,