test(daemon): serialize heavy socket/PTY integration tests

Process-wide serial lock around the socket-binding and PTY-spawning
integration tests in spaceshd. Running several at once on a many-core
box starved each other's async tasks and tripped timing assumptions,
causing ~1/10 flakes under cargo test --workspace. Unit tests stay
parallel. 0/20 spaceshd + 0/5 workspace runs after the change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-09 20:39:24 +07:00
parent 77dfc69bd9
commit f1630633e5
3 changed files with 24 additions and 0 deletions
+18
View File
@@ -6,6 +6,24 @@ mod surface;
use anyhow::Result;
/// Test-only support shared across the crate's test modules.
#[cfg(test)]
pub(crate) mod test_support {
use std::sync::{Mutex, MutexGuard};
/// Process-wide serialization lock for the heavy socket/PTY integration tests.
/// These bind sockets and spawn real PTYs/processes; running several at once on a
/// many-core box starves each other's tasks and trips timing assumptions. Unit
/// tests stay parallel; only guarded integration tests serialize on this lock.
static SERIAL: Mutex<()> = Mutex::new(());
/// Acquire the serial lock for the duration of a test. Poison-tolerant so one
/// panicking test does not cascade-fail the rest.
pub(crate) fn serial() -> MutexGuard<'static, ()> {
SERIAL.lock().unwrap_or_else(|e| e.into_inner())
}
}
#[tokio::main]
async fn main() -> Result<()> {
let arg = std::env::args().nth(1);