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(())