preserve existing behavior and avoid changes to gh workflows/xtask

pull/409/head
abhijeetbhagat 2 years ago
parent 4183c7a7d2
commit c83d012c51

@ -4,16 +4,19 @@ mod tests;
use tests::IntegrationTest; use tests::IntegrationTest;
use clap::Parser; use clap::Parser;
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
pub struct RunOptions { pub struct RunOptions {
#[clap(short, long, value_parser)] #[clap(short, long, value_parser)]
tests: Option<Vec<String>>, tests: Option<Vec<String>>,
} }
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct Options { struct Cli {
#[clap(subcommand)] #[clap(subcommand)]
command: Command, command: Option<Command>,
} }
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
@ -33,13 +36,21 @@ macro_rules! exec_test {
}}; }};
} }
macro_rules! exec_all_tests {
() => {{
for t in inventory::iter::<IntegrationTest> {
exec_test!(t)
}
}};
}
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
env_logger::init(); env_logger::init();
let cmd = Command::parse(); let cli = Cli::parse();
match cmd { match &cli.command {
Command::Run(opts) => match opts.tests { Some(Command::Run(opts)) => match &opts.tests {
Some(tests) => { Some(tests) => {
for t in inventory::iter::<IntegrationTest> { for t in inventory::iter::<IntegrationTest> {
if tests.contains(&t.name.into()) { if tests.contains(&t.name.into()) {
@ -48,16 +59,17 @@ fn main() -> anyhow::Result<()> {
} }
} }
None => { None => {
for t in inventory::iter::<IntegrationTest> { exec_all_tests!()
exec_test!(t)
}
} }
}, },
Command::List => { Some(Command::List) => {
for t in inventory::iter::<IntegrationTest> { for t in inventory::iter::<IntegrationTest> {
info!("{}", t.name); info!("{}", t.name);
} }
} }
None => {
exec_all_tests!()
}
} }
Ok(()) Ok(())

Loading…
Cancel
Save