1010//
1111//===----------------------------------------------------------------------===//
1212
13- import Dispatch
1413import SwiftParser
1514import SwiftParserDiagnostics
1615import SwiftSyntax
@@ -59,8 +58,8 @@ class ParserTests: ParserTestCase {
5958 name: String ,
6059 path: URL ,
6160 checkDiagnostics: Bool ,
62- shouldExclude: @Sendable ( URL ) -> Bool = { _ in false }
63- ) {
61+ shouldExclude: @escaping @ Sendable ( URL ) -> Bool = { _ in false }
62+ ) async throws {
6463 let fileURLs = FileManager . default
6564 . enumerator ( at: path, includingPropertiesForKeys: nil ) !
6665 . compactMap ( { $0 as? URL } )
@@ -71,16 +70,15 @@ class ParserTests: ParserTestCase {
7170 }
7271
7372 print ( " \( name) - processing \( fileURLs. count) source files " )
74- DispatchQueue . concurrentPerform ( iterations: fileURLs. count) { fileURLIndex in
75- let fileURL = fileURLs [ fileURLIndex]
76- if shouldExclude ( fileURL) {
77- return
78- }
79-
80- do {
81- try Self . runParseTest ( fileURL: fileURL, checkDiagnostics: checkDiagnostics)
82- } catch {
83- XCTFail ( " \( name) : \( fileURL) failed due to \( error) " )
73+ await withTaskGroup ( of: Void . self) { group in
74+ for fileURL in fileURLs where !shouldExclude( fileURL) {
75+ group. addTask {
76+ do {
77+ try Self . runParseTest ( fileURL: fileURL, checkDiagnostics: checkDiagnostics)
78+ } catch {
79+ XCTFail ( " \( name) : \( fileURL) failed due to \( error) " )
80+ }
81+ }
8482 }
8583 }
8684 }
@@ -90,14 +88,14 @@ class ParserTests: ParserTestCase {
9088 . deletingLastPathComponent ( )
9189 . deletingLastPathComponent ( )
9290
93- func testSelfParse( ) throws {
91+ func testSelfParse( ) async throws {
9492 // Allow skipping the self parse test in local development environments
9593 // because it takes very long compared to all the other tests.
9694 try XCTSkipIf ( longTestsDisabled)
9795 let currentDir =
9896 packageDir
9997 . appendingPathComponent ( " Sources " )
100- runParserTests (
98+ try await runParserTests (
10199 name: " Self-parse tests " ,
102100 path: currentDir,
103101 checkDiagnostics: true
@@ -107,14 +105,14 @@ class ParserTests: ParserTestCase {
107105 /// Test all of the files in the "test" directory of the main Swift compiler.
108106 /// This requires the Swift compiler to have been checked out into the "swift"
109107 /// directory alongside swift-syntax.
110- func testSwiftTestsuite( ) throws {
108+ func testSwiftTestsuite( ) async throws {
111109 try XCTSkipIf ( longTestsDisabled)
112110 let testDir =
113111 packageDir
114112 . deletingLastPathComponent ( )
115113 . appendingPathComponent ( " swift " )
116114 . appendingPathComponent ( " test " )
117- runParserTests (
115+ try await runParserTests (
118116 name: " Swift tests " ,
119117 path: testDir,
120118 checkDiagnostics: false
@@ -124,14 +122,14 @@ class ParserTests: ParserTestCase {
124122 /// Test all of the files in the "validation-text" directory of the main
125123 /// Swift compiler. This requires the Swift compiler to have been checked
126124 /// out into the "swift" directory alongside swift-syntax.
127- func testSwiftValidationTestsuite( ) throws {
125+ func testSwiftValidationTestsuite( ) async throws {
128126 try XCTSkipIf ( longTestsDisabled)
129127 let testDir =
130128 packageDir
131129 . deletingLastPathComponent ( )
132130 . appendingPathComponent ( " swift " )
133131 . appendingPathComponent ( " validation-test " )
134- runParserTests (
132+ try await runParserTests (
135133 name: " Swift validation tests " ,
136134 path: testDir,
137135 checkDiagnostics: false
0 commit comments