Skip to content

SR-14796: Don't lose '-sdk /' when dropping the trailing slash #776

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

Merged
merged 1 commit into from
Aug 2, 2021
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/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,7 @@ extension Driver {
}

// Delete trailing /.
sdkPath = sdkPath.map { $0.last == "/" ? String($0.dropLast()) : $0 }
sdkPath = sdkPath.map { $0.count > 1 && $0.last == "/" ? String($0.dropLast()) : $0 }

// Validate the SDK if we found one.
if let sdkPath = sdkPath {
Expand Down
4 changes: 4 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3442,6 +3442,10 @@ final class SwiftDriverTests: XCTestCase {
func testRegressions() throws {
var driverWithEmptySDK = try Driver(args: ["swiftc", "-sdk", "", "file.swift"])
_ = try driverWithEmptySDK.planBuild()

var driver = try Driver(args: ["swiftc", "foo.swift", "-sdk", "/"])
let plannedJobs = try driver.planBuild()
XCTAssertTrue(plannedJobs[0].commandLine.contains(subsequence: ["-sdk", .path(.absolute(.init("/")))]))
}

func testDumpASTOverride() throws {
Expand Down