@@ -38,7 +38,6 @@ private func checkExplicitModuleBuildJob(job: Job,
3838 }
3939 try checkExplicitModuleBuildJobDependencies ( job: job, moduleInfo: moduleInfo,
4040 moduleDependencyGraph: moduleDependencyGraph)
41-
4241}
4342
4443/// Checks that the build job for the specified module contains the required options and inputs
@@ -54,22 +53,22 @@ throws {
5453 switch dependencyInfo. details {
5554 case . swift:
5655 let swiftDependencyModulePath =
57- TypedVirtualPath ( file: try VirtualPath ( path: moduleInfo . modulePath) ,
56+ TypedVirtualPath ( file: try VirtualPath ( path: dependencyInfo . modulePath) ,
5857 type: . swiftModule)
5958 XCTAssertTrue ( job. inputs. contains ( swiftDependencyModulePath) )
6059 XCTAssertTrue ( job. commandLine. contains (
61- . flag( String ( " -swift-module-file= \( moduleInfo . modulePath) " ) ) ) )
60+ . flag( String ( " -swift-module-file= \( dependencyInfo . modulePath) " ) ) ) )
6261 case . clang( let clangDependencyDetails) :
6362 let clangDependencyModulePath =
64- TypedVirtualPath ( file: try VirtualPath ( path: moduleInfo . modulePath) ,
63+ TypedVirtualPath ( file: try VirtualPath ( path: dependencyInfo . modulePath) ,
6564 type: . pcm)
6665 let clangDependencyModuleMapPath =
6766 TypedVirtualPath ( file: try VirtualPath ( path: clangDependencyDetails. moduleMapPath) ,
6867 type: . pcm)
6968 XCTAssertTrue ( job. inputs. contains ( clangDependencyModulePath) )
7069 XCTAssertTrue ( job. inputs. contains ( clangDependencyModuleMapPath) )
7170 XCTAssertTrue ( job. commandLine. contains (
72- . flag( String ( " -clang-module-file= \( moduleInfo . modulePath) " ) ) ) )
71+ . flag( String ( " -clang-module-file= \( dependencyInfo . modulePath) " ) ) ) )
7372 XCTAssertTrue ( job. commandLine. contains (
7473 . flag( String ( " -clang-module-map-file= \( clangDependencyDetails. moduleMapPath) " ) ) ) )
7574 }
@@ -116,8 +115,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
116115 }
117116
118117 /// Test generation of explicit module build jobs for dependency modules when the driver
119- /// is invoked with -driver-print -module-dependencies-jobs
120- func testModuleDependencyBuildEndToEnd ( ) throws {
118+ /// is invoked with -experimental-explicit -module-build
119+ func testExplicitModuleBuildJobs ( ) throws {
121120 try withTemporaryDirectory { path in
122121 let main = path. appending ( component: " main.swift " )
123122 try localFileSystem. writeFileContents ( main) {
@@ -131,36 +130,64 @@ final class ExplicitModuleBuildTests: XCTestCase {
131130 let testInputsPath = packageRootPath + " /TestInputs "
132131 let cHeadersPath : String = testInputsPath + " /ExplicitModuleBuilds/CHeaders "
133132 let swiftModuleInterfacesPath : String = testInputsPath + " /ExplicitModuleBuilds/Swift "
134- var driver = try Driver ( args: [ " swift " ,
133+ var driver = try Driver ( args: [ " swiftc " ,
135134 " -I " , cHeadersPath,
136135 " -I " , swiftModuleInterfacesPath,
137- " -driver-print -module-dependencies-jobs " ,
136+ " -experimental-explicit -module-build " ,
138137 main. pathString] )
139- let jobs = try driver. generateExplicitModuleBuildJobs ( )
140- XCTAssertEqual ( jobs. count, 10 )
138+ let jobs = try driver. planBuild ( )
139+ XCTAssertTrue ( driver. parsedOptions. contains ( . driverExplicitModuleBuild) )
140+ let dependencyGraph = driver. interModuleDependencyGraph!
141+ XCTAssertEqual ( jobs. count, 12 )
141142 for job in jobs {
142143 XCTAssertEqual ( job. outputs. count, 1 )
143144 switch ( job. outputs [ 0 ] . file) {
144145 case . relative( RelativePath ( " A.swiftmodule " ) ) :
145- XCTAssertEqual ( job. kind, . emitModule)
146+ try checkExplicitModuleBuildJob ( job: job, moduleName: " A " ,
147+ moduleKind: ModuleDependencyId . CodingKeys. swift,
148+ moduleDependencyGraph: dependencyGraph)
146149 case . relative( RelativePath ( " E.swiftmodule " ) ) :
147- XCTAssertEqual ( job. kind, . emitModule)
150+ try checkExplicitModuleBuildJob ( job: job, moduleName: " E " ,
151+ moduleKind: ModuleDependencyId . CodingKeys. swift,
152+ moduleDependencyGraph: dependencyGraph)
148153 case . relative( RelativePath ( " G.swiftmodule " ) ) :
149- XCTAssertEqual ( job. kind, . emitModule)
154+ try checkExplicitModuleBuildJob ( job: job, moduleName: " G " ,
155+ moduleKind: ModuleDependencyId . CodingKeys. swift,
156+ moduleDependencyGraph: dependencyGraph)
150157 case . relative( RelativePath ( " A.pcm " ) ) :
151- XCTAssertEqual ( job. kind, . generatePCM)
158+ try checkExplicitModuleBuildJob ( job: job, moduleName: " A " ,
159+ moduleKind: ModuleDependencyId . CodingKeys. clang,
160+ moduleDependencyGraph: dependencyGraph)
152161 case . relative( RelativePath ( " B.pcm " ) ) :
153- XCTAssertEqual ( job. kind, . generatePCM)
162+ try checkExplicitModuleBuildJob ( job: job, moduleName: " B " ,
163+ moduleKind: ModuleDependencyId . CodingKeys. clang,
164+ moduleDependencyGraph: dependencyGraph)
154165 case . relative( RelativePath ( " C.pcm " ) ) :
155- XCTAssertEqual ( job. kind, . generatePCM)
166+ try checkExplicitModuleBuildJob ( job: job, moduleName: " C " ,
167+ moduleKind: ModuleDependencyId . CodingKeys. clang,
168+ moduleDependencyGraph: dependencyGraph)
156169 case . relative( RelativePath ( " G.pcm " ) ) :
157- XCTAssertEqual ( job. kind, . generatePCM)
170+ try checkExplicitModuleBuildJob ( job: job, moduleName: " G " ,
171+ moduleKind: ModuleDependencyId . CodingKeys. clang,
172+ moduleDependencyGraph: dependencyGraph)
158173 case . relative( RelativePath ( " Swift.swiftmodule " ) ) :
159- XCTAssertEqual ( job. kind, . emitModule)
174+ try checkExplicitModuleBuildJob ( job: job, moduleName: " Swift " ,
175+ moduleKind: ModuleDependencyId . CodingKeys. swift,
176+ moduleDependencyGraph: dependencyGraph)
160177 case . relative( RelativePath ( " SwiftOnoneSupport.swiftmodule " ) ) :
161- XCTAssertEqual ( job. kind, . emitModule)
178+ try checkExplicitModuleBuildJob ( job: job, moduleName: " SwiftOnoneSupport " ,
179+ moduleKind: ModuleDependencyId . CodingKeys. swift,
180+ moduleDependencyGraph: dependencyGraph)
162181 case . relative( RelativePath ( " SwiftShims.pcm " ) ) :
163- XCTAssertEqual ( job. kind, . generatePCM)
182+ try checkExplicitModuleBuildJob ( job: job, moduleName: " SwiftShims " ,
183+ moduleKind: ModuleDependencyId . CodingKeys. clang,
184+ moduleDependencyGraph: dependencyGraph)
185+ case . temporary( RelativePath ( " main.o " ) ) :
186+ try checkExplicitModuleBuildJobDependencies ( job: job,
187+ moduleInfo: dependencyGraph. mainModule,
188+ moduleDependencyGraph: dependencyGraph)
189+ case . relative( RelativePath ( " main " ) ) :
190+ XCTAssertEqual ( job. kind, . link)
164191 default :
165192 XCTFail ( " Unexpected module dependency build job output: \( job. outputs [ 0 ] . file) " )
166193 }
0 commit comments