From c327fa459fbab529a018b614ba16d970bc569638 Mon Sep 17 00:00:00 2001 From: Shakib Bin Kabir Date: Thu, 8 Oct 2026 14:37:50 +0600 Subject: [PATCH] Auto-close test: give the two racing timers a full second Two cases sleep for a fixed time and then assert that a pending timer has not fired yet, with 150 ms and 100 ms to spare. On a busy macOS runner the sleep runs long, the timer fires first and the precondition traps: line 27 on the windows-catch-up PR, line 54 on mochi-colours, neither of which touches the state machine. Both timers are now a full second out, so the sleeps only have to outlast what they are there to outlast. The test takes about 1.6 s longer. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/IslandAutoCloseTests.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/IslandAutoCloseTests.swift b/tests/IslandAutoCloseTests.swift index 5e4657a5e..1dfaab8f2 100644 --- a/tests/IslandAutoCloseTests.swift +++ b/tests/IslandAutoCloseTests.swift @@ -20,12 +20,15 @@ enum IslandAutoCloseTests { try await waitForCompact(edited, timeout: 1) // Increasing the delay must also cancel the previous, shorter timer. + // The new delay is a full second: the sleep below only has to outlast + // the old 50 ms timer, and on a busy CI runner a 100 ms sleep can run + // long enough to meet a timer set a few hundred milliseconds out. let extended = openedMachine(delay: 0.05) extended.mouseLeft() - extended.homeToPetitDelay = 0.25 + extended.homeToPetitDelay = 1 try await Task.sleep(for: .milliseconds(100)) precondition(extended.state == .home) - try await waitForCompact(extended, timeout: 1) + try await waitForCompact(extended, timeout: 3) // Returning to the island cancels the countdown; leaving starts it again. let hovered = openedMachine(delay: 0.05) @@ -45,14 +48,15 @@ enum IslandAutoCloseTests { try await waitForCompact(hoveredEdit, timeout: 1) // Greeting timing is independent from the normal auto-close preference. + // A full second here too, for the same reason as above. let greeting = IslandStateMachine() - greeting.greetAutoCollapseDelay = 0.15 + greeting.greetAutoCollapseDelay = 1 greeting.launch() greeting.greetComplete() greeting.homeToPetitDelay = 0.01 try await Task.sleep(for: .milliseconds(50)) precondition(greeting.state == .coucou) - try await waitForCompact(greeting, timeout: 1) + try await waitForCompact(greeting, timeout: 3) // An unanswered approval holds the island open even after a delay edit. let heldOpen = openedMachine(delay: 0.05)