@@ -185,7 +185,7 @@ public enum TestOutput: String, ExpressibleByArgument {
185
185
}
186
186
187
187
/// swift-test tool namespace
188
- public struct SwiftTestTool : AsyncSwiftCommand {
188
+ public struct SwiftTestTool : SwiftCommand {
189
189
public static var configuration = CommandConfiguration (
190
190
commandName: " test " ,
191
191
_superCommandName: " swift " ,
@@ -206,7 +206,7 @@ public struct SwiftTestTool: AsyncSwiftCommand {
206
206
207
207
// MARK: - XCTest
208
208
209
- private func xctestRun( _ swiftTool: SwiftTool ) async throws {
209
+ private func xctestRun( _ swiftTool: SwiftTool ) throws {
210
210
// validate XCTest available on darwin based systems
211
211
let toolchain = try swiftTool. getTargetToolchain ( )
212
212
let isHostTestingAvailable = try swiftTool. getHostToolchain ( ) . swiftSDK. supportsTesting
@@ -224,13 +224,7 @@ public struct SwiftTestTool: AsyncSwiftCommand {
224
224
let testProducts = try buildTestsIfNeeded ( swiftTool: swiftTool, library: . xctest)
225
225
if !self . options. shouldRunInParallel {
226
226
let xctestArgs = try xctestArgs ( for: testProducts, swiftTool: swiftTool)
227
- try await runTestProducts (
228
- testProducts,
229
- additionalArguments: xctestArgs,
230
- buildParameters: buildParameters,
231
- swiftTool: swiftTool,
232
- library: . xctest
233
- )
227
+ try runTestProducts ( testProducts, additionalArguments: xctestArgs, buildParameters: buildParameters, swiftTool: swiftTool, library: . xctest)
234
228
} else {
235
229
let testSuites = try TestingSupport . getTestSuites (
236
230
in: testProducts,
@@ -275,7 +269,7 @@ public struct SwiftTestTool: AsyncSwiftCommand {
275
269
276
270
// process code Coverage if request
277
271
if self . options. enableCodeCoverage, runner. ranSuccessfully {
278
- try await processCodeCoverage ( testProducts, swiftTool: swiftTool, library: . xctest)
272
+ try processCodeCoverage ( testProducts, swiftTool: swiftTool, library: . xctest)
279
273
}
280
274
281
275
if !runner. ranSuccessfully {
@@ -340,22 +334,16 @@ public struct SwiftTestTool: AsyncSwiftCommand {
340
334
341
335
// MARK: - swift-testing
342
336
343
- private func swiftTestingRun( _ swiftTool: SwiftTool ) async throws {
337
+ private func swiftTestingRun( _ swiftTool: SwiftTool ) throws {
344
338
let buildParameters = try swiftTool. buildParametersForTest ( options: self . options, library: . swiftTesting)
345
339
let testProducts = try buildTestsIfNeeded ( swiftTool: swiftTool, library: . swiftTesting)
346
340
let additionalArguments = Array ( CommandLine . arguments. dropFirst ( ) )
347
- try await runTestProducts (
348
- testProducts,
349
- additionalArguments: additionalArguments,
350
- buildParameters: buildParameters,
351
- swiftTool: swiftTool,
352
- library: . swiftTesting
353
- )
341
+ try runTestProducts ( testProducts, additionalArguments: additionalArguments, buildParameters: buildParameters, swiftTool: swiftTool, library: . swiftTesting)
354
342
}
355
343
356
344
// MARK: - Common implementation
357
345
358
- public func run( _ swiftTool: SwiftTool ) async throws {
346
+ public func run( _ swiftTool: SwiftTool ) throws {
359
347
do {
360
348
// Validate commands arguments
361
349
try self . validateArguments ( observabilityScope: swiftTool. observabilityScope)
@@ -365,28 +353,22 @@ public struct SwiftTestTool: AsyncSwiftCommand {
365
353
}
366
354
367
355
if self . options. shouldPrintCodeCovPath {
368
- try await printCodeCovPath ( swiftTool)
356
+ try printCodeCovPath ( swiftTool)
369
357
} else if self . options. _deprecated_shouldListTests {
370
358
// backward compatibility 6/2022 for deprecation of flag into a subcommand
371
359
let command = try List . parse ( )
372
360
try command. run ( swiftTool)
373
361
} else {
374
362
if options. sharedOptions. enableSwiftTestingLibrarySupport {
375
- try await swiftTestingRun ( swiftTool)
363
+ try swiftTestingRun ( swiftTool)
376
364
}
377
365
if options. sharedOptions. enableXCTestSupport {
378
- try await xctestRun ( swiftTool)
366
+ try xctestRun ( swiftTool)
379
367
}
380
368
}
381
369
}
382
370
383
- private func runTestProducts(
384
- _ testProducts: [ BuiltTestProduct ] ,
385
- additionalArguments: [ String ] ,
386
- buildParameters: BuildParameters ,
387
- swiftTool: SwiftTool ,
388
- library: BuildParameters . Testing . Library
389
- ) async throws {
371
+ private func runTestProducts( _ testProducts: [ BuiltTestProduct ] , additionalArguments: [ String ] , buildParameters: BuildParameters , swiftTool: SwiftTool , library: BuildParameters . Testing . Library ) throws {
390
372
// Clean out the code coverage directory that may contain stale
391
373
// profraw files from a previous run of the code coverage tool.
392
374
if self . options. enableCodeCoverage {
@@ -421,7 +403,7 @@ public struct SwiftTestTool: AsyncSwiftCommand {
421
403
}
422
404
423
405
if self . options. enableCodeCoverage, ranSuccessfully {
424
- try await processCodeCoverage ( testProducts, swiftTool: swiftTool, library: library)
406
+ try processCodeCoverage ( testProducts, swiftTool: swiftTool, library: library)
425
407
}
426
408
427
409
if self . options. enableExperimentalTestOutput, !ranSuccessfully {
@@ -461,18 +443,16 @@ public struct SwiftTestTool: AsyncSwiftCommand {
461
443
}
462
444
463
445
/// Processes the code coverage data and emits a json.
464
- private func processCodeCoverage(
465
- _ testProducts: [ BuiltTestProduct ] ,
466
- swiftTool: SwiftTool ,
467
- library: BuildParameters . Testing . Library
468
- ) async throws {
446
+ private func processCodeCoverage( _ testProducts: [ BuiltTestProduct ] , swiftTool: SwiftTool , library: BuildParameters . Testing . Library ) throws {
469
447
let workspace = try swiftTool. getActiveWorkspace ( )
470
448
let root = try swiftTool. getWorkspaceRoot ( )
471
- let rootManifests = try await workspace. loadRootManifests (
472
- packages: root. packages,
473
- observabilityScope: swiftTool. observabilityScope
474
- )
475
-
449
+ let rootManifests = try temp_await {
450
+ workspace. loadRootManifests (
451
+ packages: root. packages,
452
+ observabilityScope: swiftTool. observabilityScope,
453
+ completion: $0
454
+ )
455
+ }
476
456
guard let rootManifest = rootManifests. values. first else {
477
457
throw StringError ( " invalid manifests at \( root. packages) " )
478
458
}
@@ -568,14 +548,16 @@ public struct SwiftTestTool: AsyncSwiftCommand {
568
548
}
569
549
570
550
extension SwiftTestTool {
571
- func printCodeCovPath( _ swiftTool: SwiftTool ) async throws {
551
+ func printCodeCovPath( _ swiftTool: SwiftTool ) throws {
572
552
let workspace = try swiftTool. getActiveWorkspace ( )
573
553
let root = try swiftTool. getWorkspaceRoot ( )
574
- let rootManifests = try await workspace. loadRootManifests (
575
- packages: root. packages,
576
- observabilityScope: swiftTool. observabilityScope
577
- )
578
-
554
+ let rootManifests = try temp_await {
555
+ workspace. loadRootManifests (
556
+ packages: root. packages,
557
+ observabilityScope: swiftTool. observabilityScope,
558
+ completion: $0
559
+ )
560
+ }
579
561
guard let rootManifest = rootManifests. values. first else {
580
562
throw StringError ( " invalid manifests at \( root. packages) " )
581
563
}
0 commit comments