@@ -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 " ) )
@@ -4649,7 +4683,7 @@ final class SwiftDriverTests: XCTestCase {
46494683 // in addition to the usual flag.
46504684 try withTemporaryDirectory { path in
46514685 let completePath : AbsolutePath = path. appending ( component: " profile.profdata " )
4652-
4686+
46534687 try localFileSystem. writeFileContents ( completePath, bytes: . init( ) )
46544688 var driver = try Driver ( args: [ " swiftc " , " foo.swift " ,
46554689 " -working-directory " , path. pathString,
@@ -7437,7 +7471,7 @@ final class SwiftDriverTests: XCTestCase {
74377471 XCTAssertEqual ( try getLibraryLevel ( flags) , . spi)
74387472 }
74397473 try withTemporaryFile { file in
7440- try localFileSystem. writeFileContents ( file. path, bytes:
7474+ try localFileSystem. writeFileContents ( file. path, bytes:
74417475 " // swift-module-flags: -target arm64e-apple-macos12.0 "
74427476 )
74437477 let flags = try getAllModuleFlags ( VirtualPath . absolute ( file. path) )
@@ -8253,7 +8287,7 @@ final class SwiftDriverTests: XCTestCase {
82538287 XCTAssertTrue ( plannedJobs [ 0 ] . commandLine. contains ( . flag( " -load-pass-plugin=/path/to/plugin " ) ) )
82548288#endif
82558289 }
8256-
8290+
82578291 func testSupplementaryOutputFileMapUsage( ) throws {
82588292 // Ensure filenames are escaped properly when using a supplementary output file map
82598293 try withTemporaryDirectory { path in
@@ -8284,7 +8318,7 @@ final class SwiftDriverTests: XCTestCase {
82848318 struct D {}
82858319 """
82868320 )
8287-
8321+
82888322 let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
82898323 let invocationArguments = [ " swiftc " ,
82908324 " -parse-as-library " ,
0 commit comments