From dee2ccf79f43480203baed7a1c290745bdcc9eff Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Sat, 14 Mar 2026 15:45:06 +0100 Subject: [PATCH] Use std::path::MAIN_SEPARATOR_STR to convert module name to path This makes the path separator consistent on windows. While the forward slash works it does apparently show up and is confusing to users. Fixes #16 --- src/macros.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/macros.rs b/src/macros.rs index 8d7f3eb..c79296e 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -87,7 +87,9 @@ macro_rules! testdir { $crate::init_testdir!(); let module_path = ::std::module_path!(); let test_name = $crate::private::extract_test_name(&module_path); - let subdir_path = ::std::path::Path::new(&module_path.replace("::", "/")).join(&test_name); + let subdir_path = + ::std::path::Path::new(&module_path.replace("::", ::std::path::MAIN_SEPARATOR_STR)) + .join(&test_name); $crate::with_testdir(move |tdir| { tdir.create_subdir(subdir_path) .expect("Failed to create test-scoped sub-directory") @@ -96,7 +98,9 @@ macro_rules! testdir { ( ModuleScope ) => {{ $crate::init_testdir!(); let module_path = ::std::module_path!(); - let subdir_path = ::std::path::Path::new(&module_path.replace("::", "/")).join("mod"); + let subdir_path = + ::std::path::Path::new(&module_path.replace("::", ::std::path::MAIN_SEPARATOR_STR)) + .join("mod"); $crate::with_testdir(move |tdir| { tdir.create_subdir(subdir_path) .expect("Failed to create module-scoped sub-directory")