@@ -940,7 +940,7 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
940
940
}
941
941
}
942
942
943
- func testPackageAddSameDependencyTwiceHasNoEffect ( ) async throws {
943
+ func testPackageAddSameDependencyURLTwiceHasNoEffect ( ) async throws {
944
944
try await testWithTemporaryDirectory { tmpPath in
945
945
let fs = localFileSystem
946
946
let path = tmpPath. appending ( " PackageB " )
@@ -975,6 +975,76 @@ class PackageCommandTestCase: CommandsBuildProviderTestCase {
975
975
}
976
976
}
977
977
978
+ func testPackageAddSameDependencyPathTwiceHasNoEffect( ) async throws {
979
+ try await testWithTemporaryDirectory { tmpPath in
980
+ let fs = localFileSystem
981
+ let path = tmpPath. appending ( " PackageB " )
982
+ try fs. createDirectory ( path)
983
+
984
+ let depPath = " ../foo "
985
+ let manifest = """
986
+ // swift-tools-version: 5.9
987
+ import PackageDescription
988
+ let package = Package(
989
+ name: " client " ,
990
+ dependencies: [
991
+ .package(path: " \( depPath) " )
992
+ ],
993
+ targets: [ .target(name: " client " , dependencies: [ " library " ]) ]
994
+ )
995
+ """
996
+
997
+ let expected = #".package(path: "../foo")"#
998
+ try await executeAddURLDependencyAndAssert (
999
+ packagePath: path,
1000
+ initialManifest: manifest,
1001
+ url: depPath,
1002
+ requirementArgs: [ " --type " , " path " ] ,
1003
+ expectedManifestString: expected
1004
+ )
1005
+
1006
+ try assertManifest ( path) {
1007
+ let components = $0. components ( separatedBy: expected)
1008
+ XCTAssertEqual ( components. count, 2 , " Expected the dependency to be added exactly once. " )
1009
+ }
1010
+ }
1011
+ }
1012
+
1013
+ func testPackageAddSameDependencyRegistryTwiceHasNoEffect( ) async throws {
1014
+ try await testWithTemporaryDirectory { tmpPath in
1015
+ let fs = localFileSystem
1016
+ let path = tmpPath. appending ( " PackageB " )
1017
+ try fs. createDirectory ( path)
1018
+
1019
+ let registryId = " foo "
1020
+ let manifest = """
1021
+ // swift-tools-version: 5.9
1022
+ import PackageDescription
1023
+ let package = Package(
1024
+ name: " client " ,
1025
+ dependencies: [
1026
+ .package(id: " \( registryId) " )
1027
+ ],
1028
+ targets: [ .target(name: " client " , dependencies: [ " library " ]) ]
1029
+ )
1030
+ """
1031
+
1032
+ let expected = #".package(id: "foo", exact: "1.0.0")"#
1033
+ try await executeAddURLDependencyAndAssert (
1034
+ packagePath: path,
1035
+ initialManifest: manifest,
1036
+ url: registryId,
1037
+ requirementArgs: [ " --type " , " registry " , " --exact " , " 1.0.0 " ] ,
1038
+ expectedManifestString: expected
1039
+ )
1040
+
1041
+ try assertManifest ( path) {
1042
+ let components = $0. components ( separatedBy: expected)
1043
+ XCTAssertEqual ( components. count, 2 , " Expected the dependency to be added exactly once. " )
1044
+ }
1045
+ }
1046
+ }
1047
+
978
1048
func testPackageAddURLDependency( ) async throws {
979
1049
try await testWithTemporaryDirectory { tmpPath in
980
1050
let fs = localFileSystem
0 commit comments