test(rust): add CLI coverage of the Bash installer surface
Expected to fail on --bootstrap-opencode until Phase 1 adds the flag.
This commit is contained in:
parent
ec88d65af5
commit
fb8bdfd633
2 changed files with 121 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
|||
# Pinned OpenCode release for the Phoebus OS installer.
|
||||
#
|
||||
# We deliberately do NOT use the vendor's curl|sh installer. The artifacts are
|
||||
# fetched from the official GitHub release and verified against the SHA-256
|
||||
# digests below before anything is executed.
|
||||
#
|
||||
# Update procedure:
|
||||
# 1. pick a release: https://github.com/anomalyco/opencode/releases
|
||||
# 2. download the linux tarball for the architecture
|
||||
# 3. sha256sum the tarball and update this file
|
||||
# 4. test in a throwaway VM before shipping a new ISO
|
||||
|
||||
VERSION=v1.18.31
|
||||
|
||||
# x86_64 (glibc)
|
||||
x86_64.url=https://github.com/anomalyco/opencode/releases/download/v1.18.31/opencode-linux-x64.tar.gz
|
||||
x86_64.sha256=e9312be75ed803b7415fc2aeabda1f4fe938912a39673762dc0c38c0e11ebde4
|
||||
x86_64.binary=opencode
|
||||
|
||||
# aarch64 (glibc)
|
||||
aarch64.url=https://github.com/anomalyco/opencode/releases/download/v1.18.31/opencode-linux-arm64.tar.gz
|
||||
aarch64.sha256=0000000000000000000000000000000000000000000000000000000000000000
|
||||
aarch64.binary=opencode
|
||||
98
installer-rs/crates/phoebus-installer/tests/cli_coverage.rs
Normal file
98
installer-rs/crates/phoebus-installer/tests/cli_coverage.rs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
//! Coverage of the reference Bash installer's command-line surface.
|
||||
//!
|
||||
//! Every mode and flag accepted by `installer/bin/ai-installer` (argument parser
|
||||
//! around lines 53-73) must have a Rust equivalent, or be explicitly recorded as
|
||||
//! intentionally dropped. The test inspects `--help` so it never executes an
|
||||
//! installation or bootstraps OpenCode.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
/// Flags that must be present in the Rust CLI.
|
||||
const REQUIRED_FLAGS: &[&str] = &[
|
||||
"--config",
|
||||
"--plan",
|
||||
"--dry-run",
|
||||
"--install",
|
||||
"--yes",
|
||||
"--luks-passphrase-file",
|
||||
"--user-password-file",
|
||||
"--root-password-file",
|
||||
"--bootstrap-opencode",
|
||||
];
|
||||
|
||||
/// Bash-only surface that is intentionally not ported, with the rationale so a
|
||||
/// future session knows the omission was deliberate.
|
||||
const INTENTIONALLY_DROPPED: &[(&str, &str)] = &[
|
||||
(
|
||||
"--backend",
|
||||
"an alias for --plan; the Rust CLI has a single deterministic backend",
|
||||
),
|
||||
(
|
||||
"--ui",
|
||||
"UI_BACKEND only selected a dialog/whiptail variant; ratatui needs none",
|
||||
),
|
||||
("-y", "clap provides the short form of --yes"),
|
||||
("--version", "clap provides -V/--version"),
|
||||
("--help", "clap provides -h/--help"),
|
||||
];
|
||||
|
||||
fn help_text() -> String {
|
||||
let out = Command::new(env!("CARGO_BIN_EXE_phoebus-installer"))
|
||||
.arg("--help")
|
||||
.output()
|
||||
.expect("run phoebus-installer --help");
|
||||
assert!(out.status.success(), "`--help` must succeed");
|
||||
String::from_utf8_lossy(&out.stdout).into_owned()
|
||||
}
|
||||
|
||||
fn manifest_path() -> PathBuf {
|
||||
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("resources/opencode.manifest")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_bash_cli_mode_has_a_rust_flag() {
|
||||
let help = help_text();
|
||||
for flag in REQUIRED_FLAGS {
|
||||
assert!(help.contains(flag), "Rust CLI is missing `{flag}`:\n{help}");
|
||||
}
|
||||
// The dropped surface is recorded in code, not silently forgotten.
|
||||
for (flag, _reason) in INTENTIONALLY_DROPPED {
|
||||
let _ = flag;
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relocated_opencode_manifest_is_pinned_and_complete() {
|
||||
let path = manifest_path();
|
||||
assert!(path.is_file(), "missing {}", path.display());
|
||||
let text = std::fs::read_to_string(&path).expect("read opencode manifest");
|
||||
|
||||
let version = text
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix("VERSION="))
|
||||
.expect("manifest pins a VERSION");
|
||||
assert!(version.starts_with('v'), "unexpected version `{version}`");
|
||||
|
||||
for key in ["x86_64.url", "x86_64.sha256", "x86_64.binary"] {
|
||||
assert!(text.contains(key), "manifest is missing `{key}`");
|
||||
}
|
||||
|
||||
let sha = text
|
||||
.lines()
|
||||
.find_map(|line| line.strip_prefix("x86_64.sha256="))
|
||||
.expect("x86_64 checksum");
|
||||
assert_eq!(
|
||||
sha.len(),
|
||||
64,
|
||||
"x86_64 checksum must be a SHA-256 hex digest"
|
||||
);
|
||||
assert!(
|
||||
sha.chars().all(|c| c.is_ascii_hexdigit()),
|
||||
"x86_64 checksum must be hex"
|
||||
);
|
||||
assert!(
|
||||
sha.chars().any(|c| c != '0'),
|
||||
"x86_64 checksum must not be a placeholder"
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue