test: hygiene check sees arcanum's own features; A-15 binding goes through session_prk

This commit is contained in:
2026-11-25 07:40:57 +01:00
parent 89b5329f06
commit 6233c8244e
3 changed files with 51 additions and 29 deletions
+24 -7
View File
@@ -1,8 +1,10 @@
//! QA A-35: no test-only feature may reach a normal (release) build through Cargo feature
//! unification. Checks the normal-edge dependency graph that a consumer of Arcanum would get.
//! unification. Checks the normal-edge graph a consumer of Arcanum gets with default features.
//!
//! `arcanum/hazmat` exposes the deterministic entry points; `ml-kem/hazmat` only un-hides docs in
//! `arcanum/hazmat` exposes the deterministic entry points. `ml-kem/hazmat` only un-hides docs in
//! 0.3.4 (its `encapsulate_deterministic` is public either way), but is kept out on principle.
//! Consumers (via-core, via) must run the same check in their own CI: a `[dependencies]` entry
//! there could still enable `arcanum/hazmat`.
use std::process::Command;
@@ -17,18 +19,33 @@ fn tree(args: &[&str]) -> String {
String::from_utf8(out.stdout).unwrap()
}
#[test]
fn hazmat_is_not_in_the_normal_graph() {
let t = tree(&["-p", "arcanum"]);
assert!(t.contains("ml-kem"), "the tree must include ml-kem, or this test checks nothing:\n{t}");
fn assert_no_hazmat(t: &str, what: &str) {
for line in t.lines() {
assert!(!line.contains("feature \"hazmat\""), "hazmat reached a normal build: {line}\n{t}");
assert!(!line.contains("feature \"hazmat\""), "{what}: hazmat reached a normal build: {line}\n{t}");
}
}
#[test]
fn arcanum_default_features_do_not_include_hazmat() {
let t = tree(&["-i", "arcanum"]);
assert!(t.contains("arcanum feature \"default\""), "the tree must list arcanum's features:\n{t}");
assert_no_hazmat(&t, "arcanum");
// Prove the check can see the feature at all: asking for it must make it appear.
let with = tree(&["-i", "arcanum", "--features", "hazmat"]);
assert!(with.contains("arcanum feature \"hazmat\""), "the check is blind:\n{with}");
}
#[test]
fn ml_kem_hazmat_is_not_in_the_normal_graph() {
let t = tree(&["-i", "ml-kem"]);
assert!(t.contains("ml-kem feature \"zeroize\""), "the tree must list ml-kem's features:\n{t}");
assert_no_hazmat(&t, "ml-kem");
}
#[test]
fn no_os_rng_in_the_normal_graph() {
// Randomness is a parameter (QA A-36): nothing in the normal graph may pull an OS RNG.
let t = tree(&["-p", "arcanum"]);
assert!(t.contains("rand_core"), "the tree must include rand_core:\n{t}");
assert!(!t.contains("getrandom"), "getrandom reached a normal build:\n{t}");
}