Skip to content
Closed
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
4 changes: 2 additions & 2 deletions Sources/Testing/Running/Runner.RuntimeState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ extension Test {
/// - Returns: Whatever is returned by `body`.
///
/// - Throws: Whatever is thrown by `body`.
static func withCurrent<R>(_ test: Self, perform body: () async throws -> R) async rethrows -> R {
static nonisolated(nonsending) func withCurrent<R>(_ test: Self, perform body: nonisolated(nonsending) () async throws -> R) async rethrows -> R {
var runtimeState = Runner.RuntimeState.current ?? .init()
runtimeState.test = test
runtimeState.testCase = nil
Expand Down Expand Up @@ -239,7 +239,7 @@ extension Test.Case {
/// - Returns: Whatever is returned by `body`.
///
/// - Throws: Whatever is thrown by `body`.
static func withCurrent<R>(_ testCase: Self, perform body: () async throws -> R) async rethrows -> R {
static func withCurrent<R>(_ testCase: Self, perform body: nonisolated(nonsending) () async throws -> R) async rethrows -> R {
var runtimeState = Runner.RuntimeState.current ?? .init()
runtimeState.testCase = testCase
return try await Runner.RuntimeState.$current.withValue(runtimeState) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Testing/Test+Cancellation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extension TestCancellable {
/// This function sets up a task cancellation handler and calls `body`. If
/// the current task, test, or test case is cancelled, it records a
/// corresponding cancellation event.
func withCancellationHandling<R>(_ body: () async throws -> R) async rethrows -> R {
nonisolated(nonsending) func withCancellationHandling<R>(_ body: nonisolated(nonsending) () async throws -> R) async rethrows -> R {
let taskCanceller = _TaskCanceller()
var currentTaskCancellers = _currentTaskCancellers
currentTaskCancellers[ObjectIdentifier(Self.self)] = taskCanceller
Expand Down
9 changes: 7 additions & 2 deletions Sources/Testing/Test+Discovery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ extension Test {
await generator.rawValue()
}
}
result = await taskGroup.reduce(into: result) { $0.insert($1) }
for await task in taskGroup {
result.insert(task)
}
}
}

Expand All @@ -104,7 +106,10 @@ extension Test {
await generator.rawValue()
}
}
result = await taskGroup.reduce(into: result) { $0.insert($1) }
// result = await taskGroup.reduce(into: result) { $0.insert($1) } // TODO: reduce is not usable since it sends taskGroup
for await task in taskGroup {
result.insert(task)
}
}
}
#endif
Expand Down
Loading