Keep stage/reason classification in the Journal Feature without changing frozen input, metadata or fallback behavior. Exercise connection, Host read failures, size budget and secret-bearing fixtures through compaction persistence. Validation: old freeze function with new tests fails connection and snapshot/size diagnostics (3 failures); new code passes all six selected cases and cargo test -p worker. Serialization is currently unreachable for the derived JSON-safe snapshot fields; no artificial runtime failure is claimed.
34 lines
950 B
Rust
34 lines
950 B
Rust
use std::io::{self, Write};
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
/// Per-test warning capture; never installs a global subscriber or writes fixture secrets.
|
|
#[derive(Clone, Default)]
|
|
pub struct CapturedWarnings(Arc<Mutex<Vec<u8>>>);
|
|
|
|
impl CapturedWarnings {
|
|
pub fn subscriber(&self) -> impl tracing::Subscriber + Send + Sync + 'static {
|
|
let output = self.clone();
|
|
tracing_subscriber::fmt()
|
|
.with_writer(move || output.clone())
|
|
.without_time()
|
|
.with_ansi(false)
|
|
.with_max_level(tracing::Level::WARN)
|
|
.finish()
|
|
}
|
|
|
|
pub fn text(&self) -> String {
|
|
String::from_utf8(self.0.lock().unwrap().clone()).unwrap()
|
|
}
|
|
}
|
|
|
|
impl Write for CapturedWarnings {
|
|
fn write(&mut self, bytes: &[u8]) -> io::Result<usize> {
|
|
self.0.lock().unwrap().extend_from_slice(bytes);
|
|
Ok(bytes.len())
|
|
}
|
|
|
|
fn flush(&mut self) -> io::Result<()> {
|
|
Ok(())
|
|
}
|
|
}
|