Repository navigation
make three timing-dependent tests assert behaviour instead of wall-clock bounds - #237
Merged
Merged
Conversation
testDownloadProgressWithEmptyTracks asserted that nothing was published by waiting 1 s on main with a 2 s timeout. On iOS 26.5 CI the main queue did not run that block within 2 s (runs of 8.0 s and 17.9 s), so the test failed while the service published nothing. The test now waits on whenPendingWorkDrains, a new internal hook that runs a block after every barrier already on the service's queue and the main-queue hops those blocks scheduled. The 30 s timeout is a hang bound, not the window being measured.
test_saveSuppression_whenItLapses_theNextDueTickWrites needed 20 s of simulated ticks to be delivered within a real 0.4 s window. On a slow run the window lapsed part way through and the premise assertion failed. AudiobookPlaybackModel reads the suppression window through wallClock, which defaults to Date(), so production behaviour is unchanged. The test pins the clock while the window should hold and advances it to lapse the window.
testContentInfo_WhenLengthLookupFailsLate_FinishesWithoutLength relied on a 0.4 s lookup outlasting a 0.1 s stall timeout, and its 2-byte data range raced the data phase's own 0.1 s stall timer. On ios-core's macos-15 run 36911638959 it took 37.7 s and reported the request unfinished after the 5 s bound. The lookup now parks until the test releases it, after at least five stall timeouts have passed with the request still open. The request asks for content information only, so no data-phase timer is involved, and the final wait is a 30 s hang bound.
mauricecarrier7
added a commit
to ThePalaceProject/ios-core
that referenced
this pull request
Oct 1, 2026
Picks up ThePalaceProject/ios-audiobooktoolkit#237. That PR rewrites three toolkit tests that failed this branch's toolkit-tests job on iOS 26.5, and macos-15, because they depended on wall-clock windows. It also brings in #235 and #236, which change only the toolkit's own CI workflow.
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.
What
Three toolkit tests failed on CI because of wall-clock timing, not because of a code defect. Each one now waits for the event it is about, or uses an injected clock.
AudiobookNetworkServiceTest.testDownloadProgressWithEmptyTracksasyncAfteron main had to fire within a 2 s wait. On iOS 26.5 it did not (runs of 8.0 s and 17.9 s).whenPendingWorkDrains, a new internal hook onDefaultAudiobookNetworkServicethat runs a block after the queue's pending barriers and their main-queue hops. It then asserts that nothing was published.AudiobookPlaybackModelAutosaveTests.test_saveSuppression_whenItLapses_theNextDueTickWritesAudiobookPlaybackModelreads the window throughwallClock, which defaults toDate(). The test pins that clock while the window holds and then advances it.LCPResourceLoaderStallTests.testContentInfo_WhenLengthLookupFailsLate_FinishesWithoutLengthWhy
ios-core is moving CI to Xcode 26.6 and iOS 26.5, and its
toolkit-testsjob failed on these tests. The third test also failed on the current macos-15 runner, so it is not specific to iOS 26.Production changes
Two small seams, both with unchanged default behaviour:
DefaultAudiobookNetworkService.whenPendingWorkDrains(_:): internal and only called by tests.AudiobookPlaybackModel.wallClock: defaults toDate(). Only the save-suppression window reads it. The other suppression windows still callDate()directly.Verification
Executed 315 tests, with 1 test skipped and 0 failures,** TEST SUCCEEDED **..downloadCompleteat startup: the network test fails because it received[downloadComplete].XCTUnwrapfails because the first due tick did not write.XCTAssertNil(outcome)fails withtransferStalled.XCTAssertNil(contentLength)fails.Not done: the other suppression windows in
AudiobookPlaybackModelstill readDate()directly, and I did not change any other wall-clock tests in the suite.