Parcourir la source

use macro to log, execute test and handle error

abhijeetbhagat il y a 2 ans
Parent
commit
638cf514fb
1 fichiers modifiés avec 11 ajouts et 8 suppressions
  1. 11 8
      test/integration-test/src/main.rs

+ 11 - 8
test/integration-test/src/main.rs

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