@@ -413,6 +413,66 @@ final class WorkspaceTests: XCTestCase {
413
413
}
414
414
}
415
415
}
416
+
417
+ /// Test that the explicit name given to a package is not used as its identity.
418
+ func testExplicitPackageNameIsNotUsedAsPackageIdentity( ) throws {
419
+ let sandbox = AbsolutePath ( " /tmp/ws/ " )
420
+ let fs = InMemoryFileSystem ( )
421
+
422
+ let workspace = try TestWorkspace (
423
+ sandbox: sandbox,
424
+ fs: fs,
425
+ roots: [
426
+ TestPackage (
427
+ name: " FooPackage " ,
428
+ path: " foo-package " ,
429
+ targets: [
430
+ TestTarget ( name: " FooTarget " , dependencies: [ . product( name: " BarProduct " , package : " BarPackage " ) ] ) ,
431
+ ] ,
432
+ products: [ ] ,
433
+ dependencies: [
434
+ TestDependency ( name: " BarPackage " , path: " bar-package " , requirement: . upToNextMajor( from: " 1.0.0 " ) ) ,
435
+ ] ,
436
+ toolsVersion: . v5
437
+ ) ,
438
+ TestPackage (
439
+ name: " BarPackage " ,
440
+ path: " bar-package " ,
441
+ targets: [
442
+ TestTarget ( name: " BarTarget " ) ,
443
+ ] ,
444
+ products: [
445
+ TestProduct ( name: " BarProduct " , targets: [ " BarTarget " ] ) ,
446
+ ] ,
447
+ versions: [ " 1.0.0 " , " 1.0.1 " ]
448
+ ) ,
449
+ ] ,
450
+ packages: [
451
+ TestPackage (
452
+ name: " BarPackage " ,
453
+ path: " bar-package " ,
454
+ targets: [
455
+ TestTarget ( name: " BarTarget " ) ,
456
+ ] ,
457
+ products: [
458
+ TestProduct ( name: " BarProduct " , targets: [ " BarTarget " ] ) ,
459
+ ] ,
460
+ versions: [ " 1.0.0 " , " 1.0.1 " ]
461
+ ) ,
462
+ ]
463
+ )
464
+
465
+ workspace. checkPackageGraph ( roots: [ " foo-package " , " bar-package " ] , dependencies: [ PackageDependencyDescription ( url: " /tmp/ws/pkgs/bar-package " , requirement: . upToNextMajor( from: " 1.0.0 " ) , productFilter: . everything) ] ) { ( graph, diagnostics) in
466
+ PackageGraphTester ( graph) { result in
467
+ result. check ( roots: " FooPackage " , " BarPackage " )
468
+ result. check ( packages: " FooPackage " , " BarPackage " )
469
+ result. checkTarget ( " FooTarget " ) { result in result. check ( dependencies: " BarProduct " ) }
470
+ }
471
+ XCTAssertNoDiagnostics ( diagnostics)
472
+ }
473
+ }
474
+
475
+
416
476
417
477
/// Test that the remote repository is not resolved when a root package with same name is already present.
418
478
func testRootAsDependency1( ) throws {
0 commit comments