@@ -7219,30 +7219,88 @@ final class SwiftDriverTests: XCTestCase {
7219
7219
7220
7220
func testEmitAPIDescriptorEmitModule( ) throws {
7221
7221
try withTemporaryDirectory { path in
7222
- let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7223
- var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " baz.swift " ,
7224
- " -emit-module " , " -module-name " , " Test " ,
7225
- " -emit-api-descriptor-path " , apiDescriptorPath] )
7222
+ do {
7223
+ let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7224
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " baz.swift " ,
7225
+ " -emit-module " , " -module-name " , " Test " ,
7226
+ " -emit-api-descriptor-path " , apiDescriptorPath] )
7226
7227
7227
- let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7228
- let emitModuleJob = try jobs. findJob ( . emitModule)
7229
- XCTAssert ( emitModuleJob. commandLine. contains ( . flag( " -emit-api-descriptor-path " ) ) )
7228
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7229
+ let emitModuleJob = try jobs. findJob ( . emitModule)
7230
+ XCTAssert ( emitModuleJob. commandLine. contains ( . flag( " -emit-api-descriptor-path " ) ) )
7231
+ }
7232
+
7233
+ do {
7234
+ var env = ProcessEnv . vars
7235
+ env [ " TAPI_SDKDB_OUTPUT_PATH " ] = path. appending ( component: " SDKDB " ) . nativePathString ( escaped: false )
7236
+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " baz.swift " ,
7237
+ " -emit-module " , " -module-name " , " Test " ] , env: env)
7238
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7239
+ let emitModuleJob = try jobs. findJob ( . emitModule)
7240
+ XCTAssert ( emitModuleJob. commandLine. contains ( subsequence: [
7241
+ . flag( " -emit-api-descriptor-path " ) ,
7242
+ . path( . absolute( path. appending ( components: " SDKDB " , " Test. \( driver. frontendTargetInfo. target. moduleTriple. triple) .swift.sdkdb " ) ) ) ,
7243
+ ] ) )
7244
+ }
7245
+
7246
+ do {
7247
+ var env = ProcessEnv . vars
7248
+ env [ " LD_TRACE_FILE " ] = path. appending ( component: " .LD_TRACE " ) . 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
+ }
7230
7258
}
7231
7259
}
7232
7260
7233
7261
func testEmitAPIDescriptorWholeModuleOptimization( ) throws {
7234
7262
try withTemporaryDirectory { path in
7235
- let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7236
- var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7237
- " -driver-filelist-threshold=0 " ,
7238
- " foo.swift " , " bar.swift " , " baz.swift " ,
7239
- " -module-name " , " Test " , " -emit-module " ,
7240
- " -emit-api-descriptor-path " , apiDescriptorPath] )
7263
+ do {
7264
+ let apiDescriptorPath = path. appending ( component: " api.json " ) . nativePathString ( escaped: true )
7265
+ var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7266
+ " -driver-filelist-threshold=0 " ,
7267
+ " foo.swift " , " bar.swift " , " baz.swift " ,
7268
+ " -module-name " , " Test " , " -emit-module " ,
7269
+ " -emit-api-descriptor-path " , apiDescriptorPath] )
7241
7270
7242
- let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7243
- let compileJob = try jobs. findJob ( . compile)
7244
- let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7245
- XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7271
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7272
+ let compileJob = try jobs. findJob ( . compile)
7273
+ let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7274
+ XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7275
+ }
7276
+
7277
+ do {
7278
+ var env = ProcessEnv . vars
7279
+ env [ " TAPI_SDKDB_OUTPUT_PATH " ] = path. appending ( component: " SDKDB " ) . nativePathString ( escaped: false )
7280
+ var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7281
+ " -driver-filelist-threshold=0 " ,
7282
+ " foo.swift " , " bar.swift " , " baz.swift " ,
7283
+ " -module-name " , " Test " , " -emit-module " ] , env: env)
7284
+
7285
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7286
+ let compileJob = try jobs. findJob ( . compile)
7287
+ let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7288
+ XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7289
+ }
7290
+
7291
+ do {
7292
+ var env = ProcessEnv . vars
7293
+ env [ " LD_TRACE_FILE " ] = path. appending ( component: " .LD_TRACE " ) . nativePathString ( escaped: false )
7294
+ var driver = try Driver ( args: [ " swiftc " , " -whole-module-optimization " ,
7295
+ " -driver-filelist-threshold=0 " ,
7296
+ " foo.swift " , " bar.swift " , " baz.swift " ,
7297
+ " -module-name " , " Test " , " -emit-module " ] , env: env)
7298
+
7299
+ let jobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
7300
+ let compileJob = try jobs. findJob ( . compile)
7301
+ let supplementaryOutputs = try XCTUnwrap ( compileJob. commandLine. supplementaryOutputFilemap)
7302
+ XCTAssertNotNil ( supplementaryOutputs. entries. values. first ? [ . jsonAPIDescriptor] )
7303
+ }
7246
7304
}
7247
7305
}
7248
7306
}
0 commit comments