Skip to content

Commit

Permalink
done compatible with Sendable (#1159)
Browse files Browse the repository at this point in the history
Co-authored-by: Rachel Brindle <you@subluminal.net>
  • Loading branch information
soranoba and younata authored Dec 12, 2024
1 parent 9aaef11 commit fd4a97e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/Nimble/DSL+AsyncAwait.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public func waitUntil(
file: FileString = #filePath,
line: UInt = #line,
column: UInt = #column,
action: @escaping (@escaping () -> Void) async -> Void
action: @escaping (@escaping @Sendable () -> Void) async -> Void
) async {
await throwableUntil(
timeout: timeout,
Expand All @@ -116,7 +116,7 @@ public func waitUntil(
file: FileString = #filePath,
line: UInt = #line,
column: UInt = #column,
action: @escaping (@escaping () -> Void) -> Void
action: @escaping (@escaping @Sendable () -> Void) -> Void
) async {
await throwableUntil(
timeout: timeout,
Expand All @@ -134,7 +134,7 @@ private enum ErrorResult {
private func throwableUntil(
timeout: NimbleTimeInterval,
sourceLocation: SourceLocation,
action: @escaping (@escaping () -> Void) async throws -> Void) async {
action: @escaping (@escaping @Sendable () -> Void) async throws -> Void) async {
let leeway = timeout.divided
let result = await performBlock(
timeoutInterval: timeout,
Expand Down
9 changes: 9 additions & 0 deletions Tests/NimbleTests/AsyncAwaitTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ final class AsyncAwaitTest: XCTestCase { // swiftlint:disable:this type_body_len
}
}

func testWaitUntilUsingSendable() async {
await waitUntil { done in
let queue = OperationQueue()
let op = BlockOperation {}
op.completionBlock = done
queue.addOperation(op)
}
}

func testWaitUntilTimesOutIfNotCalled() async {
await failsWithErrorMessage("Waited more than 1.0 second") {
await waitUntil(timeout: .seconds(1)) { _ in return }
Expand Down

0 comments on commit fd4a97e

Please sign in to comment.