Skip to content

Commit 7502ddf

Browse files
committed
[Commands] Don't load the package graph on every command
This was making swift test to load the package graph even on options like --version.
1 parent b5542af commit 7502ddf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/Commands/SwiftTestTool.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,12 @@ public class SwiftTestTool: SwiftTool<TestToolOptions> {
130130
}
131131

132132
override func runImpl() throws {
133-
let graph = try loadPackageGraph()
134-
135133
switch options.mode {
136134
case .version:
137135
print(Versioning.currentVersion.completeDisplayString)
138136

139137
case .listTests:
138+
let graph = try loadPackageGraph()
140139
let testPath = try buildTestsIfNeeded(options, graph: graph)
141140
let testSuites = try getTestSuites(path: testPath)
142141
let tests = testSuites.filteredTests(specifier: options.testCaseSpecifier)
@@ -150,12 +149,14 @@ public class SwiftTestTool: SwiftTool<TestToolOptions> {
150149
#if os(Linux)
151150
warning(message: "can't discover new tests on Linux; please use this option on macOS instead")
152151
#endif
152+
let graph = try loadPackageGraph()
153153
let testPath = try buildTestsIfNeeded(options, graph: graph)
154154
let testSuites = try getTestSuites(path: testPath)
155155
let generator = LinuxMainGenerator(graph: graph, testSuites: testSuites)
156156
try generator.generate()
157157

158158
case .runSerial:
159+
let graph = try loadPackageGraph()
159160
let testPath = try buildTestsIfNeeded(options, graph: graph)
160161
var ranSuccessfully = true
161162

@@ -191,6 +192,7 @@ public class SwiftTestTool: SwiftTool<TestToolOptions> {
191192
}
192193

193194
case .runParallel:
195+
let graph = try loadPackageGraph()
194196
let testPath = try buildTestsIfNeeded(options, graph: graph)
195197
let testSuites = try getTestSuites(path: testPath)
196198
let tests = testSuites.filteredTests(specifier: options.testCaseSpecifier)

0 commit comments

Comments
 (0)