From 4c0560717cd20c54e3e524fe06164697ecdc4d32 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 30 Dec 2020 12:33:22 +0000 Subject: [PATCH] easier to reuse stuff from formal tests Signed-off-by: Ian Jackson --- src/config.rs | 9 ++++++++- wdriver.rs | 2 ++ wdriver/wdt-simple.rs | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 416e15e3..00221494 100644 --- a/src/config.rs +++ b/src/config.rs @@ -19,6 +19,7 @@ pub const DAEMON_STARTUP_REPORT : &str = "otter-daemon started"; #[derive(Deserialize,Debug,Clone)] pub struct ServerConfigSpec { + pub change_directory: Option, pub base_dir: Option, pub save_dir: Option, pub command_socket: Option, @@ -66,13 +67,19 @@ impl TryFrom for WholeServerConfig { #[throws(Self::Error)] fn try_from(spec: ServerConfigSpec) -> WholeServerConfig { let ServerConfigSpec { - base_dir, save_dir, command_socket, debug, + change_directory, base_dir, save_dir, command_socket, debug, http_port, public_url, sse_wildcard_url, rocket_workers, template_dir, nwtemplate_dir, wasm_dir, log, bundled_sources, shapelibs, sendmail, debug_js_inject_file, } = spec; + if let Some(cd) = change_directory { + env::set_current_dir(&cd) + .context(cd) + .context("config change_directory")?; + } + let defpath = |specd: Option, leaf: &str| -> String { specd.unwrap_or_else(|| match &base_dir { Some(base) => format!("{}/{}", &base, &leaf), diff --git a/wdriver.rs b/wdriver.rs index a77a5cfb..72e019f6 100644 --- a/wdriver.rs +++ b/wdriver.rs @@ -225,6 +225,7 @@ impl Substitutor for DirSubst { "url" => URL.to_owned(), "src" => self.src.clone(), "build" => self.start_dir.clone(), + "abstmp" => self.abstmp.clone(), "target" => format!("{}/target", &self.start_dir), "specs" => format!("{}/specs" , &self.src ), _ => return None, @@ -534,6 +535,7 @@ fn prepare_gameserver(cln: &cleanup_notify::Handle, ds: &DirSubst) ("command_socket", "command.socket"), ]); let config = subst.subst(r##" +change_directory = "@abstmp@" base_dir = "@build@" public_url = "@url@" diff --git a/wdriver/wdt-simple.rs b/wdriver/wdt-simple.rs index 9d060237..d7e55e1f 100644 --- a/wdriver/wdt-simple.rs +++ b/wdriver/wdt-simple.rs @@ -4,6 +4,10 @@ use otter_webdriver_tests::*; +// Reuse this setup, after a test: +// target/debug/daemon-otter tmp/wdt-simple/server-config.toml +// http://localhost:8000/?kmqAKPwK4TfReFjMor8MJhdRPBcwIBpe + #[throws(AE)] fn main(){ { -- 2.30.2