@@ -1433,6 +1433,38 @@ final class SwiftDriverTests: XCTestCase {
14331433 }
14341434 }
14351435
1436+ func testEmitPCHWithOutputFileMap( ) throws {
1437+ try withTemporaryDirectory { path in
1438+ let outputFileMap = path. appending ( component: " outputFileMap.json " )
1439+ try localFileSystem. writeFileContents ( outputFileMap, bytes: """
1440+ {
1441+ " " : {
1442+ " pch " : " /build/Foo-bridging-header.pch "
1443+ }
1444+ }
1445+ """
1446+ )
1447+ var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Foo " , " -emit-module " ,
1448+ " -serialize-diagnostics " , " -experimental-emit-module-separately " ,
1449+ " -import-objc-header " , " bridging.h " , " -enable-bridging-pch " ,
1450+ " -output-file-map " , outputFileMap. description] )
1451+ let plannedJobs = try driver. planBuild ( ) . removingAutolinkExtractJobs ( )
1452+ XCTAssertTrue ( driver. diagnosticEngine. diagnostics. isEmpty)
1453+
1454+ // Test the output path is correct for GeneratePCH job.
1455+ XCTAssertEqual ( plannedJobs. count, 4 )
1456+ XCTAssertEqual ( plannedJobs [ 0 ] . kind, . generatePCH)
1457+ try XCTAssertJobInvocationMatches ( plannedJobs [ 0 ] , . flag( " -o " ) , . path( . absolute( . init( validating: " /build/Foo-bridging-header.pch " ) ) ) )
1458+
1459+ // Plan a build with no bridging header and make sure no diagnostics is emitted (pch in output file map is still accepted)
1460+ driver = try Driver ( args: [ " swiftc " , " foo.swift " , " bar.swift " , " -module-name " , " Foo " , " -emit-module " ,
1461+ " -serialize-diagnostics " , " -experimental-emit-module-separately " ,
1462+ " -output-file-map " , outputFileMap. description] )
1463+ let _ = try driver. planBuild ( )
1464+ XCTAssertTrue ( driver. diagnosticEngine. diagnostics. isEmpty)
1465+ }
1466+ }
1467+
14361468 func testReferenceDependencies( ) throws {
14371469 var driver = try Driver ( args: [ " swiftc " , " foo.swift " , " -incremental " ] )
14381470 let plannedJobs = try driver. planBuild ( )
0 commit comments