Repository navigation
test: keep timing tests reliable while other tests hold the main actor - #109
Merged
Merged
Conversation
Swift Testing runs the tests in parallel, and almost all of them share the main actor. On CI the native rendering tests hold it so long that a test can wait seconds for its next turn, so three tests that bounded that wait with the clock failed on main and in pull requests. - The failure streak test gave runs that fail at once 300 ms before they counted as steady. They now get 60 seconds; only the run that has to stay open gets 300 ms. - The temporary output test let a 10-second deadline pass while the expiry waited behind its poll. expiry(of:) now counts polls instead, and the test uses it. - The widget actions test timed out its first action after 4 seconds, before the test released it. The timeout is now 60 seconds, and stopping the store still ends the action.
|
🎉 This PR is included in version 0.5.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since 2026-10-17, CI has failed on
mainafter merging #66, #98, #102 and #108, and in pull requests, with no real regression (the run for #108, for example). Three tests flake:aContinuousRunThatStayedOpenStartsANewFailureStreakWhenItFailsnextDelayis 1.0 instead of 2.0temporaryOutputShowsItsFieldsForItsDurationThenExpireswidgetActionsRunInOrderAndStoppingCancelsQueuedWorkSwift Testing runs the tests in parallel, and almost all of them are
@MainActor, so they take turns on one thread. On the CI runner the native rendering tests hold it so long that tests which never wait report 2 to 14 seconds spent waiting for their turn. This part of the run grew from 8 seconds on 10-17 to 24–36 seconds. Each of these tests bounded that wait with the clock: 300 ms before a run counts as steady, a 10-second deadline for a 1-second expiry, and a 4-second timeout on an action the test releases.Changes
Tests only. Each test still checks the same behavior, without timing the main actor:
DataSourceTests): the two runs that fail at once get 60 seconds before they count as steady, so waiting for the main actor can't make them steady. Only the run that has to stay open gets 300 ms. Its 400 ms sleep is a minimum, which delays only lengthen.PresentationTests):expiry(of:)counts polls instead of watching a deadline. When the main actor stalls, the expiry runs before the next poll, while a deadline could pass first. The test uses this helper instead of its own 10-second loop, and the helper's other caller,theSameTemporaryOutputShowsAgainAfterItExpires, gets the same fix.ScriptEventTests): the action the test releases now times out after 60 seconds instead of 4.store.stop()still ends it if the test fails early.Testing
swift test --filter. All three failed with the same messages and lines as on CI. With this change, the same pairs pass in three rounds each. The scratch test isn't committed.swift test --filteron the four tests this changes passes, as fast as before (0.1–1.4 seconds each).ScriptWidgetso that a failure never starts a new streak, then so that every continuous failure does. The failure streak test still fails for both.Merging
Any method works: it's one
test:commit whose message matches the title, and it makes no release.Claude Opus 5.5 via Claude Code