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

nordisk/gunnar

crates/gunnar-core/tests/txlog_test_hooks.rs

//! **A shipped box never honours a test's group-commit hold** (wiring tracer
//! B 2026-10-08). `GUNNAR_TXLOG_TEST_GROUP` makes every group-commit leader
//! wait up to 100 ms for its group before its fsync — the audit fsync test's
//! way to count what a group SHARES. It was read by every build, so a box
//! started with that variable (a stray env file, a copied unit) held every
//! write up to 100 ms. Only a build with the `test-hooks` feature (the
//! gunnar-server test that needs it) reads it.

#[test]
fn a_build_without_test_hooks_does_not_hold_a_group_commit_for_a_test() {
    std::env::set_var(gunnar_core::txlog::TEST_GROUP_ENV, "8");
    let dir = tempfile::tempdir().expect("tmp");
    let log = gunnar_core::txlog::Log::open(dir.path()).expect("a log");
    // `cargo test --workspace` unifies features: gunnar-server's dev-dependency turns
    // `test-hooks` on for THIS crate too, and then the hook is meant to be read. What is
    // held is that the variable is read exactly when the build carries the feature.
    if cfg!(feature = "test-hooks") {
        assert_eq!(
            log.group_hold(),
            Some(8),
            "a test-hooks build reads the hook"
        );
    } else {
        assert_eq!(
            log.group_hold(),
            None,
            "the test hook is honoured by a build without test-hooks"
        );
    }
}