@@ -7232,30 +7232,88 @@ final class SwiftDriverTests: XCTestCase {
7232
7232
7233
7233
func testEmitAPIDescriptorEmitModule( ) throws {
7234
7234
try withTemporaryDirectory { path in
7235
- let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7236
- var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " baz.swift " ,
7237
- " -emit-module " , " -module-name " , " Test " ,
7238
- " -emit-api-descriptor-path " , apiDescriptorPath] )
7235
+ do {
7236
+ let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7237
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " baz.swift " ,
7238
+ " -emit-module " , " -module-name " , " Test " ,
7239
+ " -emit-api-descriptor-path " , apiDescriptorPath] )
7239
7240
7240
- let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7241
- let emitModuleJob = try jobs. findJob ( . emitModule)
7242
- XCTAssert ( emitModuleJob. commandLine. contains ( . flag( " -emit-api-descriptor-path " ) ) )
7241
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7242
+ let emitModuleJob = try jobs. findJob ( . emitModule)
7243
+ XCTAssert ( emitModuleJob. commandLine. contains ( . flag( " -emit-api-descriptor-path " ) ) )
7244
+ }
7245
+
7246
+ do {
7247
+ var env = ProcessEnv . vars
7248
+ env [ " TAPI_SDKDB_OUTPUT_PATH " ] = path. appending ( component: " SDKDB " ) . nativePathString ( escaped: false )
7249
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " baz.swift " ,
7250
+ " -emit-module " , " -module-name " , " Test " ] , env: env)
7251
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7252
+ let emitModuleJob = try jobs. findJob ( . emitModule)
7253
+ XCTAssert ( emitModuleJob. commandLine. contains ( subsequence: [
7254
+ . flag( " -emit-api-descriptor-path " ) ,
7255
+ . path( . absolute( path. appending ( components: " SDKDB " , " Test. \( driver. frontendTargetInfo. target. moduleTriple. triple) .swift.sdkdb " ) ) ) ,
7256
+ ] ) )
7257
+ }
7258
+
7259
+ do {
7260
+ var env = ProcessEnv . vars
7261
+ env [ " LD_TRACE_FILE " ] = path. appending ( component: " .LD_TRACE " ) . nativePathString ( escaped: false )
7262
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " baz.swift " ,
7263
+ " -emit-module " , " -module-name " , " Test " ] , env: env)
7264
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7265
+ let emitModuleJob = try jobs. findJob ( . emitModule)
7266
+ XCTAssert ( emitModuleJob. commandLine. contains ( subsequence: [
7267
+ . flag( " -emit-api-descriptor-path " ) ,
7268
+ . path( . absolute( path. appending ( components: " SDKDB " , " Test. \( driver. frontendTargetInfo. target. moduleTriple. triple) .swift.sdkdb " ) ) ) ,
7269
+ ] ) )
7270
+ }
7243
7271
}
7244
7272
}
7245
7273
7246
7274
func testEmitAPIDescriptorWholeModuleOptimization( ) throws {
7247
7275
try withTemporaryDirectory { path in
7248
- let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7249
- var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7250
- " -driver-filelist-threshold=0 " ,
7251
- " foo.swift " , " bar.swift " , " baz.swift " ,
7252
- " -module-name " , " Test " , " -emit-module " ,
7253
- " -emit-api-descriptor-path " , apiDescriptorPath] )
7276
+ do {
7277
+ let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7278
+ var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7279
+ " -driver-filelist-threshold=0 " ,
7280
+ " foo.swift " , " bar.swift " , " baz.swift " ,
7281
+ " -module-name " , " Test " , " -emit-module " ,
7282
+ " -emit-api-descriptor-path " , apiDescriptorPath] )
7254
7283
7255
- let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7256
- let compileJob = try jobs. findJob ( . compile)
7257
- let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7258
- XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7284
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7285
+ let compileJob = try jobs. findJob ( . compile)
7286
+ let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7287
+ XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7288
+ }
7289
+
7290
+ do {
7291
+ var env = ProcessEnv . vars
7292
+ env [ " TAPI_SDKDB_OUTPUT_PATH " ] = path. appending ( component: " SDKDB " ) . nativePathString ( escaped: false )
7293
+ var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7294
+ " -driver-filelist-threshold=0 " ,
7295
+ " foo.swift " , " bar.swift " , " baz.swift " ,
7296
+ " -module-name " , " Test " , " -emit-module " ] , env: env)
7297
+
7298
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7299
+ let compileJob = try jobs. findJob ( . compile)
7300
+ let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7301
+ XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7302
+ }
7303
+
7304
+ do {
7305
+ var env = ProcessEnv . vars
7306
+ env [ " LD_TRACE_FILE " ] = path. appending ( component: " .LD_TRACE " ) . nativePathString ( escaped: false )
7307
+ var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7308
+ " -driver-filelist-threshold=0 " ,
7309
+ " foo.swift " , " bar.swift " , " baz.swift " ,
7310
+ " -module-name " , " Test " , " -emit-module " ] , env: env)
7311
+
7312
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7313
+ let compileJob = try jobs. findJob ( . compile)
7314
+ let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7315
+ XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7316
+ }
7259
7317
}
7260
7318
}
7261
7319
}
0 commit comments