tests/silenced_tests_guard.rs
//! **This repo must contain no silenced test file.**
//!
//! A `tests/*.rs` carrying a crate-level `#![cfg(feature = "X")]` that the crate's
//! `default` closure does not satisfy compiles to an **empty test binary**. `cargo
//! test` then prints `running 0 tests ... ok` for it — a green that was produced by
//! looking at nothing. That is LAW 2's exact failure mode, and it is invisible to
//! review because the file reads like its running siblings.
//!
//! `nornir_testmatrix::audit_repo` walks every `test` target of every workspace
//! member (via `cargo metadata`), resolves each crate's transitive `default`
//! feature closure, and reports any gated file that is neither default-reachable
//! nor rescued by a declared arm in `.nornir/testmatrix-arms.json`.
//!
//! ## What was dark in Skidbladnir on 2026-08-01
//!
//! Measured with the guard, from disk: 6 test targets scanned, 2 feature-gated,
//! **1 silenced** — `tests/promote_contract.rs`, behind `#![cfg(feature =
//! "promote")]`, hiding **15** `#[test]` fns. `default = ["pki"]`, so `promote`
//! (= `["dep:serde_yaml"]`) was never on and the whole PUBLIC-API contract of
//! `skidbladnir::promote` — the fence a config file must not be able to lower, the
//! two-key prod guard, the partial-capture refusal, the unanswerable watermark —
//! had never executed. Verified the same day: the file compiles under `--features
//! promote` and all **15 tests PASS**. Pure reporting gap, zero fixes needed; but
//! 15 contract assertions reporting `0 tests ... ok` is precisely the silence this
//! file exists to end.
//!
//! `tests/install_matrix_live.rs` (feature `matrix`) was already rescued by the arm
//! declared on 2026-07-21 — see `.nornir/testmatrix-arms.json` for what each arm
//! PROVES (it compiles) and does NOT prove (the live KVM run).
//!
//! ## Why this file is not itself feature-gated
//!
//! A guard hidden behind the same mechanism it polices would be the joke version of
//! itself: it would go dark exactly when a feature is turned off, which is when it
//! is needed. It carries **no** `#![cfg]`, and its only dependency is the
//! serde-only `nornir-testmatrix` (a dev-dependency), so it runs on a plain
//! `cargo test` with no features at all.
use std::path::{Path, PathBuf};
/// The repo root — for Skidbladnir the root crate IS the repo, so the manifest
/// directory is already it.
fn repo_root() -> PathBuf {
Path::new(env!("CARGO_MANIFEST_DIR"))
.ancestors()
.next()
.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 — {}\n{}",
rep.summary(),
rep.silenced()
.iter()
.map(|f| format!(" · {}", f.message()))
.collect::<Vec<_>>()
.join("\n")
);
}