Fix Principal topic monitor not initialized panic

Like 1b16d318cc, reproduces with `cargo test test_pthread`

Fix by using stdlib `println!` to avoid interacting with topicMonitor.

Enable `allow-print-in-tests` like with crates/printf, such that there i
no deny-warning.
This commit is contained in:
Henrik Hørlück Berg
2026-05-24 13:49:21 +02:00
committed by Peter Ammon
parent 8dee291200
commit 79bf53aaa5
3 changed files with 6 additions and 3 deletions

View File

@@ -233,6 +233,8 @@ unused_trait_names = "warn"
# In the future, they might change to flag other methods of printing.
print_stdout = "deny"
print_stderr = "deny"
# usage in tests is fine since it avoids interacting with TopicMonitor
# and is configured in clippy.toml with `allow-print-in-tests`
[lints]
workspace = true

1
clippy.toml Normal file
View File

@@ -0,0 +1 @@
allow-print-in-tests = true

View File

@@ -458,7 +458,7 @@ struct Context {
let made = spawn(move || {
ctx2.val.fetch_add(2, Ordering::Release);
ctx2.condvar.notify_one();
printf!("condvar signalled\n");
println!("condvar signalled");
});
assert!(made);
@@ -466,9 +466,9 @@ struct Context {
let (_lock, timeout) = ctx
.condvar
.wait_timeout_while(lock, Duration::from_secs(5), |()| {
printf!("looping with lock held\n");
println!("looping with lock held");
if ctx.val.load(Ordering::Acquire) != 5 {
printf!("test_pthread: value did not yet reach goal\n");
println!("test_pthread: value did not yet reach goal");
return true;
}
false