bread-utils: fix flaky test isolation around process-global env vars
singleton.rs's tests used to call the real kill() on the current test process itself (the recorded "other instance" PID was our own, since tests run single-process) — split try_acquire (side-effect-free) out from toggle_or_kill (sends the signal) so the concurrency assertions no longer risk SIGTERM-ing the test binary. Separately, hypr.rs's env-var test mutates HYPRLAND_INSTANCE_SIGNATURE/ XDG_RUNTIME_DIR process-globally; cargo runs tests in parallel threads by default, so it could race a concurrently-running singleton or xdg test expecting the real XDG_RUNTIME_DIR, intermittently failing them with ENOENT. Added a shared env_test_lock() all env-var-touching tests now acquire for their duration. Verified via 5 repeated full test runs with zero flakes (28/28 passing each time).
This commit is contained in:
parent
853ee33415
commit
49c63c8ccf
4 changed files with 29 additions and 1 deletions
|
|
@ -217,6 +217,7 @@ mod tests {
|
|||
// vars would be flaky.
|
||||
#[test]
|
||||
fn socket_path_env_var_behavior() {
|
||||
let _lock = crate::env_test_lock().lock().unwrap_or_else(|e| e.into_inner());
|
||||
unsafe { env::remove_var("HYPRLAND_INSTANCE_SIGNATURE") };
|
||||
assert!(socket_path(Socket::Request).is_none());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue