Skip to content

Commit

Permalink
done compatible with Sendable
Browse files Browse the repository at this point in the history
  • Loading branch information
soranoba committed Sep 24, 2024
1 parent cecacf0 commit 6254a6d
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 6254a6d

Please sign in to comment.