From adce0f389ce71c705cb3778e1c0025ddb1c01b3f Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Wed, 10 Feb 2021 19:13:56 +0100 Subject: [PATCH] Compute the right test number at runtime --- firmware/defmt-test/macros/src/lib.rs | 35 ++++++++++++++++++++------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/firmware/defmt-test/macros/src/lib.rs b/firmware/defmt-test/macros/src/lib.rs index 0346d87b..21d65dae 100644 --- a/firmware/defmt-test/macros/src/lib.rs +++ b/firmware/defmt-test/macros/src/lib.rs @@ -167,7 +167,6 @@ fn tests_impl(args: TokenStream, input: TokenStream) -> parse::Result parse::Result parse::Result ! { + #declare_test_count #init_expr + + let mut __defmt_test_number: usize = 1; #( - defmt::info!(#unit_test_running); - #unit_test_calls + #(#test_cfgs)* + { + defmt::info!(#unit_test_running, __defmt_test_number, __DEFMT_TEST_COUNT); + #unit_test_calls + __defmt_test_number += 1; + } )* defmt::info!("all tests passed!");