From 8513bb8dc4531aaa5d381cbc987694cbfc33937c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=B8rl=C3=BCck=20Berg?= <36937807+henrikhorluck@users.noreply.github.com> Date: Sun, 24 May 2026 13:19:33 +0200 Subject: [PATCH] Fix `Principal topic monitor not initialized` in `test_path_normalize_for_cd` This happens when running the tests using `cargo nextest run`, where each test runs in its own process, but does not happen with normal `cargo test`. Fix by avoiding eprintf!, which can reach SigChecker::check. Instead use a custom panic-message. --- src/wutil/mod.rs | 64 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/src/wutil/mod.rs b/src/wutil/mod.rs index c64c01134..94729887d 100644 --- a/src/wutil/mod.rs +++ b/src/wutil/mod.rs @@ -476,50 +476,65 @@ mod test_path_normalize_for_cd { fn relative_path() { let wd = L!("/home/user/"); let path = L!("projects"); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user/projects")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/home/user/projects"), + "Normalized path for ({wd}, {path})" + ); } #[test] fn absolute_path() { let wd = L!("/home/user/"); let path = L!("/etc"); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/etc")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/etc"), + "Normalized path for ({wd}, {path})" + ); } #[test] fn parent_directory() { let wd = L!("/home/user/projects/"); let path = L!("../docs"); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user/docs")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/home/user/docs"), + "Normalized path for ({wd}, {path})" + ); } #[test] fn current_directory() { let wd = L!("/home/user/"); let path = L!("./"); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/home/user"), + "Normalized path for ({wd}, {path})" + ); } #[test] fn nested_parent_directory() { let wd = L!("/home/user/projects/"); let path = L!("../../"); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/home")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/home"), + "Normalized path for ({wd}, {path})" + ); } #[test] fn complex_path() { let wd = L!("/home/user/projects/"); let path = L!("./../other/projects/./.././../docs"); - eprintf!("(%s, %s)\n", wd, path); assert_eq!( path_normalize_for_cd(wd, path), - L!("/home/user/other/projects/./.././../docs") + L!("/home/user/other/projects/./.././../docs"), + "Normalized path for ({wd}, {path})" ); } @@ -527,34 +542,43 @@ fn complex_path() { fn root_directory() { let wd = L!("/"); let path = L!(".."); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/..")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/.."), + "Normalized path for ({wd}, {path})" + ); } #[test] fn up_to_root_directory() { let wd = L!("/foo/"); let path = L!(".."); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/"), + "Normalized path for ({wd}, {path})" + ); } #[test] fn empty_path() { let wd = L!("/home/user/"); let path = L!(""); - eprintf!("(%s, %s)\n", wd, path); - assert_eq!(path_normalize_for_cd(wd, path), L!("/home/user/")); + assert_eq!( + path_normalize_for_cd(wd, path), + L!("/home/user/"), + "Normalized path for ({wd}, {path})" + ); } #[test] fn trailing_slash() { let wd = L!("/home/user/projects/"); let path = L!("docs/"); - eprintf!("(%s, %s)\n", wd, path); assert_eq!( path_normalize_for_cd(wd, path), - L!("/home/user/projects/docs/") + L!("/home/user/projects/docs/"), + "Normalized path for ({wd}, {path})" ); } }