From c83d012c514a6a02572c43a6ff3659ca88259d37 Mon Sep 17 00:00:00 2001 From: abhijeetbhagat Date: Tue, 11 Oct 2022 22:42:58 +0530 Subject: [PATCH] preserve existing behavior and avoid changes to gh workflows/xtask --- test/integration-test/src/main.rs | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/test/integration-test/src/main.rs b/test/integration-test/src/main.rs index 5a135d3d..60744da5 100644 --- a/test/integration-test/src/main.rs +++ b/test/integration-test/src/main.rs @@ -4,16 +4,19 @@ mod tests; use tests::IntegrationTest; use clap::Parser; + #[derive(Debug, Parser)] +#[clap(author, version, about, long_about = None)] +#[clap(propagate_version = true)] pub struct RunOptions { #[clap(short, long, value_parser)] tests: Option>, } #[derive(Debug, Parser)] -struct Options { +struct Cli { #[clap(subcommand)] - command: Command, + command: Option, } #[derive(Debug, Parser)] @@ -33,13 +36,21 @@ macro_rules! exec_test { }}; } +macro_rules! exec_all_tests { + () => {{ + for t in inventory::iter:: { + exec_test!(t) + } + }}; +} + fn main() -> anyhow::Result<()> { env_logger::init(); - let cmd = Command::parse(); + let cli = Cli::parse(); - match cmd { - Command::Run(opts) => match opts.tests { + match &cli.command { + Some(Command::Run(opts)) => match &opts.tests { Some(tests) => { for t in inventory::iter:: { if tests.contains(&t.name.into()) { @@ -48,16 +59,17 @@ fn main() -> anyhow::Result<()> { } } None => { - for t in inventory::iter:: { - exec_test!(t) - } + exec_all_tests!() } }, - Command::List => { + Some(Command::List) => { for t in inventory::iter:: { info!("{}", t.name); } } + None => { + exec_all_tests!() + } } Ok(())