From e185c80bdb457dd06ba99e7fbcbba0d2d090f237 Mon Sep 17 00:00:00 2001 From: Filip Bodor Date: Thu, 15 Oct 2026 16:26:17 +0200 Subject: [PATCH] test: widen the real-time bounds of the conformance helpers The iOS simulator job failed twice on "invariant 6: a request of an ended session that never answers cannot block the next session" (.signOutThenSignIn): finishes(next) gave up after 2 s of real time. The log shows the next session's refresh rotating its token right after the failure, so the manager was correct and the bound was too short. On the CI simulator the parallel run is starved: trivial tests report 4 to 10 s. finishes, waitUntil and the sleeper wait in the hung-policy test check something that either happens soon or stays false until the test intervenes, so a long bound only delays a real failure. Raise them to 30 s, well inside the suites' one-minute time limit. --- Tests/ConformanceTests/AcceptanceTests.swift | 2 +- Tests/ConformanceTests/Stores.swift | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tests/ConformanceTests/AcceptanceTests.swift b/Tests/ConformanceTests/AcceptanceTests.swift index ab389bd..5bab22e 100644 --- a/Tests/ConformanceTests/AcceptanceTests.swift +++ b/Tests/ConformanceTests/AcceptanceTests.swift @@ -22,7 +22,7 @@ struct AcceptanceTests { let manager = harness.manager let target = TokenTarget.refreshGrant(resources: [apiA]) let hanging = Task { try await manager.accessToken(for: target) } - #expect(await harness.clock.waitForSleeper(timeout: .seconds(2)), "the policy has no time limit") + #expect(await harness.clock.waitForSleeper(timeout: .seconds(30)), "the policy has no time limit") harness.clock.advance(by: .seconds(10)) let isDone = await finishes(hanging) gate.open() diff --git a/Tests/ConformanceTests/Stores.swift b/Tests/ConformanceTests/Stores.swift index 5907c21..76d16c3 100644 --- a/Tests/ConformanceTests/Stores.swift +++ b/Tests/ConformanceTests/Stores.swift @@ -61,7 +61,7 @@ actor GatedStore: CredentialStore { /// Polls `condition` until it holds. Gives up after `timeout` of real time, so a broken implementation fails the /// test instead of hanging it. Yields between polls; never sleeps. -func waitUntil(timeout: Duration = .seconds(5), _ condition: () async -> Bool) async -> Bool { +func waitUntil(timeout: Duration = .seconds(30), _ condition: () async -> Bool) async -> Bool { let deadline = ContinuousClock.now.advanced(by: timeout) while ContinuousClock.now < deadline { if await condition() { return true } @@ -72,8 +72,12 @@ func waitUntil(timeout: Duration = .seconds(5), _ condition: () async -> Bool) a /// Whether `task` finishes (with a value or an error) within `timeout` of real time. Unlike awaiting the task, a /// task that never finishes makes this return `false` instead of hanging the test. +/// +/// The default is generous on purpose: callers check a task that is either served soon or blocked until the +/// test intervenes, so a long bound only delays a real failure, while a short one fails a correct run on a +/// loaded machine (a parallel run on a CI simulator can take seconds to schedule a task). func finishes( - _ task: Task, within timeout: Duration = .seconds(2) + _ task: Task, within timeout: Duration = .seconds(30) ) async -> Bool { let flag = Flag() Task {