clay-borg/tools/cb-sim/src/main.rs

60 lines
1.9 KiB
Rust
Raw Normal View History

//! cb-sim — scenario runner binary (GameKernel K17; precursor of `cb sim`).
//! T07 scope: parse and validate scenario files, report coverage tags.
//! T08 wires execution. Exit codes: 0 all passed, 1 failures, 2 not yet
//! executable (parse-only), 64 usage error.
use cb_game_runtime::{scenario, RunOutcome, ScenarioFile};
fn main() {
let args: Vec<String> = std::env::args().skip(1).collect();
if args.is_empty() {
eprintln!("usage: cb-sim <scenario.yaml>...");
std::process::exit(64);
}
let mut unimplemented = false;
let mut failed = false;
for path in &args {
let text = match std::fs::read_to_string(path) {
Ok(t) => t,
Err(e) => {
eprintln!("{path}: read error: {e}");
failed = true;
continue;
}
};
match ScenarioFile::from_yaml(&text) {
Err(e) => {
eprintln!("{path}: parse error: {e}");
failed = true;
}
Ok(sc) => match scenario::run(&sc) {
RunOutcome::Passed { covers } => {
println!("PASS {} covers={}", sc.scenario, covers.join(","));
}
RunOutcome::Failed { reason } => {
println!("FAIL {}{reason}", sc.scenario);
failed = true;
}
RunOutcome::Unimplemented => {
println!(
"PARSED {} covers={}{} (runner not yet implemented — T08)",
sc.scenario,
sc.covers.join(","),
if sc.provisional { " provisional" } else { "" }
);
unimplemented = true;
}
},
}
}
if failed {
std::process::exit(1);
}
if unimplemented {
std::process::exit(2);
}
}