Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

mikronova/modgunn

tests/no_silenced_tests.rs

//! **Tripwire: no `tests/*.rs` in this repo may compile to ZERO tests.**
//!
//! A test file whose crate-level inner attribute — `#![cfg(feature = "X")]` —
//! is not satisfied by its crate's `default` feature closure compiles to an
//! EMPTY test binary. `cargo test` then prints `running 0 tests ... ok` and the
//! file is green-by-vacuum: it looks exactly like a passing file, forever.
//! `nornir_testmatrix::audit_repo` resolves every workspace member's `default`
//! closure statically and RED-flags any gated file that is neither
//! default-reachable nor re-invoked by an arm declared in
//! `.nornir/testmatrix-arms.json`.
//!
//! ## What this repo looks like today
//!
//! Measured 2026-08-01 on `oden`: **11 test targets scanned · 10 feature-gated ·
//! 9 rescued by the declared arm · 0 silenced**.
//!
//! Those numbers make modgunn the most load-bearing adoption of the six. **Ten
//! of eleven** integration-test files here carry a crate-level `#![cfg]`, and
//! **nine of them are dark under a plain `cargo test`** — they exist entirely at
//! the mercy of one declared arm:
//!
//! ```json
//! { "features": ["scan", "provenance-verify", "warehouse",
//!                "manifests", "framework", "testmatrix"] }
//! ```
//!
//! That is not an accident and it is not a defect. modgunn's default feature set
//! is deliberately LEAN — `scan` + `provenance-verify` only — because holger's
//! policy gate and static-holger link modgunn and must stay free of the
//! arrow/iceberg/redb tree. The leanness is correct; the silence was its side
//! effect. Before the arm was declared on 2026-07-21, seven of these files had
//! never compiled, and `cargo test` reported `0 tests ... ok` for each. modgunn
//! has no CI, so nothing else was ever going to notice.
//!
//! A 9-of-11 rescue ratio is exactly the state where the *arm file itself*
//! becomes the single point of failure. Rename a feature, split `warehouse`,
//! add a twelfth test gated on something the arm does not name, and this repo
//! goes quietly back to reporting green on files that never built. This guard
//! is what makes that go red instead. It re-resolves the arm's transitive
//! feature closure against the cfg each file actually carries, rather than
//! comparing strings — the near-miss failure (`lineage` vs `lineage-http`) the
//! original audit caught in a sibling repo.
//!
//! What this file does NOT prove: that the arm is ever executed. It proves the
//! arm exists and still covers every gated file. Nothing in a static audit can
//! tell you a command was invoked — for modgunn in particular, which has no CI,
//! that gap is real and worth naming.
//!
//! The non-vacuity assertion below matters as much as the silence assertion: a
//! repo root that resolves but scans nothing reports "0 silenced" because it
//! looked at nothing. `scanned > 0` is what separates a real green from an empty
//! one. (Two repos in this fleet — bifrost and heimdal — genuinely scan zero
//! targets, and for that reason deliberately do NOT carry this file.)
//!
//! Deliberately NOT feature-gated — and here that is the whole point rather than
//! a wisecrack. Ten of the eleven files beside this one ARE gated; following the
//! local convention would have made the guard against silenced tests the tenth
//! silenced test, rescued only by the very arm it exists to police.

use std::path::{Path, PathBuf};

/// This file lives at `<repo>/tests/`, and `modgunn` is a single root package
/// whose `Cargo.toml` sits at the repo root, so `CARGO_MANIFEST_DIR` is already
/// the directory the audit must run in.
fn repo_root() -> PathBuf {
    Path::new(env!("CARGO_MANIFEST_DIR"))
        .ancestors()
        .nth(0)
        .unwrap()
        .to_path_buf()
}

#[test]
fn this_repo_has_no_silenced_test_files() {
    let root = repo_root();
    let rep = nornir_testmatrix::audit_repo(&root, "self-audit").unwrap_or_else(|e| {
        panic!(
            "the silenced-test audit could not RUN at {} — that is a RED, not a skip: {e:#}",
            root.display()
        )
    });
    // Non-vacuity (LAW 2: check output, not exit code). A root that resolves but
    // scans nothing reports "0 silenced" because it looked at nothing.
    assert!(
        rep.scanned > 0,
        "the audit scanned ZERO test targets under {} — it proved nothing",
        root.display()
    );
    assert!(
        rep.is_green(),
        "SILENCED TESTS in `modgunn` — {}\n{}",
        rep.summary(),
        rep.silenced()
            .iter()
            .map(|f| format!("  · {}", f.message()))
            .collect::<Vec<_>>()
            .join("\n")
    );
}