From 852b021a5f5b9a4f013ed716558eacb18afa1574 Mon Sep 17 00:00:00 2001 From: selikhov Date: Sat, 3 Oct 2026 06:56:07 +0300 Subject: [PATCH] tsclientlib: keep its tests from failing in a chain on test order The tests share a tracing setup in a Lazy that called init(). When the quickcheck test ran first, its logging (use_logging) had already installed a log logger, init() panicked with SetLoggerError, the Lazy was poisoned and every later test of the binary failed. Use try_init(). Recorded as local patch 10 in UPSTREAM.md. Co-Authored-By: Claude Opus 5.5 --- crates/proto/UPSTREAM.md | 4 ++++ crates/proto/tsclientlib/src/tests.rs | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/proto/UPSTREAM.md b/crates/proto/UPSTREAM.md index c6dfab0..e7aa7fb 100644 --- a/crates/proto/UPSTREAM.md +++ b/crates/proto/UPSTREAM.md @@ -78,3 +78,7 @@ against or offered back to upstream. "Voelin patch"). TeamSpeak 6 sends some times, e.g. `datetime` of `notifyfilelist`, in milliseconds, which failed to parse and dropped the whole message (empty file lists). Values from 10^11 on (year 5138 in seconds) are taken as milliseconds. +10. **Test logger** (`tsclientlib/src/tests.rs`, "Voelin patch"). The tests' shared + tracing setup used `init`, which panics when quickcheck (`use_logging`) has + already installed a `log` logger; the panic poisoned the `Lazy` and failed every + later test of the binary, depending on test order. It uses `try_init` now. diff --git a/crates/proto/tsclientlib/src/tests.rs b/crates/proto/tsclientlib/src/tests.rs index d5752e8..8e44234 100644 --- a/crates/proto/tsclientlib/src/tests.rs +++ b/crates/proto/tsclientlib/src/tests.rs @@ -2,7 +2,11 @@ use once_cell::sync::Lazy; use ts_bookkeeping::messages::s2c::InMessage; use tsproto_packets::packets::{Direction, Flags, OutPacket, PacketType}; -static TRACING: Lazy<()> = Lazy::new(|| tracing_subscriber::fmt().with_test_writer().init()); +// Voelin patch: `try_init`. quickcheck's logging installs a `log` logger, after +// which `init` panics, poisons this `Lazy` and fails every test that follows. +static TRACING: Lazy<()> = Lazy::new(|| { + let _ = tracing_subscriber::fmt().with_test_writer().try_init(); +}); pub(crate) fn create_logger() { Lazy::force(&TRACING); }