From 367e1600750da1b5cf6a6e574f9c9a24cdf10e86 Mon Sep 17 00:00:00 2001 From: Teknique Date: Fri, 26 May 2023 11:51:20 -0700 Subject: [PATCH] Better run_test! macro param naming --- veilid-core/src/tests/native/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/veilid-core/src/tests/native/mod.rs b/veilid-core/src/tests/native/mod.rs index c687b1e0..e8b450a3 100644 --- a/veilid-core/src/tests/native/mod.rs +++ b/veilid-core/src/tests/native/mod.rs @@ -64,26 +64,31 @@ cfg_if! { use paste::paste; macro_rules! run_test { - ($mod:ident, $func:ident) => { + // Nearly all test runner code is cookie cutter, and copy-pasting makes it too easy to make a typo. + + // Pass in a module and test module, and we'll run its `test_all`. + ($parent_module:ident, $test_module:ident) => { paste! { #[test] #[serial] - fn []() { + fn []() { setup(); block_on(async { - $mod::tests::$func::test_all().await; + $parent_module::tests::$test_module::test_all().await; }) } } }; - ($func:ident) => { + + // Pass in a test module name, and we'll run its `test_all`. + ($test_module:ident) => { paste! { #[test] #[serial] - fn []() { + fn []() { setup(); block_on(async { - $func::test_all().await; + $test_module::test_all().await; }) } }