@@ -603,6 +603,62 @@ class ConventionTests: XCTestCase {
603
603
}
604
604
}
605
605
606
+ func testTestsProduct( ) throws {
607
+ // Make sure product name and test module name are different in single module package.
608
+ var fs = InMemoryFileSystem ( )
609
+ try fs. createEmptyFiles ( " /Sources/Foo.swift " ,
610
+ " /Tests/FooTests/Bar.swift " )
611
+
612
+ PackageBuilderTester ( " Foo " , in: fs, products: products) { result in
613
+ result. checkModule ( " Foo " ) { moduleResult in
614
+ moduleResult. check ( c99name: " Foo " , type: . library, isTest: false )
615
+ moduleResult. checkSources ( root: " /Sources " , paths: " Foo.swift " )
616
+ }
617
+
618
+ result. checkModule ( " FooTests " ) { moduleResult in
619
+ moduleResult. check ( c99name: " FooTests " , type: . library, isTest: true )
620
+ moduleResult. checkSources ( root: " /Tests/FooTests " , paths: " Bar.swift " )
621
+ }
622
+
623
+ result. checkProduct ( " FooPackageTests " ) { productResult in
624
+ productResult. check ( type: . Test, modules: [ " FooTests " ] )
625
+ }
626
+ }
627
+
628
+ // Multi module tests package.
629
+ fs = InMemoryFileSystem ( )
630
+ try fs. createEmptyFiles ( " /Sources/Foo/Foo.swift " ,
631
+ " /Sources/Bar/Bar.swift " ,
632
+ " /Tests/FooTests/Foo.swift " ,
633
+ " /Tests/BarTests/Bar.swift " )
634
+
635
+ PackageBuilderTester ( " Foo " , in: fs, products: products) { result in
636
+ result. checkModule ( " Foo " ) { moduleResult in
637
+ moduleResult. check ( c99name: " Foo " , type: . library, isTest: false )
638
+ moduleResult. checkSources ( root: " /Sources/Foo " , paths: " Foo.swift " )
639
+ }
640
+
641
+ result. checkModule ( " Bar " ) { moduleResult in
642
+ moduleResult. check ( c99name: " Bar " , type: . library, isTest: false )
643
+ moduleResult. checkSources ( root: " /Sources/Bar " , paths: " Bar.swift " )
644
+ }
645
+
646
+ result. checkModule ( " FooTests " ) { moduleResult in
647
+ moduleResult. check ( c99name: " FooTests " , type: . library, isTest: true )
648
+ moduleResult. checkSources ( root: " /Tests/FooTests " , paths: " Foo.swift " )
649
+ }
650
+
651
+ result. checkModule ( " BarTests " ) { moduleResult in
652
+ moduleResult. check ( c99name: " BarTests " , type: . library, isTest: true )
653
+ moduleResult. checkSources ( root: " /Tests/BarTests " , paths: " Bar.swift " )
654
+ }
655
+
656
+ result. checkProduct ( " FooPackageTests " ) { productResult in
657
+ productResult. check ( type: . Test, modules: [ " BarTests " , " FooTests " ] )
658
+ }
659
+ }
660
+ }
661
+
606
662
func testBadProducts( ) throws {
607
663
var fs = InMemoryFileSystem ( )
608
664
try fs. createEmptyFiles ( " /Foo.swift " )
@@ -789,6 +845,7 @@ class ConventionTests: XCTestCase {
789
845
( " testManifestTargetDeclErrors " , testManifestTargetDeclErrors) ,
790
846
( " testProducts " , testProducts) ,
791
847
( " testBadProducts " , testBadProducts) ,
848
+ ( " testTestsProduct " , testTestsProduct) ,
792
849
]
793
850
}
794
851
0 commit comments