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 {