test: red executable-spec for #266 — aura --version carries the engine commit

aura --version must print 'aura 0.1.0 (<commit>)', the commit sourced
from the same AURA_COMMIT build provenance the run manifest stamps —
a pre-run freshness probe distinguishing a stale binary from an engine
bug. Fails on the absent parenthesized commit, not on scaffolding.

refs #266
This commit is contained in:
2026-07-13 22:11:03 +02:00
parent 5b70bd60a5
commit 5a1696891a
+36
View File
@@ -4866,6 +4866,42 @@ fn version_flag_prints_version_to_stdout_and_exits_zero() {
} }
} }
/// `--version` carries the ENGINE COMMIT beside the semver, drawn from the SAME
/// `AURA_COMMIT` build-time provenance the run manifest stamps (the
/// `option_env!("AURA_COMMIT")` that fills `RunManifest.commit`), so a stale
/// binary is distinguishable at the CLI surface *before* any run (#266). Shape:
/// `aura 0.1.0 (<commit-ish>)`, exit 0.
///
/// Property, not a specific sha: the expected commit is read from the same
/// provenance source the built binary was compiled with — this integration test
/// receives aura-cli's build-script `rustc-env`, so it sees the identical value
/// (dirty/`unknown` suffixes included) rather than today's HEAD, keeping the
/// assertion honest against a lagging or unclean tree. The load-bearing claim is
/// that the parenthesized commit rides beside the still-present semver.
#[test]
fn version_flag_carries_the_engine_commit_from_manifest_provenance() {
// The single source of truth — the same env the manifest's commit is sourced
// from; falls back to "unknown" identically to `sim_optimal_manifest`.
let commit = option_env!("AURA_COMMIT").unwrap_or("unknown");
let out = std::process::Command::new(env!("CARGO_BIN_EXE_aura"))
.arg("--version")
.output()
.expect("spawn aura");
assert_eq!(out.status.code(), Some(0), "--version exit {:?}", out.status);
let stdout = String::from_utf8_lossy(&out.stdout);
// Semver stays present (one source of truth, CARGO_PKG_VERSION).
assert!(
stdout.contains(env!("CARGO_PKG_VERSION")),
"--version still prints the semver: {stdout:?}"
);
// ...and the engine commit rides beside it, parenthesized, from the shared
// manifest provenance — the load-bearing assertion #266 adds.
assert!(
stdout.contains(&format!("({commit})")),
"--version prints the engine commit ({commit}) beside the semver: {stdout:?}"
);
}
/// Subcommand help is SCOPED: `aura sweep --help` names sweep's own flags and is /// Subcommand help is SCOPED: `aura sweep --help` names sweep's own flags and is
/// NOT byte-identical to `aura run --help` — each subcommand documents its own /// NOT byte-identical to `aura run --help` — each subcommand documents its own
/// options rather than reprinting one shared global blob (the #131 uniform-help /// options rather than reprinting one shared global blob (the #131 uniform-help