Skip to content

Commit 063b5c4

Browse files
committed
Consolidate BuildConfiguration.buildArgs into one spot
1 parent d9dd06b commit 063b5c4

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

Sources/_InternalTestSupport/misc.swift

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ fileprivate func setup(
322322
#else
323323
try Process.checkNonZeroExit(args: "cp", "-R", "-H", srcDir.pathString, dstDir.pathString)
324324
#endif
325-
325+
326326
// Ensure we get a clean test fixture.
327327
try localFileSystem.removeFileTree(dstDir.appending(component: ".build"))
328328
try localFileSystem.removeFileTree(dstDir.appending(component: ".swiftpm"))
@@ -533,14 +533,7 @@ private func swiftArgs(
533533
Xswiftc: [String],
534534
buildSystem: BuildSystemProvider.Kind?
535535
) -> [String] {
536-
var args = ["--configuration"]
537-
switch configuration {
538-
case .debug:
539-
args.append("debug")
540-
case .release:
541-
args.append("release")
542-
}
543-
536+
var args = configuration.buildArgs
544537
args += Xcc.flatMap { ["-Xcc", $0] }
545538
args += Xld.flatMap { ["-Xlinker", $0] }
546539
args += Xswiftc.flatMap { ["-Xswiftc", $0] }
@@ -549,7 +542,7 @@ private func swiftArgs(
549542
return args
550543
}
551544

552-
@available(*,
545+
@available(*,
553546
deprecated,
554547
renamed: "loadModulesGraph",
555548
message: "Rename for consistency: the type of this functions return value is named `ModulesGraph`."
@@ -582,6 +575,19 @@ public func loadPackageGraph(
582575
)
583576
}
584577

578+
extension BuildConfiguration {
579+
public var buildArgs: [String] {
580+
var args = ["--configuration"]
581+
switch self {
582+
case .debug:
583+
args.append("debug")
584+
case .release:
585+
args.append("release")
586+
}
587+
return args
588+
}
589+
}
590+
585591
public let emptyZipFile = ByteString([0x80, 0x75, 0x05, 0x06] + [UInt8](repeating: 0x00, count: 18))
586592

587593
extension FileSystem {
@@ -693,7 +699,7 @@ public func getNumberOfMatches(of match: String, in value: String) -> Int {
693699
}
694700

695701
public extension String {
696-
var withSwiftLineEnding: String {
702+
var withSwiftLineEnding: String {
697703
return replacingOccurrences(of: "\r\n", with: "\n")
698704
}
699705
}

Tests/CommandsTests/TestCommandTests.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ struct TestCommandTests {
14361436
}
14371437

14381438
func args(_ args: [String], for buildSystem: BuildSystemProvider.Kind, buildConfiguration: BuildConfiguration = .debug) -> [String] {
1439-
return args + buildConfiguration.args + getBuildSystemArgs(for: buildSystem)
1439+
return args + buildConfiguration.buildArgs + getBuildSystemArgs(for: buildSystem)
14401440
}
14411441

14421442
func commandState() throws -> (SwiftCommandState, BufferedOutputByteStream) {
@@ -1467,16 +1467,3 @@ struct TestCommandTests {
14671467
}
14681468
}
14691469

1470-
fileprivate extension BuildConfiguration {
1471-
var args: [String] {
1472-
var args = ["--configuration"]
1473-
switch self {
1474-
case .debug:
1475-
args.append("debug")
1476-
case .release:
1477-
args.append("release")
1478-
}
1479-
return args
1480-
}
1481-
}
1482-

0 commit comments

Comments
 (0)