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 <noreply@anthropic.com>
This commit is contained in:
1 parent
4e56c15505
commit
852b021a5f
2 files changed
+9
-1
No files matched your search
@@ -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.
|
||||
@@ -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); }
|
||||
|
||||
|
||||
Reference in new issue
Block a user