Fix flaky testDynamicPendable#43
Open
gibachan wants to merge 1 commit into
Open
Conversation
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
A unit test
testDynamicPendablefails on Darwin CI (swiftpm_darwin, swiftpm_darwin_15) while Linux environments continue to pass.Root Cause
#30 bumps Nimble to 14.0.0 which changed the
pollBlockimplementation at Quick/Nimble@5a0cc37 .pollBlocknow iterates a fixed number of times instead of checking wall-clock time.The number of iterations is calculated at https://github.com/Quick/Nimble/blob/727f75d91a0f7501d08d938966d17e6728b76a2a/Sources/Nimble/Utils/PollAwait.swift#L196 which evaluates to 100 in this case.
On Darwin CI, each
await managedTask.isFinishedevaluation requires an actor hop which takes additional time (~10ms). This makes the total polling duration approach PendableDefaults.delay (2 seconds):100 × 10ms (eval) + 99 × 10ms (sleep) ≈ 2s
As a result, the
Pendable's fallback resolves during thetoNeverwindow, makingisFinishedbecometrueand failing the assertion. On Linux, actor hops are fast enough that the total duration stays well below 2 seconds.Fix
Replace
toNeverwith deterministic assertions that don't rely on timing. Oncesubject.callshas one entry, the task is definitively suspended waiting for thePendable—isFinishedmust befalseat that point.Checklist - While not every PR needs it, new features should consider this list: