From fcb9d04d9e5039171b1758eab470bee482bd785a Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 26 Aug 2024 21:29:00 +0000 Subject: [PATCH] add program argument for functional testing; simplify execute argument Signed-off-by: Jason Volk --- src/core/config/mod.rs | 5 ++++- src/main/clap.rs | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index b7708760..6acb814a 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -1,5 +1,5 @@ use std::{ - collections::BTreeMap, + collections::{BTreeMap, BTreeSet}, fmt, net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, path::PathBuf, @@ -361,6 +361,9 @@ pub struct Config { #[serde(default)] pub tokio_console: bool, + #[serde(default)] + pub test: BTreeSet, + #[serde(flatten)] #[allow(clippy::zero_sized_map_values)] // this is a catchall, the map shouldn't be zero at runtime catchall: BTreeMap, diff --git a/src/main/clap.rs b/src/main/clap.rs index 56d614a4..3af0be02 100644 --- a/src/main/clap.rs +++ b/src/main/clap.rs @@ -28,6 +28,10 @@ pub(crate) struct Args { /// Execute console command automatically after startup. #[arg(long)] pub(crate) execute: Vec, + + /// Set functional testing modes if available. Ex '--test=smoke' + #[arg(long, hide(true))] + pub(crate) test: Vec, } /// Parse commandline arguments into structured data @@ -44,9 +48,10 @@ pub(crate) fn update(mut config: Figment, args: &Args) -> Result { } // Execute commands after any commands listed in configuration file - for command in &args.execute { - config = config.adjoin(("admin_execute", [command])); - } + config = config.adjoin(("admin_execute", &args.execute)); + + // Update config with names of any functional-tests + config = config.adjoin(("test", &args.test)); // All other individual overrides can go last in case we have options which // set multiple conf items at once and the user still needs granular overrides.