From cf3afc49b40978bd1085e4640e99d315889e6c94 Mon Sep 17 00:00:00 2001 From: Jakob Jungreuthmayer <116195279+jakobjung10@users.noreply.github.com> Date: Sat, 9 May 2026 00:13:17 +0200 Subject: [PATCH] json: field added + added field for full test name (current name field only exposes flat names) --- CHANGELOG.md | 6 ++++++ macros/src/attributes/tests/codegen/export_sym.rs | 5 ++++- macros/src/attributes/tests/codegen/test.rs | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4df749..cac4ef2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- ELF test metadata now keeps `name` as the legacy flat leaf test name for compatibility, + and adds `full_name` with the canonical module-qualified path (e.g. `tests::my_test`) + to match libtest/rust-analyzer filtering semantics. + ## [0.7.1] ### Added diff --git a/macros/src/attributes/tests/codegen/export_sym.rs b/macros/src/attributes/tests/codegen/export_sym.rs index 1a898eb..bd4f978 100644 --- a/macros/src/attributes/tests/codegen/export_sym.rs +++ b/macros/src/attributes/tests/codegen/export_sym.rs @@ -6,6 +6,7 @@ use std::hash::{DefaultHasher, Hash as _, Hasher as _}; pub(crate) fn export_sym( test: &TestFunc, + module_name: &str, ident_entrypoint: Ident, default_timeout: Option, ) -> proc_macro2::TokenStream { @@ -38,10 +39,12 @@ pub(crate) fn export_sym( } else { // Generate a symbol name which is actually a JSON object describing the test so that probe-rs can parse it. + let full_test_name = format!("{}::{}", module_name, test_name); let sym_name = format!( - r#"{{"disambiguator":{},"name":"{}","ignored":{},"should_panic":{}{}}}"#, + r#"{{"disambiguator":{},"name":"{}","full_name":"{}","ignored":{},"should_panic":{}{}}}"#, _crate_local_disambiguator(), // disambiguator is needed to allow multiple identical test in different modules _json_escape(&test_name.to_string()), + _json_escape(&full_test_name), if ignore { "true" } else { "false" }, if should_panic { "true" } else { "false" }, if let Some(timeout) = timeout { diff --git a/macros/src/attributes/tests/codegen/test.rs b/macros/src/attributes/tests/codegen/test.rs index 911b9a9..fee64db 100644 --- a/macros/src/attributes/tests/codegen/test.rs +++ b/macros/src/attributes/tests/codegen/test.rs @@ -39,7 +39,12 @@ pub(crate) fn test(test: &TestFunc, module: &ValidatedModule) -> TokenStream { ); // A static symbol that will be exported that describes the test and can be parsed by probe-rs. - let sym = export_sym(test, ident_entrypoint, module.macro_args.default_timeout); + let sym = export_sym( + test, + &module.module_name, + ident_entrypoint, + module.macro_args.default_timeout, + ); quote! {