nornir 0.4.21

Companion to cargo: dependency tracking, release gating, deploy, benchmarks, and documentation assembly. Project-agnostic.
Documentation
//! CLI-parity smoke tests for the dependency-graph (`mimir`) and viz-diagram
//! (`diagram`) subcommands added to bring the `nornir` CLI to parity with the
//! server's `Mimir`/`Viz` RPCs and the egui viz's `diagram.rs` renderers.
//!
//! These drive the real `nornir` binary's argument parser (`--help`), so a
//! regression that drops a subcommand or mis-wires clap fails here without
//! needing a warehouse fixture. `clap` also debug-asserts the whole command
//! tree while building `--help`, catching duplicate/ambiguous args.

use std::process::Command;

fn nornir() -> Command {
    Command::new(env!("CARGO_BIN_EXE_nornir"))
}

fn stdout_of(args: &[&str]) -> String {
    let out = nornir().args(args).output().expect("run nornir");
    assert!(
        out.status.success(),
        "`nornir {}` failed: {}",
        args.join(" "),
        String::from_utf8_lossy(&out.stderr)
    );
    String::from_utf8_lossy(&out.stdout).into_owned()
}

#[test]
fn mimir_is_registered_with_every_op() {
    let help = stdout_of(&["mimir", "--help"]);
    for sub in [
        "deps-of",
        "dependents-of",
        "affected",
        "build-order",
        "dep-path",
        "external-users",
        "mermaid",
        "overview",
        "changed",
    ] {
        assert!(help.contains(sub), "`mimir --help` missing subcommand `{sub}`:\n{help}");
    }
}

#[test]
fn diagram_is_registered_with_every_renderer() {
    let help = stdout_of(&["diagram", "--help"]);
    for sub in [
        "timeline",
        "lane-summary",
        "depgraph",
        "snapshot-edges",
        "gate-matrix",
        "release-versions",
        "bench-history",
        "bench-compare",
    ] {
        assert!(help.contains(sub), "`diagram --help` missing renderer `{sub}`:\n{help}");
    }
}

#[test]
fn top_level_lists_new_commands() {
    let help = stdout_of(&["--help"]);
    assert!(help.contains("mimir"), "top-level help missing `mimir`:\n{help}");
    assert!(help.contains("diagram"), "top-level help missing `diagram`:\n{help}");
}

#[test]
fn mimir_deps_of_accepts_transitive_flag() {
    // Parse-only: `--help` on the leaf op asserts the flag exists.
    let help = stdout_of(&["mimir", "deps-of", "--help"]);
    assert!(help.contains("--transitive"), "deps-of missing --transitive:\n{help}");
}