Skip to content

Commit 384bd95

Browse files
committed
fix(test2): Capture names as full paths
1 parent f403743 commit 384bd95

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

crates/libtest2/src/macros.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ macro_rules! _test_parse {
110110
fn name(&self) -> &str {
111111
$crate::_private::push!(crate::TESTS, _: $crate::_private::DynCase = $crate::_private::DynCase(&$name));
112112

113-
stringify!($name)
113+
const FULL_PATH: &str = concat!(std::module_path!(), "::", stringify!($name));
114+
let i = FULL_PATH.find("::").expect("we have inserted this in the line above so it must be there");
115+
&FULL_PATH[(i+2)..]
114116
}
115117
fn kind(&self) -> $crate::_private::TestKind {
116118
Default::default()

crates/libtest2/tests/testsuite/macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ fn check() {
3030
let data = str![[r#"
3131
3232
running 2 tests
33-
test foo ... ok
34-
test foo ... ok
33+
test foo ... ok
34+
test some_module::foo ... ok
3535
36-
test result: ok. 1 passed; 0 failed; 0 ignored; 0 filtered out; finished in [..]s
36+
test result: ok. 2 passed; 0 failed; 0 ignored; 0 filtered out; finished in [..]s
3737
3838
3939
"#]];

0 commit comments

Comments
 (0)