@@ -237,32 +237,45 @@ public struct SwiftTestTool: SwiftCommand {
237
237
let tests = try testSuites
238
238
. filteredTests ( specifier: options. testCaseSpecifier)
239
239
. skippedTests ( specifier: options. skippedTests ( fileSystem: swiftTool. fileSystem) )
240
+ var testResults = [ ParallelTestRunner . TestResult] ( )
240
241
241
242
// If there were no matches, emit a warning and exit.
242
243
if tests. isEmpty {
243
244
swiftTool. observabilityScope. emit ( . noMatchingTests)
244
- return
245
- }
245
+ } else {
246
+ // Clean out the code coverage directory that may contain stale
247
+ // profraw files from a previous run of the code coverage tool.
248
+ if self . options. enableCodeCoverage {
249
+ try swiftTool. fileSystem. removeFileTree ( buildParameters. codeCovPath)
250
+ }
246
251
247
- // Clean out the code coverage directory that may contain stale
248
- // profraw files from a previous run of the code coverage tool.
249
- if self . options. enableCodeCoverage {
250
- try swiftTool. fileSystem. removeFileTree ( buildParameters. codeCovPath)
251
- }
252
+ // Run the tests using the parallel runner.
253
+ let runner = ParallelTestRunner (
254
+ bundlePaths: testProducts. map { $0. bundlePath } ,
255
+ cancellator: swiftTool. cancellator,
256
+ toolchain: toolchain,
257
+ numJobs: options. numberOfWorkers ?? ProcessInfo . processInfo. activeProcessorCount,
258
+ buildOptions: globalOptions. build,
259
+ buildParameters: buildParameters,
260
+ shouldOutputSuccess: swiftTool. logLevel <= . info,
261
+ observabilityScope: swiftTool. observabilityScope
262
+ )
252
263
253
- // Run the tests using the parallel runner.
254
- let runner = ParallelTestRunner (
255
- bundlePaths: testProducts. map { $0. bundlePath } ,
256
- cancellator: swiftTool. cancellator,
257
- toolchain: toolchain,
258
- numJobs: options. numberOfWorkers ?? ProcessInfo . processInfo. activeProcessorCount,
259
- buildOptions: globalOptions. build,
260
- buildParameters: buildParameters,
261
- shouldOutputSuccess: swiftTool. logLevel <= . info,
262
- observabilityScope: swiftTool. observabilityScope
263
- )
264
+ testResults = try runner. run ( tests)
265
+
266
+ // process code Coverage if request
267
+ if self . options. enableCodeCoverage, runner. ranSuccessfully {
268
+ try processCodeCoverage ( testProducts, swiftTool: swiftTool, library: . xctest)
269
+ }
264
270
265
- let testResults = try runner. run ( tests)
271
+ if !runner. ranSuccessfully {
272
+ swiftTool. executionStatus = . failure
273
+ }
274
+
275
+ if self . options. enableExperimentalTestOutput, !runner. ranSuccessfully {
276
+ try Self . handleTestOutput ( buildParameters: buildParameters, packagePath: testProducts [ 0 ] . packagePath)
277
+ }
278
+ }
266
279
267
280
// Generate xUnit file if requested
268
281
if let xUnitOutput = options. xUnitOutput {
@@ -272,19 +285,6 @@ public struct SwiftTestTool: SwiftCommand {
272
285
)
273
286
try generator. generate ( at: xUnitOutput)
274
287
}
275
-
276
- // process code Coverage if request
277
- if self . options. enableCodeCoverage, runner. ranSuccessfully {
278
- try processCodeCoverage ( testProducts, swiftTool: swiftTool, library: . xctest)
279
- }
280
-
281
- if !runner. ranSuccessfully {
282
- swiftTool. executionStatus = . failure
283
- }
284
-
285
- if self . options. enableExperimentalTestOutput, !runner. ranSuccessfully {
286
- try Self . handleTestOutput ( buildParameters: buildParameters, packagePath: testProducts [ 0 ] . packagePath)
287
- }
288
288
}
289
289
}
290
290
0 commit comments