Swift Testing: a wall-clock deadline in a @MainActor polling loop flakes under main-actor starvation
Pattern: a @MainActor test waits for a debounced Task by looping while condition is false and ContinuousClock.now < deadline, with Task.sleep(5 ms) between checks. Under extreme host load the main actor can be starved for longer than the deadline. When it resumes, the test loop may run before the debounced task, see the deadline already passed, and continue with the wrong state, so the test fails as if the code under test never ran. It is deterministic-looking: it failed 4 times in a row at load ~500 and passed every time at normal load on identical code. Diagnose by tracing timestamps in the hooks. Fix: use generous deadlines (60 s or more), or await an explicit signal (a continuation or AsyncStream) from the hook instead of polling a wall clock.