Skip to content

Commit 028f414

Browse files
committed
Consolidate BuildConfiguration.buildArgs into one spot
1 parent 1f6e90f commit 028f414

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
@@ -319,7 +319,7 @@ fileprivate func setup(
319319
#else
320320
try Process.checkNonZeroExit(args: "cp", "-R", "-H", srcDir.pathString, dstDir.pathString)
321321
#endif
322-
322+
323323
// Ensure we get a clean test fixture.
324324
try localFileSystem.removeFileTree(dstDir.appending(component: ".build"))
325325
try localFileSystem.removeFileTree(dstDir.appending(component: ".swiftpm"))
@@ -522,14 +522,7 @@ private func swiftArgs(
522522
Xswiftc: [String],
523523
buildSystem: BuildSystemProvider.Kind?
524524
) -> [String] {
525-
var args = ["--configuration"]
526-
switch configuration {
527-
case .debug:
528-
args.append("debug")
529-
case .release:
530-
args.append("release")
531-
}
532-
525+
var args = configuration.buildArgs
533526
args += Xcc.flatMap { ["-Xcc", $0] }
534527
args += Xld.flatMap { ["-Xlinker", $0] }
535528
args += Xswiftc.flatMap { ["-Xswiftc", $0] }
@@ -538,7 +531,7 @@ private func swiftArgs(
538531
return args
539532
}
540533

541-
@available(*,
534+
@available(*,
542535
deprecated,
543536
renamed: "loadModulesGraph",
544537
message: "Rename for consistency: the type of this functions return value is named `ModulesGraph`."
@@ -571,6 +564,19 @@ public func loadPackageGraph(
571564
)
572565
}
573566

567+
extension BuildConfiguration {
568+
public var buildArgs: [String] {
569+
var args = ["--configuration"]
570+
switch self {
571+
case .debug:
572+
args.append("debug")
573+
case .release:
574+
args.append("release")
575+
}
576+
return args
577+
}
578+
}
579+
574580
public let emptyZipFile = ByteString([0x80, 0x75, 0x05, 0x06] + [UInt8](repeating: 0x00, count: 18))
575581

576582
extension FileSystem {
@@ -682,7 +688,7 @@ public func getNumberOfMatches(of match: String, in value: String) -> Int {
682688
}
683689

684690
public extension String {
685-
var withSwiftLineEnding: String {
691+
var withSwiftLineEnding: String {
686692
return replacingOccurrences(of: "\r\n", with: "\n")
687693
}
688694
}

Tests/CommandsTests/TestCommandTests.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ struct TestCommandTests {
14401440
}
14411441

14421442
func args(_ args: [String], for buildSystem: BuildSystemProvider.Kind, buildConfiguration: BuildConfiguration = .debug) -> [String] {
1443-
return args + buildConfiguration.args + getBuildSystemArgs(for: buildSystem)
1443+
return args + buildConfiguration.buildArgs + getBuildSystemArgs(for: buildSystem)
14441444
}
14451445

14461446
func commandState() throws -> (SwiftCommandState, BufferedOutputByteStream) {
@@ -1471,16 +1471,3 @@ struct TestCommandTests {
14711471
}
14721472
}
14731473

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

0 commit comments

Comments
 (0)