Lines
100 %
Functions
Branches
//! Shared fixtures for xtask's unit tests.
use std::sync::{Mutex, MutexGuard, PoisonError};
static PROCESSES: Mutex<()> = Mutex::new(());
/// Held by every test that starts a process. A test that writes a script and
/// then runs it fails with ETXTBSY when another test forks while the script is
/// still open for writing, because the forked child keeps that descriptor
/// until its own exec. Serialising process-starting tests closes that window.
pub fn processes() -> MutexGuard<'static, ()> {
PROCESSES.lock().unwrap_or_else(PoisonError::into_inner)
}