cli.rs 46 lignes · 1311 octets
//! Acceptance tests for the `chipai` binary (outer TDD loop).
//!
//! Scenario (docs/plans/chipai-fonderie.md, tranche 0):
//!   Given the chipai binary
//!   When I run `chipai --help`
//!   Then it exits successfully and lists the pipeline subcommands.

use assert_cmd::Command;
use predicates::prelude::*;

const SUBCOMMANDS: &[&str] = &[
    "fetch", "ref", "quant", "vectors", "gen", "sim", "synth", "diagrams", "report",
];

#[test]
fn help_lists_every_pipeline_subcommand() {
    let mut cmd = Command::cargo_bin("chipai").expect("binary built");
    let assert = cmd.arg("--help").assert().success();
    let out = String::from_utf8(assert.get_output().stdout.clone()).unwrap();
    for sub in SUBCOMMANDS {
        assert!(
            out.contains(sub),
            "`--help` should mention subcommand `{sub}`, got:\n{out}"
        );
    }
}

#[test]
fn version_flag_prints_crate_version() {
    Command::cargo_bin("chipai")
        .unwrap()
        .arg("--version")
        .assert()
        .success()
        .stdout(predicate::str::contains(env!("CARGO_PKG_VERSION")));
}

#[test]
fn unknown_subcommand_fails_with_usage() {
    Command::cargo_bin("chipai")
        .unwrap()
        .arg("frobnicate")
        .assert()
        .failure()
        .stderr(predicate::str::contains("Usage"));
}