Skip to content

make target dependency lookup case-insensitive #3615

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
Jul 16, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// swift-tools-version:5.0

import PackageDescription

let package = Package(
name: "Dep",
products: [
.library(name: "Dep", targets: ["Dep"]),
],
targets: [
.target(name: "Dep", dependencies: []),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public struct dep {
public private(set) var text = "Hello, World!"

public init() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// swift-tools-version:5.4

import PackageDescription

let package = Package(
name: "pkg",
products: [
.library(name: "pkg", targets: ["pkg"]),
],
dependencies: [
.package(path: "../dep"),
],
targets: [
.target(
name: "pkg",
dependencies: [.product(name: "Dep", package: "Dep")]),
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
public struct pkg {
public private(set) var text = "Hello, World!"

public init() {
}
}
7 changes: 5 additions & 2 deletions Sources/PackageModel/Manifest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ public final class Manifest: ObjectIdentifierProtocol {
return nil
}

return self.dependencies.first(where: { $0.nameForTargetDependencyResolutionOnly == packageName })
return self.dependencies.first(where: {
// rdar://80594761 make sure validation is case insensitive
$0.nameForTargetDependencyResolutionOnly.lowercased() == packageName.lowercased()
})
}

/// Registers a required product with a particular dependency if possible, or registers it as unknown.
Expand Down Expand Up @@ -341,7 +344,7 @@ public final class Manifest: ObjectIdentifierProtocol {
/// - Parameters:
/// - product: The product to try registering.
/// - package: The package to try associating it with.
/// - registry: The registry in which to record the assocation.
/// - registry: The registry in which to record the association.
/// - availablePackages: The set of available packages.
///
/// - Returns: `true` if the particular dependency was found and the product was registered; `false` if no matching dependency was found and the product has not yet been handled.
Expand Down
7 changes: 7 additions & 0 deletions Tests/FunctionalTests/DependencyResolutionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,11 @@ class DependencyResolutionTests: XCTestCase {
}
}
}

func testPackageLookupCaseInsensitive() throws {
fixture(name: "DependencyResolution/External/PackageLookupCaseInsensitive") { path in
let result = try SwiftPMProduct.SwiftPackage.executeProcess(["update"], packagePath: path.appending(component: "pkg"))
XCTAssert(result.exitStatus == .terminated(code: 0), try! result.utf8Output() + result.utf8stderrOutput())
}
}
}