Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

done compatible with Sendable #1159

Merged
merged 2 commits into from
Dec 12, 2024
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
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 @@
}
}

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

Check warning on line 195 in Tests/NimbleTests/AsyncAwaitTest.swift

View workflow job for this annotation

GitHub Actions / lint

Identifier Name Violation: Variable name 'op' should be between 3 and 50 characters long (identifier_name)
op.completionBlock = done
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • On Swift5:
    • Before
      • Warning: Assigning non-sendable parameter 'done' to a @Sendable closure
    • After
      • No-Warning

queue.addOperation(op)
}
}

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