Skip to content

[5.7] Add diagnostics to use module aliasing when duplicate targets found #5607

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
Jun 19, 2022
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/PackageLoading/PackageBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extension ModuleError: CustomStringConvertible {
switch self {
case .duplicateModule(let name, let packages):
let packages = packages.joined(separator: "', '")
return "multiple targets named '\(name)' in: '\(packages)'"
return "multiple targets named '\(name)' in: '\(packages)'; consider using the `moduleAliases` parameter in manifest to provide unique names"
case .moduleNotFound(let target, let type):
let folderName = (type == .test) ? "Tests" : (type == .plugin) ? "Plugins" : "Sources"
return "Source files for target \(target) should be located under '\(folderName)/\(target)', or a custom sources path can be set with the 'path' property in Package.swift"
Expand Down
12 changes: 6 additions & 6 deletions Tests/PackageGraphTests/PackageGraphTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ class PackageGraphTests: XCTestCase {
)

testDiagnostics(observability.diagnostics) { result in
result.check(diagnostic: "multiple targets named 'Bar' in: 'bar', 'foo'", severity: .error)
result.check(diagnostic: "multiple targets named 'Bar' in: 'bar', 'foo'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
}
}

Expand Down Expand Up @@ -350,7 +350,7 @@ class PackageGraphTests: XCTestCase {
)

testDiagnostics(observability.diagnostics) { result in
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth', 'second', 'third'", severity: .error)
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth', 'second', 'third'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
}
}

Expand Down Expand Up @@ -409,8 +409,8 @@ class PackageGraphTests: XCTestCase {
)

testDiagnostics(observability.diagnostics) { result in
result.check(diagnostic: "multiple targets named 'Bar' in: 'fourth', 'third'", severity: .error)
result.check(diagnostic: "multiple targets named 'Foo' in: 'first', 'second'", severity: .error)
result.check(diagnostic: "multiple targets named 'Bar' in: 'fourth', 'third'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
result.check(diagnostic: "multiple targets named 'Foo' in: 'first', 'second'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
}
}

Expand Down Expand Up @@ -476,7 +476,7 @@ class PackageGraphTests: XCTestCase {
)

testDiagnostics(observability.diagnostics) { result in
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth'", severity: .error)
result.check(diagnostic: "multiple targets named 'First' in: 'first', 'fourth'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
}
}

Expand Down Expand Up @@ -950,7 +950,7 @@ class PackageGraphTests: XCTestCase {
)

testDiagnostics(observability.diagnostics) { result in
result.check(diagnostic: "multiple targets named 'Foo' in: 'dep2', 'start'", severity: .error)
result.check(diagnostic: "multiple targets named 'Foo' in: 'dep2', 'start'; consider using the `moduleAliases` parameter in manifest to provide unique names", severity: .error)
}
}

Expand Down