@@ -484,6 +484,40 @@ final class SwiftDriverTests: XCTestCase {
484484 }
485485 }
486486
487+ func testIndexMultipleFilesInSingleCommandLineInvocation( ) throws {
488+ try withTemporaryFile { outputFileMap in
489+ let outputMapContents = ByteString ( """
490+ {
491+ " first.swift " : {
492+ " index-unit-output-path " : " first.o "
493+ },
494+ " second.swift " : {
495+ " index-unit-output-path " : " second.o "
496+ }
497+ }
498+ """ . utf8)
499+ try localFileSystem. writeFileContents ( outputFileMap. path, bytes: outputMapContents)
500+ try assertNoDriverDiagnostics ( args:
501+ " swiftc " , " -index-file " ,
502+ " first.swift " , " second.swift " , " third.swift " ,
503+ " -index-file-path " , " first.swift " ,
504+ " -index-file-path " , " second.swift " ,
505+ " -index-store-path " , " /tmp/idx " ,
506+ " -output-file-map " , outputFileMap. path. pathString
507+ ) { driver in
508+ let jobs = try driver. planBuild ( )
509+ XCTAssertEqual ( jobs. count, 1 )
510+ let commandLine = jobs [ 0 ] . commandLine
511+ XCTAssertJobInvocationMatches ( jobs [ 0 ] , . flag( " -index-unit-output-path " ) , . path( . relative( try RelativePath ( validating: " first.o " ) ) ) )
512+ XCTAssertJobInvocationMatches ( jobs [ 0 ] , . flag( " -index-unit-output-path " ) , . path( . relative( try RelativePath ( validating: " second.o " ) ) ) )
513+ XCTAssertEqual ( commandLine. filter { $0 == . flag( " -index-unit-output-path " ) } . count, 2 )
514+ XCTAssertJobInvocationMatches ( jobs [ 0 ] , . flag( " -primary-file " ) , . path( . relative( try RelativePath ( validating: " first.swift " ) ) ) )
515+ XCTAssertJobInvocationMatches ( jobs [ 0 ] , . flag( " -primary-file " ) , . path( . relative( try RelativePath ( validating: " second.swift " ) ) ) )
516+ XCTAssertEqual ( commandLine. filter { $0 == . flag( " -primary-file " ) } . count, 2 )
517+ }
518+ }
519+ }
520+
487521 func testMultiThreadingOutputs( ) throws {
488522 try assertDriverDiagnostics ( args: " swiftc " , " -c " , " foo.swift " , " bar.swift " , " -o " , " bar.ll " , " -o " , " foo.ll " , " -num-threads " , " 2 " , " -whole-module-optimization " ) {
489523 $1. expect ( . error( " cannot specify -o when generating multiple output files " ) )
@@ -4709,7 +4743,7 @@ final class SwiftDriverTests: XCTestCase {
47094743 // in addition to the usual flag.
47104744 try withTemporaryDirectory { path in
47114745 let completePath : AbsolutePath = path. appending ( component: " profile.profdata " )
4712-
4746+
47134747 try localFileSystem. writeFileContents ( completePath, bytes: . init( ) )
47144748 var driver = try Driver ( args: [ " swiftc " , " foo.swift " ,
47154749 " -working-directory " , path. pathString,
@@ -7516,7 +7550,7 @@ final class SwiftDriverTests: XCTestCase {
75167550 XCTAssertEqual ( try getLibraryLevel ( flags) , . spi)
75177551 }
75187552 try withTemporaryFile { file in
7519- try localFileSystem. writeFileContents ( file. path, bytes:
7553+ try localFileSystem. writeFileContents ( file. path, bytes:
75207554 " // swift-module-flags: -target arm64e-apple-macos12.0 "
75217555 )
75227556 let flags = try getAllModuleFlags ( VirtualPath . absolute ( file. path) )
@@ -8332,7 +8366,7 @@ final class SwiftDriverTests: XCTestCase {
83328366 XCTAssertTrue ( plannedJobs [ 0 ] . commandLine. contains ( . flag( " -load-pass-plugin=/path/to/plugin " ) ) )
83338367#endif
83348368 }
8335-
8369+
83368370 func testSupplementaryOutputFileMapUsage( ) throws {
83378371 // Ensure filenames are escaped properly when using a supplementary output file map
83388372 try withTemporaryDirectory { path in
@@ -8363,7 +8397,7 @@ final class SwiftDriverTests: XCTestCase {
83638397 struct D {}
83648398 """
83658399 )
8366-
8400+
83678401 let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
83688402 let invocationArguments = [ " swiftc " ,
83698403 " -parse-as-library " ,
0 commit comments