mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-01 21:10:37 +01:00
gpui: Fix flaky hang monitor shutdown test (#64993)
`profiler::hang::tests::app_flushes_its_hang_monitor_on_shutdown` fails intermittently on CI ([example](https://github.com/zed-industries/zed/actions/runs/36730826643/job/109954752762)). `App::shutdown` requests a flush from the hang monitor and waits for it with `block_with_timeout`, which in tests runs on the deterministic `TestScheduler`. The monitor is a real OS thread (`HangDetection`), so the outcome depends on timing: - If the monitor finishes after shutdown starts waiting, its `done.send(())` wakes the scheduler from the `HangDetection` thread, and `end_test` panics with "Your test is not deterministic" (the CI failure). - If it hasn't finished when shutdown first checks, parking is forbidden, so the timed wait gives up immediately and the `Some(Flush)` assertion fails (reproduced locally). The test now calls `cx.executor().allow_parking()`, the existing opt-in for tests that involve real threads. Shutdown can then wait for the flush (still capped by `SHUTDOWN_TIMEOUT`), and the cross-thread wake is allowed. Production code is unchanged. Before the change, locally on macOS: `ITERATIONS=200` failed once, and 1 of 500 separate-process runs failed. After the change: all 200 iterations and 300 separate-process runs (as nextest does) passed. Release Notes: - [GPUI] Fixed a flaky hang monitor shutdown test
This commit is contained in:
@@ -691,6 +691,10 @@ mod tests {
|
||||
fn app_flushes_its_hang_monitor_on_shutdown(cx: &mut TestAppContext) {
|
||||
use super::{HangMonitorConfig, HangMonitorPollReason};
|
||||
|
||||
// The monitor runs on a real OS thread, so shutdown has to park until it
|
||||
// finishes the flush, and its completion wakes the scheduler from that thread.
|
||||
cx.executor().allow_parking();
|
||||
|
||||
let (sender, receiver) = std::sync::mpsc::channel();
|
||||
cx.update(|cx| {
|
||||
cx.start_hang_monitor(
|
||||
|
||||
Reference in New Issue
Block a user