Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tests/ConformanceTests/AcceptanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 6 additions & 2 deletions Tests/ConformanceTests/Stores.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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<Value: Sendable, Failure: Error>(
_ task: Task<Value, Failure>, within timeout: Duration = .seconds(2)
_ task: Task<Value, Failure>, within timeout: Duration = .seconds(30)
) async -> Bool {
let flag = Flag()
Task {
Expand Down
Loading