use super::fixture::world;
use super::painted;
use crate::cli_outbound::Cli;
#[test]
fn a_driver_that_dies_after_launch_banners_on_the_sweep_that_folds_its_sink() {
let (lernie, bl) = (Cli::new("lernie"), Cli::new("bl"));
let mut world = world();
let ws = world.ws.clone();
world.model.focus_agent(&ws, "c-1");
crate::opslog::append(
world.model.state_root(),
&crate::opslog::OpEntry {
ts: "17".into(),
argv: vec![
"lernie".into(),
"prompt".into(),
ws.to_string_lossy().into_owned(),
"yo".into(),
],
cwd: ws.to_string_lossy().into_owned(),
exit: crate::opslog::DETACHED_EXIT,
stdout: String::new(),
stderr: String::new(),
origin: crate::opslog::Origin::Conversation,
},
)
.unwrap();
world.model.after_lernie_verb();
world.converge();
let quiet = painted(&mut world, &lernie, &bl);
assert!(
!quiet.contains("was retired"),
"a live launch is not a failure:\n{quiet}"
);
let sink = crate::opslog::detached::sink(world.model.state_root(), "17", &ws);
std::fs::create_dir_all(sink.parent().unwrap()).unwrap();
std::fs::write(&sink, "lernie prompt: config: action was retired\n").unwrap();
world.model.after_lernie_verb();
world.converge();
let banner = painted(&mut world, &lernie, &bl);
assert!(
banner.contains("was retired"),
"the dead driver's stderr tail reaches the paint layer:\n{banner}"
);
assert!(
banner.contains("⚠ lernie prompt"),
"with the attempted argv:\n{banner}"
);
}
#[test]
fn a_driver_notice_on_the_sink_reaches_the_trail_without_alarming_the_window() {
let (lernie, bl) = (Cli::new("lernie"), Cli::new("bl"));
let mut world = world();
let ws = world.ws.clone();
world.model.focus_agent(&ws, "c-1");
world.state.activity_open = true;
crate::opslog::append(
world.model.state_root(),
&crate::opslog::OpEntry {
ts: "19".into(),
argv: vec![
"lernie".into(),
"prompt".into(),
ws.to_string_lossy().into_owned(),
"yo".into(),
],
cwd: ws.to_string_lossy().into_owned(),
exit: crate::opslog::DETACHED_EXIT,
stdout: String::new(),
stderr: String::new(),
origin: crate::opslog::Origin::Conversation,
},
)
.unwrap();
let sink = crate::opslog::detached::sink(world.model.state_root(), "19", &ws);
std::fs::create_dir_all(sink.parent().unwrap()).unwrap();
std::fs::write(
&sink,
"lernie: compaction landing [c-2] superseded — a compaction landed since \
its fork point (ARCH §2.6); the branch continues\n",
)
.unwrap();
world.model.after_lernie_verb();
world.converge();
let out = painted(&mut world, &lernie, &bl);
let (glyph, _, _) = crate::theme::op_badge(crate::opslog::OpOutcome::Notice);
assert!(
out.lines()
.any(|line| line.starts_with(glyph) && line.ends_with('⋯')),
"the notice row is on the glass, badged and expandable:\n{out}"
);
assert!(
!out.contains("⚠ lernie prompt"),
"and no §7.3 failure banner is raised over it:\n{out}"
);
assert!(
!out.contains("failed ⚠"),
"nor does the chip count it:\n{out}"
);
}