Skip to content

Commit 46c6452

Browse files
committed
Use IssueHandlingTrait within unit tests
1 parent fccc9c5 commit 46c6452

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

Tests/PropertyBasedTests/Utils.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,22 @@ import Testing
99

1010
@testable import PropertyBased
1111

12-
func gatherIssues(block: @Sendable () async throws -> Void) async -> [String] {
12+
func gatherIssues(isolation: isolated (any Actor)? = #isolation, block: () async throws -> Void) async -> [String] {
1313
let mutex = Mutex([] as [String])
1414

15-
// No way to stop issues from still being recorded. Ignore those for now.
16-
await withKnownIssue(isIntermittent: true) {
15+
#if swift(>=6.2)
16+
nonisolated(unsafe) let closure = block
17+
18+
let handler = IssueHandlingTrait.filterIssues { issue in
19+
mutex.withLock { $0.append(issue.description) }
20+
return false
21+
}
22+
23+
try? await handler.provideScope(for: Test.current!, testCase: Test.Case.current) {
24+
try await run(closure, in: isolation)
25+
}
26+
#else
27+
await withKnownIssue(isIntermittent: true, isolation: isolation) {
1728
do {
1829
try await block()
1930
} catch {
@@ -23,6 +34,7 @@ func gatherIssues(block: @Sendable () async throws -> Void) async -> [String] {
2334
mutex.withLock { $0.append(issue.description) }
2435
return true
2536
}
37+
#endif
2638

2739
return mutex.withLock { $0 }
2840
}

0 commit comments

Comments
 (0)