Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of the '--' argument followed by inputs for the immediate compilation mode ('swift') #1439

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/SwiftOptions/OptionParsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ extension OptionTable {
throw OptionParseError.unknownOption(
index: index - 1, argument: argument)
}
parsedOptions.addOption(.DASHDASH, argument: .single("--"))
parsedOptions.addOption(.DASHDASH, argument: .multiple(Array()))
arguments[index...].map { String($0) }.forEach { parsedOptions.addInput($0) }
index = arguments.endIndex

Expand Down
6 changes: 5 additions & 1 deletion Sources/SwiftOptions/ParsedOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ extension ParsedOption: CustomStringConvertible {
return option.spelling + " " + argument.asSingle.spm_shellEscaped()

case .remaining:
return argument.asSingle
let args = argument.asMultiple
if args.isEmpty {
return option.spelling
}
return option.spelling + " " + argument.asMultiple.map { $0.spm_shellEscaped() }.joined(separator: " ")
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2907,6 +2907,18 @@ final class SwiftDriverTests: XCTestCase {
}
}

func testDashDashImmediateInput() throws {
do {
var driver = try Driver(args: ["swift", "--", "main.swift"])
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
XCTAssertFalse(driver.diagnosticEngine.hasErrors)
XCTAssertEqual(plannedJobs.count, 1)
XCTAssertEqual(plannedJobs[0].kind, .interpret)
XCTAssertEqual(plannedJobs[0].inputs.count, 1)
XCTAssertEqual(plannedJobs[0].inputs[0].file, VirtualPath.relative(RelativePath("main.swift")))
}
}

func testWholeModuleOptimizationOutputFileMap() throws {
let contents = """
{
Expand Down