holger-estate-front/tests/the_monetize_log_reaches_the_log_door.rs
//! **monetize's log reaches the installer's log door** (owner 2026-09-28).
//!
//! The front embeds monetize-server (feature `metered`), which logs with
//! `eprintln!` — the purchase, the grant, the webhook, every guest's `[guest …]`
//! line — and has no logger. fd 2 of PID 1 is the serial console, which the
//! log door (`cargo xtask estate logs web`) never reads; only the BootLog is
//! read. So the front must take fd 2 into the BootLog
//! (`nordisk_pairing::bootlog::capture_stderr`, the behaviour proven in
//! Skidbladnir's tests/stderr_reaches_the_boot_log.rs) BEFORE monetize or
//! tracing say anything, and hand the tracing Tap the CONSOLE it returns (a Tap
//! over `std::io::stderr()` would now feed the pipe and push every line twice).
//! This holds the wiring in `src/main.rs` to that; the mock run proves the lines.
#[test]
fn the_front_takes_fd_2_into_the_boot_log_before_anything_logs() {
let main =
std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/src/main.rs")).unwrap();
let code: String = main
.lines()
.filter(|l| !l.trim_start().starts_with("//"))
.collect::<Vec<_>>()
.join("\n");
// Read with the whitespace out: rustfmt wraps a long call where it likes.
let code: String = code.split_whitespace().collect();
let capture = code
.find("bootlog::capture_stderr(&BOOT_LOG")
.expect("main.rs takes fd 2 into the BootLog (capture_stderr)");
let tracing = code
.find("tracing_subscriber::fmt()")
.expect("main.rs starts tracing");
assert!(
capture < tracing,
"fd 2 is taken before tracing says anything"
);
assert!(!code.contains("Tap::new(&BOOT_LOG,std::io::stderr())"), "the Tap writes the console capture_stderr returns, never fd 2 (every line would be pushed twice)");
let manifest =
std::fs::read_to_string(concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml")).unwrap();
assert!(
manifest
.lines()
.any(|l| l.starts_with("nordisk-pairing") && l.contains("\"stderr-capture\"")),
"nordisk-pairing's stderr-capture feature is on"
);
}