tests: a tick report lists deferred nodes with their reasons
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0c80f39791
commit
d846363781
1 changed files with 54 additions and 0 deletions
|
|
@ -3163,3 +3163,57 @@ async fn a_node_is_labelled_by_what_it_stands_on() {
|
|||
"a node the hierarchy does not hold has no label"
|
||||
);
|
||||
}
|
||||
|
||||
/// G6: a node that took no turn is in the report with why, whether the plan
|
||||
/// left it out (frozen in the tick) or the window's allowance stopped the wave
|
||||
/// inside or before it. A node that ran to its end is not deferred.
|
||||
#[tokio::test]
|
||||
async fn a_tick_report_lists_deferred_nodes_with_their_reasons() {
|
||||
let (_probe_dir, probe) = Harness::fresh().await;
|
||||
let measuring = ScriptedPort::speaking();
|
||||
probe.run_quietly(measuring.clone(), u64::MAX, 1).await;
|
||||
let first_bound = measuring.bounds()[0];
|
||||
|
||||
let (_dir, verse) = Harness::fresh().await;
|
||||
let config = deep_config(1);
|
||||
let mut tick = opened_tick(&verse, &config).await;
|
||||
let world = tick.world_id;
|
||||
tick.deferred.push((NodeId::of(world, &NodeAnchor::World), Deferral::NotDue));
|
||||
verse.runs.put_tick(&tick).unwrap();
|
||||
|
||||
let mut reports = Vec::new();
|
||||
let ended = verse
|
||||
.run_under(ScriptedPort::speaking(), first_bound + 64, config, |report| {
|
||||
reports.push(report.clone());
|
||||
ControlFlow::Continue(())
|
||||
})
|
||||
.await;
|
||||
assert_eq!(ended.record.status, RunStatus::BudgetExhausted);
|
||||
let [report] = reports.as_slice() else {
|
||||
panic!("one tick reported")
|
||||
};
|
||||
let ran = report.nodes.iter().find(|node| node.acts.len() == 1).unwrap();
|
||||
let stopped = report.nodes.iter().find(|node| node.acts.is_empty()).unwrap();
|
||||
assert_eq!(
|
||||
report.deferred,
|
||||
vec![
|
||||
DeferredNode {
|
||||
label: "world".into(),
|
||||
reason: Deferral::NotDue
|
||||
},
|
||||
DeferredNode {
|
||||
label: stopped.label.clone(),
|
||||
reason: Deferral::Allowance
|
||||
},
|
||||
],
|
||||
"the plan's deferral and the node the allowance stopped in; not {}",
|
||||
ran.label
|
||||
);
|
||||
let text = report.to_string();
|
||||
assert!(text.contains(" deferred (not due): world\n"), "{text}");
|
||||
assert!(
|
||||
text.contains(&format!(" deferred (past the allowance): {}\n", stopped.label)),
|
||||
"{text}"
|
||||
);
|
||||
assert!(!text.contains("over the node-turn bound"), "{text}");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue