diff --git a/Sources/Nimble/DSL+AsyncAwait.swift b/Sources/Nimble/DSL+AsyncAwait.swift index 522e4af53..57b4213df 100644 --- a/Sources/Nimble/DSL+AsyncAwait.swift +++ b/Sources/Nimble/DSL+AsyncAwait.swift @@ -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, @@ -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, @@ -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, diff --git a/Tests/NimbleTests/AsyncAwaitTest.swift b/Tests/NimbleTests/AsyncAwaitTest.swift index d88d4b9a3..7af280623 100644 --- a/Tests/NimbleTests/AsyncAwaitTest.swift +++ b/Tests/NimbleTests/AsyncAwaitTest.swift @@ -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 }