xtask/tests/spawn_reasons.rs
//! **Every raw thread or detached task in Holger'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, monetize and edda run (a `.spawn(` on any receiver, a detached
//! `spawn_blocking(`, a process constructor under any path). A tree that does not exist is red
//! too, so a moved crate cannot pass by going unread.
use std::path::Path;
use nornir_xtask_support::spawn_guard::{message, Guard};
/// The source trees whose production code runs in a box (the server, its inspector and sandbox,
/// the repository backends, the downstream link and the sync, PID 1, the front, the live slot),
/// and the job and duty machinery whose spawns ARE the jobs.
const GUARD: Guard<'static> = Guard {
trees: &[
"server/lib/src",
"server/cli/src",
"server/inspect/src",
"server/sandbox/src",
"server/scan-worker/src",
"server/repository",
"server/downstream/src",
"sync/src",
"holger-estate-front/src",
"estate/holger-live/src",
"estate/holger-fleet/src",
],
machinery: &["estate/holger-live/src/duty.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, "holger_live::duty"));
}