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

nordisk/facett

facett-app/tests/devid_force_gate.rs

//! **The dev-id gate seam is LOUD when it loses the race** — one test, its own binary.
//!
//! `facett_core::devid::force_gate` is what lets `devid_scene_slots.rs` assert on the
//! chip in a build profile where the chip is off by default. A seam like that has one
//! interesting failure: something reads (or forces) the gate first, `OnceLock::set`
//! returns `Err`, and the caller carries on against a gate it did not ask for. Every chip
//! assertion downstream would then be asserting against nothing while reporting green —
//! "your own new guard can be blind", which is how three hollow guards got built on
//! 2026-07-31 by agents who were hunting hollow guards at the time.
//!
//! So this file loses that race on purpose and requires the panic. It has to be its own
//! binary: the gate is process-global and decided once, so a test that spends it cannot
//! share a binary with the tests that need it open.
//!
//! ```bash
//! cargo test -p facett-app --test devid_force_gate
//! cargo test --release -p facett-app --test devid_force_gate
//! ```

/// RED-when-broken: drop the `assert_eq!` from `force_gate` — leaving only the
/// `let _ = GATE.set(..)` that silently does nothing — and this fails with
/// `note: test did not panic as expected`.
#[test]
#[should_panic(expected = "the dev-id gate was already decided")]
fn force_gate_refuses_to_pretend_when_the_gate_was_already_decided() {
    // Decide it the ordinary way first — whatever this profile says is now the process's
    // answer, and `OnceLock::set` can no longer change it.
    let decided = facett_core::devid::enabled();
    // Ask for the opposite. Silence here would be the blind guard.
    facett_core::devid::force_gate(!decided);
}