holger-estate-front/tests/the_front_keeps_its_log_on_its_disk.rs
//! ★ Gunnar 6dcbbe38 + f21d8d09 + 3eb19cd3 (2026-09-28..30), shared by lane G10: **the
//! front keeps its install log for life and on its disk, and says each listener line at
//! its level.**
//!
//! 2026-10-20: test3's front lost its boot lines — its log was `BootLog::new(DEFAULT_CAP)`
//! (no head: the install's lines were evicted by the runtime) in RAM only (a restart left
//! nothing), and the untoned `serve_installer` said every listener line at WARN. Gunnar's
//! front has kept the head, the disk copy and the tone since 2026-09-30; the pieces are now
//! nordisk-pairing's (`BootLog::for_install`, `BootLog::keep_on_disk`,
//! `boxside::serve_installer_toned`), and this front uses them.
use std::time::{Duration, Instant};
use holger_estate_front::{keep_on_disk, KEEP_REL};
use nordisk_pairing::bootlog::BootLog;
static LOG: BootLog = BootLog::for_install();
#[test]
fn the_fronts_log_is_on_its_disk_within_a_second_and_the_next_boot_serves_its_last_lines() {
let root = tempfile::tempdir().unwrap();
assert_eq!(
keep_on_disk(&LOG, root.path()),
0,
"a first boot carries nothing"
);
let marker = format!(
"2026-10-21T05:00:00.000000Z INFO holger_estate_front: logproof-{}",
std::process::id()
);
LOG.push(&marker);
let file = root.path().join(KEEP_REL);
let t = Instant::now();
while !std::fs::read_to_string(&file)
.unwrap_or_default()
.contains(&marker)
{
assert!(
t.elapsed() < Duration::from_secs(5),
"the line reached {} within its second",
file.display()
);
std::thread::sleep(Duration::from_millis(100));
}
let next = BootLog::for_install();
assert!(
next.carry_previous(
&file,
nordisk_pairing::bootlog::CARRY_LINES,
nordisk_pairing::bootlog::CARRY_BYTES
) >= 1
);
let lines = next.since(0, 2000).lines;
assert!(
lines
.iter()
.any(|l| l == &format!("(previous boot) {marker}")),
"{lines:?}"
);
}
/// **main**: the log is made with its head, kept on the disk right after the ESP's story
/// is taken (before stderr is captured, so a start-time failure is on the disk too), and
/// the listener is served toned — never the untoned `serve_installer`, whose every line
/// is a WARN.
#[test]
fn main_keeps_the_head_the_disk_copy_and_the_tone() {
let src = include_str!("../src/main.rs");
assert!(
src.contains("static BOOT_LOG: BootLog = BootLog::for_install();"),
"the log keeps its head"
);
// Read with the whitespace out: rustfmt wraps a long call where it likes.
let main: String = src[src.find("fn main()").unwrap()..]
.split_whitespace()
.collect();
let (esp, keep, stderr) = (
main.find("BOOT_LOG.capture_esp(").expect("the ESP's story"),
main.find("front::keep_on_disk(&BOOT_LOG,&front::data_root())")
.expect("main keeps its log on its disk"),
main.find("capture_stderr(&BOOT_LOG").expect("stderr"),
);
assert!(
esp < keep && keep < stderr,
"the ESP, then the disk, then stderr"
);
assert!(
src.contains("serve_installer_toned") && src.contains("serve_installer_after_close_toned"),
"the listener is toned"
);
assert!(
!src.contains("boxside::serve_installer }")
&& !src.contains("boxside::serve_installer_after_close }"),
"no untoned serve"
);
}