use std::process::Command;
fn vela_bin() -> &'static str {
env!("CARGO_BIN_EXE_vela")
}
fn init_frontier(dir: &std::path::Path) {
let out = Command::new(vela_bin())
.current_dir(dir)
.env("HOME", dir)
.args([
"init",
".",
"--name",
"envtest",
"--scope",
"Exercise environment isolation.",
])
.output()
.expect("init");
assert!(out.status.success(), "init failed: {out:?}");
}
fn run_in(dir: &std::path::Path, args: &[&str]) -> std::process::Output {
Command::new(vela_bin())
.current_dir(dir)
.env("HOME", dir)
.env("VELA_NO_PUBLISH", "1")
.args(args)
.output()
.expect("spawn vela")
}
#[test]
fn command_errors_use_stable_exit_codes() {
let tmp = tempfile::TempDir::new().unwrap();
init_frontier(tmp.path());
let out = run_in(tmp.path(), &["check", "--json"]);
assert_eq!(
out.status.code(),
Some(1),
"check current repository refusal: {out:?}"
);
let out = run_in(tmp.path(), &["state", "anchor", ".", "vf_x", "--json"]);
assert_eq!(
out.status.code(),
Some(2),
"retired state anchor writer: {out:?}"
);
let out = run_in(
tmp.path(),
&[
"id",
"rotate-key",
"--id",
"reviewer:x",
"--new-id",
"reviewer:x",
"--json",
],
);
assert_eq!(out.status.code(), Some(2), "id rotate same id: {out:?}");
}