@@ -2824,6 +2824,27 @@ final class SwiftDriverTests: XCTestCase {
2824
2824
2825
2825
}
2826
2826
2827
+ func testWMOWithNonSourceInput( ) throws {
2828
+ var driver1 = try Driver ( args: [
2829
+ " swiftc " , " -whole-module-optimization " , " danger.o " , " foo.swift " , " bar.swift " , " wibble.swift " , " -module-name " , " Test " ,
2830
+ " -driver-filelist-threshold=0 "
2831
+ ] )
2832
+ let plannedJobs = try driver1. planBuild ( ) . removingAutolinkExtractJobs ( )
2833
+ XCTAssertEqual ( plannedJobs. count, 2 )
2834
+ let compileJob = plannedJobs [ 0 ]
2835
+ XCTAssertEqual ( compileJob. kind, . compile)
2836
+ XCTAssert ( compileJob. commandLine. contains ( . flag( " -supplementary-output-file-map " ) ) )
2837
+ let argIdx = try XCTUnwrap ( compileJob. commandLine. firstIndex ( where: { $0 == . flag( " -supplementary-output-file-map " ) } ) )
2838
+ let supplOutputs = compileJob. commandLine [ argIdx+ 1 ]
2839
+ guard case let . path( path) = supplOutputs,
2840
+ case let . fileList( _, fileList) = path,
2841
+ case let . outputFileMap( outFileMap) = fileList else {
2842
+ throw StringError ( " Unexpected argument for output file map " )
2843
+ }
2844
+ let firstKey : String = try VirtualPath . lookup ( XCTUnwrap ( outFileMap. entries. keys. first) ) . description
2845
+ XCTAssertEqual ( firstKey, " foo.swift " )
2846
+ }
2847
+
2827
2848
func testDashDashPassingDownInput( ) throws {
2828
2849
do {
2829
2850
var driver = try Driver ( args: [ " swiftc " , " -module-name=ThisModule " , " -wmo " , " -num-threads " , " 4 " , " -emit-module " , " -o " , " test.swiftmodule " , " -- " , " main.swift " , " multi-threaded.swift " ] )
@@ -2875,6 +2896,15 @@ final class SwiftDriverTests: XCTestCase {
2875
2896
}
2876
2897
}
2877
2898
2899
+ func testWMOWithJustObjectInputs( ) throws {
2900
+ var driver = try Driver ( args: [
2901
+ " swiftc " , " -wmo " , " foo.o " , " bar.o "
2902
+ ] )
2903
+ let plannedJobs = try driver. planBuild ( )
2904
+ XCTAssertEqual ( plannedJobs. count, 1 )
2905
+ XCTAssertEqual ( plannedJobs. first? . kind, . link)
2906
+ }
2907
+
2878
2908
func testModuleAliasingWithImplicitBuild( ) throws {
2879
2909
var driver = try Driver ( args: [
2880
2910
" swiftc " , " foo.swift " , " -module-name " , " Foo " , " -module-alias " , " Car=Bar " ,
0 commit comments