@@ -615,7 +615,8 @@ extension SwiftTestTool {
615
615
// MARK: - XCTest
616
616
617
617
private func xctestRun( _ swiftTool: SwiftTool ) throws {
618
- let testProducts = try buildTestsIfNeeded ( swiftTool: swiftTool, library: . xctest)
618
+ let buildParameters = try swiftTool. buildParametersForTest ( enableCodeCoverage: false , shouldSkipBuilding: sharedOptions. shouldSkipBuilding, library: . xctest)
619
+ let testProducts = try buildTestsIfNeeded ( swiftTool: swiftTool, buildParameters: buildParameters)
619
620
let testSuites = try TestingSupport . getTestSuites (
620
621
in: testProducts,
621
622
swiftTool: swiftTool,
@@ -634,7 +635,35 @@ extension SwiftTestTool {
634
635
// MARK: - swift-testing
635
636
636
637
private func swiftTestingRun( _ swiftTool: SwiftTool ) throws {
637
- throw StringError ( " swift test list is not yet implemented for swift-testing " )
638
+ let buildParameters = try swiftTool. buildParametersForTest ( enableCodeCoverage: false , shouldSkipBuilding: sharedOptions. shouldSkipBuilding, library: . swiftTesting)
639
+ let testProducts = try buildTestsIfNeeded ( swiftTool: swiftTool, buildParameters: buildParameters)
640
+
641
+ let toolchain = try swiftTool. getTargetToolchain ( )
642
+ let testEnv = try TestingSupport . constructTestEnvironment (
643
+ toolchain: toolchain,
644
+ buildParameters: buildParameters,
645
+ sanitizers: globalOptions. build. sanitizers
646
+ )
647
+
648
+ let runner = TestRunner (
649
+ bundlePaths: testProducts. map ( \. binaryPath) ,
650
+ additionalArguments: [ " --list-tests " ] ,
651
+ cancellator: swiftTool. cancellator,
652
+ toolchain: toolchain,
653
+ testEnv: testEnv,
654
+ observabilityScope: swiftTool. observabilityScope,
655
+ library: . swiftTesting
656
+ )
657
+
658
+ // Finally, run the tests.
659
+ let ranSuccessfully = runner. test ( outputHandler: {
660
+ // command's result output goes on stdout
661
+ // ie "swift test" should output to stdout
662
+ print ( $0)
663
+ } )
664
+ if !ranSuccessfully {
665
+ swiftTool. executionStatus = . failure
666
+ }
638
667
}
639
668
640
669
// MARK: - Common implementation
@@ -648,8 +677,7 @@ extension SwiftTestTool {
648
677
}
649
678
}
650
679
651
- private func buildTestsIfNeeded( swiftTool: SwiftTool , library: BuildParameters . Testing . Library ) throws -> [ BuiltTestProduct ] {
652
- let buildParameters = try swiftTool. buildParametersForTest ( enableCodeCoverage: false , shouldSkipBuilding: sharedOptions. shouldSkipBuilding, library: library)
680
+ private func buildTestsIfNeeded( swiftTool: SwiftTool , buildParameters: BuildParameters ) throws -> [ BuiltTestProduct ] {
653
681
return try Commands . buildTestsIfNeeded ( swiftTool: swiftTool, buildParameters: buildParameters, testProduct: self . sharedOptions. testProduct)
654
682
}
655
683
}
0 commit comments