chiark / gitweb /
apitest: Make SetupCore part of wdriver::Setup
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Feb 2021 22:45:30 +0000 (22:45 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 21 Feb 2021 22:45:43 +0000 (22:45 +0000)
NFC

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest.rs
wdriver.rs

index 14a112b656339bc58b3b55884cfa23091a74cfbd..55c980fc0ab06451647c1007c9e0a0a59713a78b 100644 (file)
@@ -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,
index 4646d5576986cb24f9b60de05007dd3ad580fc27..9773fb644bb6c98d8a15198a09020adfb2f98eef 100644 (file)
@@ -47,10 +47,7 @@ type WindowState = Option<String>;
 #[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<String>, // 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,