Skip to content

Commit 22aa7b0

Browse files
committed
Add tests and fixing option ordering
1 parent 27e8d59 commit 22aa7b0

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Sources/SwiftOptions/Options.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ extension Option {
361361
public static let externalPassPipelineFilename: Option = Option("-external-pass-pipeline-filename", .separate, attributes: [.helpHidden, .frontend, .noDriver], metaVar: "<pass_pipeline_file>", helpText: "Use the pass pipeline defined by <pass_pipeline_file>")
362362
public static let FEQ: Option = Option("-F=", .joined, alias: Option.F, attributes: [.frontend, .argumentIsPath])
363363
public static let fileCompilationDir: Option = Option("-file-compilation-dir", .separate, attributes: [.frontend], metaVar: "<path>", helpText: "The compilation directory to embed in the debug info. Coverage mapping is not supported yet.")
364-
public static let filelist: Option = Option("-filelist", .separate, attributes: [.frontend, .noDriver], helpText: "Specify source inputs in a file rather than on the command line")
365364
public static let filePrefixMap: Option = Option("-file-prefix-map", .separate, attributes: [.frontend], metaVar: "<prefix=replacement>", helpText: "Remap source paths in debug, coverage, and index info")
365+
public static let filelist: Option = Option("-filelist", .separate, attributes: [.frontend, .noDriver], helpText: "Specify source inputs in a file rather than on the command line")
366366
public static let findUsr: Option = Option("-find-usr", .flag, attributes: [.noDriver], helpText: "Find USR for decls by given condition")
367367
public static let findUsr_: Option = Option("--find-usr", .flag, alias: Option.findUsr, attributes: [.noDriver], helpText: "Find USR for decls by given condition")
368368
public static let fixitAll: Option = Option("-fixit-all", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Apply all fixits from diagnostics without any filtering")
@@ -1031,8 +1031,8 @@ extension Option {
10311031
Option.externalPassPipelineFilename,
10321032
Option.FEQ,
10331033
Option.fileCompilationDir,
1034-
Option.filelist,
10351034
Option.filePrefixMap,
1035+
Option.filelist,
10361036
Option.findUsr,
10371037
Option.findUsr_,
10381038
Option.fixitAll,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,26 @@ final class SwiftDriverTests: XCTestCase {
396396
}
397397
}
398398

399+
func testFilePrefixMapInvalidDiagnostic() throws {
400+
try assertDriverDiagnostics(args: "swiftc", "-c", "foo.swift", "-o", "foo.o", "-file-prefix-map", "invalid") {
401+
$1.expect(.error("values for '-file-prefix-map' must be in the format 'original=remapped', but 'invalid' was provided"))
402+
}
403+
}
404+
405+
func testFilePrefixMapMultiplePassToFrontend() throws {
406+
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-file-prefix-map", "foo=bar", "-file-prefix-map", "dog=doggo") { driver in
407+
let jobs = try driver.planBuild()
408+
let commandLine = jobs[0].commandLine
409+
let index = commandLine.firstIndex(of: .flag("-file-prefix-map"))
410+
let lastIndex = commandLine.lastIndex(of: .flag("-file-prefix-map"))
411+
XCTAssertNotNil(index)
412+
XCTAssertNotNil(lastIndex)
413+
XCTAssertNotEqual(index, lastIndex)
414+
XCTAssertEqual(commandLine[index!.advanced(by: 1)], .flag("foo=bar"))
415+
XCTAssertEqual(commandLine[lastIndex!.advanced(by: 1)], .flag("dog=doggo"))
416+
}
417+
}
418+
399419
func testMultiThreadingOutputs() throws {
400420
try assertDriverDiagnostics(args: "swiftc", "-c", "foo.swift", "bar.swift", "-o", "bar.ll", "-o", "foo.ll", "-num-threads", "2", "-whole-module-optimization") {
401421
$1.expect(.error("cannot specify -o when generating multiple output files"))

0 commit comments

Comments
 (0)