@@ -598,7 +598,63 @@ class ConventionTests: XCTestCase {
598
598
}
599
599
600
600
result. checkProduct ( " libpm " ) { productResult in
601
- productResult. check ( type: . Library( . Dynamic) , modules: [ " Foo " , " Bar " ] )
601
+ productResult. check ( type: . Library( . Dynamic) , modules: [ " Bar " , " Foo " ] )
602
+ }
603
+ }
604
+ }
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 " ] )
602
658
}
603
659
}
604
660
}
@@ -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
@@ -939,7 +996,7 @@ final class PackageBuilderTester {
939
996
940
997
func check( type: PackageDescription . ProductType , modules: [ String ] , file: StaticString = #file, line: UInt = #line) {
941
998
XCTAssertEqual ( product. type, type, file: file, line: line)
942
- XCTAssertEqual ( product. modules. map { $0. name} , modules, file: file, line: line)
999
+ XCTAssertEqual ( product. modules. map { $0. name} . sorted ( ) , modules, file: file, line: line)
943
1000
}
944
1001
}
945
1002
0 commit comments