crates/knut-build-thing/tests/silenced_tests_guard.rs
//! **knut's own silenced-test guard.** A `tests/*.rs` whose crate-level
//! `#![cfg(feature = "X")]` is not in its crate's `default` closure compiles to an
//! EMPTY test binary and prints `running 0 tests ... ok`. Green by vacuum.
//!
//! ## What was dark on 2026-08-01
//!
//! knut declared 10 rescue arms in `.nornir/testmatrix-arms.json` on 2026-07-21 and
//! they hold: re-verified 2026-08-01 with `nornir_testmatrix::verify_arms`. But
//! nothing in knut, or in any of the other 19 repos of the constellation, has ever
//! *run* the audit — the arms file was written once and read by no code at all. So
//! two targets drifted past it:
//!
//! * `crates/knut-thund/tests/sql_frontend.rs` — `#![cfg(feature = "sql")]`, **13
//! `#[test]` fns**, the largest single dark file in the repo. `sql` pulls
//! `sqlparser` only, not the DataFusion tree, so the existing
//! `-p knut-thund --features native` arm never covered it: `native` and `sql` are
//! siblings, neither implies the other. Measured 2026-08-01: the file compiles
//! clean under `--features sql` and its binary lists 12 tests.
//! * `crates/knut-bifrost/tests/watch_cli_iceberg.rs` —
//! `#![cfg(all(feature = "skade", feature = "cli"))]`, 3 fns. The classic
//! near-miss: knut declared `-p knut-bifrost --features skade`, and the file needs
//! `skade` AND `cli`. One conjunct short is the same as no arm at all.
//!
//! ## Why this file is not itself feature-gated
//!
//! Because it is the guard, and a gated guard is the disease. It takes no feature,
//! shells out only `cargo metadata --no-deps` (no build, no network, no container),
//! and runs on every plain `cargo test`.
//!
//! ## Why it lives in `knut-build-thing`
//!
//! It needs `nornir-testmatrix`, and knut refuses a `../sibling` path dependency
//! anywhere in the workspace — a missing sibling aborts resolution for the WHOLE
//! workspace, which was measured on 2026-09-10 — so the dep is the registry
//! (0.2.11, which carries `audit_repo`). This crate is the repo's build thing and
//! already carries the build-matrix dependency, so the guard sits beside the
//! declaration it is about rather than in `xtask`, whose dev-deps are documented
//! sibling-free. A dev-dep never leaks into what a consumer resolves.
//!
//! ## What this does NOT prove
//!
//! That the declared arms are RUN. This compares the arms file against what is on
//! disk; `nornir_testmatrix::verify_arms` compiles each arm and is the separate,
//! expensive check (run by hand 2026-08-01, results in the arms file).
use std::path::{Path, PathBuf};
fn repo_root() -> PathBuf {
// crates/knut-build-thing → crates → <repo root>
Path::new(env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(2)
.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()
)
});
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")
);
}