Files
openhuman/tests/raw_coverage_all.rs
T

37 lines
2.0 KiB
Rust

//! Aggregated integration-test target for the `tests/raw_coverage/` suites.
//!
//! Each `tests/raw_coverage/*_raw_coverage_e2e.rs` file is included here as a
//! module instead of being its own `tests/*.rs` target. Cargo builds one test
//! binary for this file rather than ~76, so the (large) `openhuman` rlib is
//! linked once instead of once per file. The module list is generated by
//! `build.rs` (see `raw_coverage_mods.rs`) so new files are picked up
//! automatically.
//!
//! Each included file keeps its own `#![cfg(...)]` gates — as module-level
//! inner attributes they conditionally compile just that module, matching the
//! per-target behaviour these files had as standalone binaries.
// Helper fns/imports that were "used" inside a file's own standalone test
// binary can read as dead once every file shares one crate root here (e.g. a
// helper only reached by a `#[cfg]`-gated test). These are coverage suites, not
// production code, so silence the noise rather than churn 76 files.
#![allow(dead_code, unused_imports)]
use std::sync::{Mutex, OnceLock};
/// Process-global env lock shared by every aggregated suite that mutates
/// process-global env (`OPENHUMAN_WORKSPACE`, `HOME`, `BACKEND_URL`, …).
///
/// Before these files were collapsed into this single binary they ran as
/// separate processes, so each file's own env lock was sufficient — different
/// files could never race because they had independent environments. Now that
/// they share one process, libtest runs them concurrently and per-file locks no
/// longer mutually exclude. Each file's local env lock is redefined to a
/// `&`-reference to this one static, so all env mutations across all aggregated
/// suites serialize on a single mutex while non-env tests keep running in
/// parallel. Poison is recovered (`into_inner`) at the guard sites, so a
/// panicking test cannot wedge the whole suite.
pub static SHARED_ENV_LOCK: OnceLock<Mutex<()>> = OnceLock::new();
include!(concat!(env!("OUT_DIR"), "/raw_coverage_mods.rs"));