@@ -446,6 +446,115 @@ final class ModulesGraphTests: XCTestCase {
446
446
}
447
447
}
448
448
449
+ func testExecutableInvalidDependencyOnTestTarget( ) throws {
450
+ let fs = InMemoryFileSystem (
451
+ emptyFiles:
452
+ " /Foo/Sources/Foo/main.swift " ,
453
+ " /Foo/Tests/FooTest/FooTest.swift "
454
+ )
455
+
456
+ let observability = ObservabilitySystem . makeForTesting ( )
457
+
458
+ let _ = try loadModulesGraph (
459
+ fileSystem: fs,
460
+ manifests: [
461
+ Manifest . createRootManifest (
462
+ displayName: " Foo " ,
463
+ path: " /Foo " ,
464
+ toolsVersion: . v6_0,
465
+ targets: [
466
+ TargetDescription ( name: " Foo " , dependencies: [ " FooTest " ] , type: . executable) ,
467
+ TargetDescription ( name: " FooTest " , type: . test) ,
468
+ ]
469
+ ) ,
470
+ ] ,
471
+ observabilityScope: observability. topScope
472
+ )
473
+
474
+ testDiagnostics ( observability. diagnostics) { result in
475
+ result. check (
476
+ diagnostic: " Invalid dependency: 'Foo' cannot depend on test target dependency 'FooTest'. Only test targets can depend on other test targets " ,
477
+ severity: . error
478
+ )
479
+ }
480
+ }
481
+
482
+ func testPluginInvalidDependencyOnTestTarget( ) throws {
483
+ let fs = InMemoryFileSystem (
484
+ emptyFiles:
485
+ " /Foo/Plugins/Foo/main.swift " ,
486
+ " /Foo/Tests/FooTest/FooTest.swift "
487
+ )
488
+
489
+ let observability = ObservabilitySystem . makeForTesting ( )
490
+
491
+ let _ = try loadModulesGraph (
492
+ fileSystem: fs,
493
+ manifests: [
494
+ Manifest . createRootManifest (
495
+ displayName: " Foo " ,
496
+ path: " /Foo " ,
497
+ toolsVersion: . v6_0,
498
+ targets: [
499
+ TargetDescription (
500
+ name: " Foo " ,
501
+ dependencies: [ " FooTest " ] ,
502
+ type: . plugin,
503
+ pluginCapability: . buildTool
504
+ ) ,
505
+ TargetDescription ( name: " FooTest " , type: . test) ,
506
+ ]
507
+ ) ,
508
+ ] ,
509
+ observabilityScope: observability. topScope
510
+ )
511
+
512
+ testDiagnostics ( observability. diagnostics) { result in
513
+ result. check (
514
+ diagnostic: " Invalid dependency: 'Foo' cannot depend on test target dependency 'FooTest'. Only test targets can depend on other test targets " ,
515
+ severity: . error
516
+ )
517
+ }
518
+ }
519
+
520
+ func testMacroInvalidDependencyOnTestTarget( ) throws {
521
+ let fs = InMemoryFileSystem (
522
+ emptyFiles:
523
+ " /Foo/Sources/Foo/main.swift " ,
524
+ " /Foo/Tests/FooTest/FooTest.swift "
525
+ )
526
+
527
+ let observability = ObservabilitySystem . makeForTesting ( )
528
+
529
+ let _ = try loadModulesGraph (
530
+ fileSystem: fs,
531
+ manifests: [
532
+ Manifest . createRootManifest (
533
+ displayName: " Foo " ,
534
+ path: " /Foo " ,
535
+ toolsVersion: . v6_0,
536
+ targets: [
537
+ TargetDescription (
538
+ name: " Foo " ,
539
+ dependencies: [ " FooTest " ] ,
540
+ type: . macro
541
+ ) ,
542
+ TargetDescription ( name: " FooTest " , type: . test) ,
543
+ ]
544
+ ) ,
545
+ ] ,
546
+ observabilityScope: observability. topScope
547
+ )
548
+
549
+ testDiagnostics ( observability. diagnostics) { result in
550
+ result. check (
551
+ diagnostic: " Invalid dependency: 'Foo' cannot depend on test target dependency 'FooTest'. Only test targets can depend on other test targets " ,
552
+ severity: . error
553
+ )
554
+ }
555
+ }
556
+
557
+
449
558
func testValidDependencyOnTestTarget( ) throws {
450
559
let fs = InMemoryFileSystem (
451
560
emptyFiles:
0 commit comments