Skip to content

Commit f6fb43b

Browse files
committed
fix swift test and swift test coverage commands
1 parent 451999a commit f6fb43b

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

Sources/Commands/SwiftTestCommand.swift

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ extension SwiftExecuteTestAsyncCommand {
496496
try swiftCommandState.fileSystem.removeFileTree(productsBuildParameters.codeCovPath)
497497
}
498498

499-
if self.shouldSkipTestExecution {
499+
if !self.shouldSkipTestExecution {
500500
try await run(
501501
swiftCommandState,
502502
buildParameters: productsBuildParameters,
@@ -656,9 +656,12 @@ extension SwiftExecuteTestAsyncCommand {
656656
let llvmCov = try toolchain.getLLVMCov()
657657

658658
// Get all production source files from test targets
659+
let buildSystem = try await swiftCommandState.createBuildSystem()
660+
let packageGraph = try await buildSystem.getPackageGraph()
661+
659662
let sourceFiles = try await getProductionSourceFiles(
660663
testProducts: testProducts,
661-
swiftCommandState: swiftCommandState
664+
packageGraph: packageGraph,
662665
)
663666
let configuration = try await self.getCodeCoverageConfiguration(swiftCommandState, format: .html)
664667
for product in testProducts {
@@ -681,11 +684,8 @@ extension SwiftExecuteTestAsyncCommand {
681684
/// Gets all production source files from test targets and their dependencies.
682685
private func getProductionSourceFiles(
683686
testProducts: [BuiltTestProduct],
684-
swiftCommandState: SwiftCommandState
687+
packageGraph: ModulesGraph,
685688
) async throws -> [AbsolutePath] {
686-
let buildSystem = try await swiftCommandState.createBuildSystem()
687-
let packageGraph = try await buildSystem.getPackageGraph()
688-
689689
var sourceFiles = Set<AbsolutePath>()
690690

691691
// Get all modules from root packages that are not test modules
@@ -819,7 +819,7 @@ extension SwiftExecuteTestAsyncCommand {
819819
// Add all the production source files of the test targets
820820
args.append(contentsOf: sourceFiles.map { $0.pathString })
821821

822-
print("Generating HTML report. calling >>> \(args)")
822+
// print("Generating HTML report. calling >>> \(args)")
823823
let result = try await AsyncProcess.popen(arguments: args)
824824

825825
if result.exitStatus != .terminated(code: 0) {
@@ -968,19 +968,17 @@ public struct SwiftTestCommand: SwiftExecuteTestAsyncCommand {
968968
var options: TestCommandOptions
969969

970970
/// Whether to enable code coverage.
971-
@Flag(name: .customLong("code-coverage"),
972-
inversion: .prefixedEnableDisable,
973-
help: "Enable code coverage.")
974-
var isCovEnabled: Bool = false
971+
@Flag(
972+
name: .customLong("code-coverage"),
973+
inversion: .prefixedEnableDisable,
974+
help: "Enable code coverage.",
975+
)
976+
var isCodeCoverageEnabled: Bool = false
975977

976978
@OptionGroup(title: "Coverage Options")
977979
var coverageOptions: CoverageOptions
978980

979981

980-
var isCodeCoverageEnabled: Bool {
981-
self.isCovEnabled
982-
}
983-
984982
var shouldSkipTestExecution: Bool { false }
985983

986984
public func run(_ swiftCommandState: CoreCommands.SwiftCommandState) async throws {
@@ -1023,18 +1021,14 @@ extension SwiftTestCommand {
10231021
name: .customLong("skip-test-execution"),
10241022
help: "Skip test execution.",
10251023
)
1026-
var skipTestExecution: Bool = false
1024+
var shouldSkipTestExecution: Bool = false
10271025

10281026
@OptionGroup(title: "Coverage Options")
10291027
var coverageOptions: CoverageOptions
10301028

10311029

10321030
var isCodeCoverageEnabled: Bool { true }
10331031

1034-
var shouldSkipTestExecution: Bool {
1035-
!skipTestExecution
1036-
}
1037-
10381032
public func run(_ swiftCommandState: CoreCommands.SwiftCommandState) async throws {
10391033
try await self.run(
10401034
swiftCommandState,

0 commit comments

Comments
 (0)