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

nordisk/monetize

xtask/tests/spawn_reasons.rs

//! **Every raw thread or detached task in monetize's runtime code says why it is not a jera job**
//! (A32-14, the owner's rule: background work in a server is a named jera job).
//!
//! A raw spawn in the production code of the server crates carries a reason on one of the lines
//! above it (`A28 M18, stays …`, `A32-14, stays …`, or for a process `A32-14, a process by
//! design: …`). A new raw spawn without one is red here, by file and line.
//!
//! The matcher is the shared one (RA4-7): `nornir_xtask_support::spawn_guard`, the same
//! call-shape guard gunnar, holger and edda run (a `.spawn(` on any receiver, a detached
//! `spawn_blocking(`, a process constructor under any path, `Command::new(` bare as well). A
//! tree that does not exist is red too, so a renamed crate cannot pass by going unread.

use std::path::Path;

use nornir_xtask_support::spawn_guard::{message, Guard};

/// The crates whose production code runs in a box (the server, the front, their shared halves),
/// and the job machinery whose spawns ARE the jobs.
const GUARD: Guard<'static> = Guard {
    trees: &[
        "crates/monetize-site-buy/src",
        "crates/monetize-server/src",
        "crates/monetize-admin/src",
        "crates/monetize-estate-side/src",
        "crates/monetize-front/src",
        "crates/monetize-ui-server/src",
        "crates/monetize-shop-pairing/src",
        "crates/monetize-mail/src",
        "crates/monetize-cloud-wasm/src",
        "crates/monetize-product-wasm/src",
    ],
    machinery: &["crates/monetize-server/src/jobs.rs"],
};

/// ★ **Every raw spawn in the server crates' production code says why it is not a jera job.**
#[test]
fn every_raw_spawn_in_the_server_crates_says_why_it_is_not_a_jera_job() {
    let root = Path::new(env!("CARGO_MANIFEST_DIR")).parent().expect("xtask has a parent");
    let bad = GUARD.unreasoned_in(root);
    assert!(bad.is_empty(), "{}", message(&bad, "monetize_server::jobs"));
}