diff --git a/Sources/Testing/Running/Runner.swift b/Sources/Testing/Running/Runner.swift index 8520d1aa..bd1167b8 100644 --- a/Sources/Testing/Running/Runner.swift +++ b/Sources/Testing/Running/Runner.swift @@ -156,7 +156,7 @@ extension Runner { in sequence: some Sequence, _ body: @Sendable @escaping (E) async throws -> Void ) async throws where E: Sendable { - try await withThrowingTaskGroup(of: Void.self) { taskGroup in + try await withThrowingTaskGroup { taskGroup in for element in sequence { // Each element gets its own subtask to run in. _ = taskGroup.addTaskUnlessCancelled { @@ -430,7 +430,7 @@ extension Runner { Event.post(.iterationEnded(iterationIndex), for: (nil, nil), configuration: runner.configuration) } - await withTaskGroup(of: Void.self) { [runner] taskGroup in + await withTaskGroup { [runner] taskGroup in _ = taskGroup.addTaskUnlessCancelled { try? await _runStep(atRootOf: runner.plan.stepGraph) } diff --git a/Sources/Testing/Test+Discovery.swift b/Sources/Testing/Test+Discovery.swift index 35f71652..5e9632d7 100644 --- a/Sources/Testing/Test+Discovery.swift +++ b/Sources/Testing/Test+Discovery.swift @@ -84,7 +84,7 @@ extension Test { // a task group and collate their results. if useNewMode { let generators = Generator.allTestContentRecords().lazy.compactMap { $0.load() } - await withTaskGroup(of: Self.self) { taskGroup in + await withTaskGroup { taskGroup in for generator in generators { taskGroup.addTask { await generator.rawValue() } } @@ -96,7 +96,7 @@ extension Test { // Perform legacy test discovery if needed. if useLegacyMode && result.isEmpty { let generators = Generator.allTypeMetadataBasedTestContentRecords().lazy.compactMap { $0.load() } - await withTaskGroup(of: Self.self) { taskGroup in + await withTaskGroup { taskGroup in for generator in generators { taskGroup.addTask { await generator.rawValue() } } diff --git a/Sources/Testing/Traits/TimeLimitTrait.swift b/Sources/Testing/Traits/TimeLimitTrait.swift index 4e84a1f9..54a200fb 100644 --- a/Sources/Testing/Traits/TimeLimitTrait.swift +++ b/Sources/Testing/Traits/TimeLimitTrait.swift @@ -264,7 +264,7 @@ func withTimeLimit( _ body: @escaping @Sendable () async throws -> Void, timeoutHandler: @escaping @Sendable () -> Void ) async throws { - try await withThrowingTaskGroup(of: Void.self) { group in + try await withThrowingTaskGroup { group in group.addTask { // If sleep() returns instead of throwing a CancellationError, that means // the timeout was reached before this task could be cancelled, so call diff --git a/Tests/TestingTests/Support/CartesianProductTests.swift b/Tests/TestingTests/Support/CartesianProductTests.swift index b817b37f..3cb4f6da 100644 --- a/Tests/TestingTests/Support/CartesianProductTests.swift +++ b/Tests/TestingTests/Support/CartesianProductTests.swift @@ -96,7 +96,7 @@ struct CartesianProductTests { // Test that the product can be iterated multiple times concurrently. let (_, _, product) = computeCartesianProduct() let expectedSum = product.reduce(into: 0) { $0 &+= $1.1 } - await withTaskGroup(of: Int.self) { taskGroup in + await withTaskGroup { taskGroup in for _ in 0 ..< 10 { taskGroup.addTask { product.reduce(into: 0) { $0 &+= $1.1 } diff --git a/Tests/TestingTests/Support/LockTests.swift b/Tests/TestingTests/Support/LockTests.swift index 0113745e..2a41e4c1 100644 --- a/Tests/TestingTests/Support/LockTests.swift +++ b/Tests/TestingTests/Support/LockTests.swift @@ -36,7 +36,7 @@ struct LockTests { @Test("No lock") func noLock() async { let lock = LockedWith(rawValue: 0) - await withTaskGroup(of: Void.self) { taskGroup in + await withTaskGroup { taskGroup in for _ in 0 ..< 100_000 { taskGroup.addTask { lock.increment() diff --git a/Tests/TestingTests/Traits/TimeLimitTraitTests.swift b/Tests/TestingTests/Traits/TimeLimitTraitTests.swift index b29ccb93..49412b6a 100644 --- a/Tests/TestingTests/Traits/TimeLimitTraitTests.swift +++ b/Tests/TestingTests/Traits/TimeLimitTraitTests.swift @@ -181,7 +181,7 @@ struct TimeLimitTraitTests { @Test("Cancelled tests can exit early (cancellation checking works)") func cancelledTestExitsEarly() async throws { let timeAwaited = await Test.Clock().measure { - await withTaskGroup(of: Void.self) { taskGroup in + await withTaskGroup { taskGroup in taskGroup.addTask { await Test { try await Test.Clock.sleep(for: .seconds(60) * 60)