The umbrella `maestro` binary had zero coverage of its feature-gate combinations (cli / daemon / registry / tui). Add: - Unit tests in `main.rs` for `is_cli_subcommand` classification (CLI vs server subcommands, plus the always-false non-`cli` stub) and the `-v` verbosity -> tracing-directive mapping. - A `verbosity_directive` helper, extracted from `cli_filter` purely to make the verbosity mapping testable without touching the process-global `RUST_LOG` (behavior unchanged). - An integration test (`tests/cli.rs`) driving the real built binary via `CARGO_BIN_EXE_maestro`, asserting the `--help`/`--version`/subcommand dispatch surface. Per-subcommand checks are `#[cfg]`-gated so the suite is meaningful under every feature subset. - A CI feature-gate matrix step: build + test each of cli/daemon/registry/ tui in isolation, and assert the no-feature build is rejected. All four subsets and the default build pass fmt, clippy, and tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
96 lines
2.9 KiB
Rust
96 lines
2.9 KiB
Rust
//! Smoke tests for the umbrella `maestro` binary's dispatch surface (NAP-271).
|
|
//!
|
|
//! These run against the real built binary via Cargo's `CARGO_BIN_EXE_maestro`
|
|
//! env var. Integration tests are compiled with the package's active feature
|
|
//! set, so the per-subcommand checks are `#[cfg]`-gated and the suite is
|
|
//! meaningful under every feature subset (`cli` / `daemon` / `tui`)
|
|
//! as well as the default all-features build. The asserts only inspect
|
|
//! `--help`/`--version` output and exit codes, so nothing is actually started.
|
|
|
|
use std::process::Command;
|
|
|
|
fn maestro() -> Command {
|
|
Command::new(env!("CARGO_BIN_EXE_maestro"))
|
|
}
|
|
|
|
fn run(args: &[&str]) -> (bool, String) {
|
|
let out = maestro().args(args).output().expect("run maestro");
|
|
let combined = format!(
|
|
"{}{}",
|
|
String::from_utf8_lossy(&out.stdout),
|
|
String::from_utf8_lossy(&out.stderr)
|
|
);
|
|
(out.status.success(), combined)
|
|
}
|
|
|
|
/// Subcommands expected in `--help`, derived from the active feature set.
|
|
fn expected_subcommands() -> Vec<&'static str> {
|
|
let mut subs: Vec<&'static str> = Vec::new();
|
|
#[cfg(feature = "cli")]
|
|
subs.extend(["list", "spawn", "attach", "kill"]);
|
|
#[cfg(feature = "daemon")]
|
|
subs.extend(["daemon"]);
|
|
#[cfg(feature = "tui")]
|
|
subs.extend(["tui"]);
|
|
subs
|
|
}
|
|
|
|
#[test]
|
|
fn top_level_help_lists_subcommands() {
|
|
let (ok, text) = run(&["--help"]);
|
|
assert!(ok, "--help should exit 0:\n{text}");
|
|
for sub in expected_subcommands() {
|
|
assert!(
|
|
text.contains(sub),
|
|
"--help missing subcommand `{sub}`:\n{text}"
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn version_flag_succeeds() {
|
|
let (ok, text) = run(&["--version"]);
|
|
assert!(ok, "--version should exit 0:\n{text}");
|
|
assert!(text.contains("maestro"), "--version output: {text}");
|
|
}
|
|
|
|
#[test]
|
|
fn no_args_prints_help_and_fails() {
|
|
// `arg_required_else_help = true` => exit non-zero but show usage.
|
|
let (ok, text) = run(&[]);
|
|
assert!(!ok, "bare invocation should fail:\n{text}");
|
|
assert!(text.contains("Usage"), "expected usage text:\n{text}");
|
|
}
|
|
|
|
#[test]
|
|
fn unknown_subcommand_fails() {
|
|
let (ok, text) = run(&["definitely-not-a-subcommand"]);
|
|
assert!(!ok, "unknown subcommand should fail:\n{text}");
|
|
}
|
|
|
|
#[cfg(feature = "cli")]
|
|
#[test]
|
|
fn cli_subcommand_help_works() {
|
|
// A representative CLI subcommand resolves and renders help.
|
|
let (ok, text) = run(&["spawn", "--help"]);
|
|
assert!(ok, "spawn --help should exit 0:\n{text}");
|
|
assert!(
|
|
text.contains("--daemon-url"),
|
|
"spawn help missing flags:\n{text}"
|
|
);
|
|
}
|
|
|
|
#[cfg(feature = "daemon")]
|
|
#[test]
|
|
fn daemon_subcommand_help_works() {
|
|
let (ok, text) = run(&["daemon", "--help"]);
|
|
assert!(ok, "daemon --help should exit 0:\n{text}");
|
|
}
|
|
|
|
#[cfg(feature = "tui")]
|
|
#[test]
|
|
fn tui_subcommand_help_works() {
|
|
let (ok, text) = run(&["tui", "--help"]);
|
|
assert!(ok, "tui --help should exit 0:\n{text}");
|
|
}
|