T04: own Unix pty so a failed chdir fails the start; closing logs and reaps
CI / platforms (windows-latest) (push) Failing after 7s
CI / macos (push) Successful in 10m0s
CI / platforms (ubuntu-24.04) (push) Canceled after 0s

This commit is contained in:
ZacharyZhang-NY committed 2026-10-14 12:08:18 -04:00
1 parent 96ae85b72c
commit fff436c8e9
8 files changed
+423 -33

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
use std::sync::{Mutex, Once};
static LINES: Mutex<Vec<String>> = Mutex::new(Vec::new());
/// Keeps every log line so tests can assert what was logged.
struct Capture;
impl log::Log for Capture {
fn enabled(&self, metadata: &log::Metadata) -> bool {
metadata.level() <= log::Level::Debug
}
fn log(&self, record: &log::Record) {
let line = record.args().to_string();
eprintln!("{} {line}", record.level());
LINES.lock().expect("the log lines").push(line);
}
fn flush(&self) {}
}
pub fn init() {
static ONCE: Once = Once::new();
ONCE.call_once(|| {
log::set_logger(&Capture).expect("the only logger in tests");
log::set_max_level(log::LevelFilter::Debug);
});
}
pub fn logged(line: &str) -> bool {
LINES
.lock()
.expect("the log lines")
.iter()
.any(|kept| kept == line)
}