use macro to log, execute test and handle error

pull/409/head
abhijeetbhagat 2 years ago
parent 5b3e0ee856
commit 638cf514fb

@ -24,6 +24,15 @@ enum Command {
List List
} }
macro_rules! exec_test {
($test:expr) => {{
info!("Running {}", $test.name);
if let Err(e) = ($test.test_fn)() {
panic!("{}", e)
}
}};
}
fn main() -> anyhow::Result<()> { fn main() -> anyhow::Result<()> {
env_logger::init(); env_logger::init();
@ -35,19 +44,13 @@ fn main() -> anyhow::Result<()> {
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()) {
info!("Running {}", t.name); exec_test!(t)
if let Err(e) = (t.test_fn)() {
panic!("{}", e)
}
} }
} }
} }
None => { None => {
for t in inventory::iter::<IntegrationTest> { for t in inventory::iter::<IntegrationTest> {
info!("Running {}", t.name); exec_test!(t)
if let Err(e) = (t.test_fn)() {
panic!("{}", e)
}
} }
} }
} }

Loading…
Cancel
Save