Remove the Bash test suite and shellcheck from CI, the pre-commit hook, the Makefile, agent-commit and publish. CI now runs cargo fmt, clippy and test.
98 lines
3 KiB
Rust
98 lines
3 KiB
Rust
//! Coverage of the reference Bash installer's command-line surface.
|
|
//!
|
|
//! Every mode and flag accepted by the reference Bash installer (see
|
|
//! `docs/BASH-MIGRATION.md`) 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"
|
|
);
|
|
}
|