@@ -484,6 +484,40 @@ final class SwiftDriverTests: XCTestCase {
484
484
}
485
485
}
486
486
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
+
487
521
func testMultiThreadingOutputs( ) throws {
488
522
try assertDriverDiagnostics ( args: " swiftc " , " -c " , " foo.swift " , " bar.swift " , " -o " , " bar.ll " , " -o " , " foo.ll " , " -num-threads " , " 2 " , " -whole-module-optimization " ) {
489
523
$1. expect ( . error( " cannot specify -o when generating multiple output files " ) )
@@ -4709,7 +4743,7 @@ final class SwiftDriverTests: XCTestCase {
4709
4743
// in addition to the usual flag.
4710
4744
try withTemporaryDirectory { path in
4711
4745
let completePath : AbsolutePath = path. appending ( component: " profile.profdata " )
4712
-
4746
+
4713
4747
try localFileSystem. writeFileContents ( completePath, bytes: . init( ) )
4714
4748
var driver = try Driver ( args: [ " swiftc " , " foo.swift " ,
4715
4749
" -working-directory " , path. pathString,
@@ -7516,7 +7550,7 @@ final class SwiftDriverTests: XCTestCase {
7516
7550
XCTAssertEqual ( try getLibraryLevel ( flags) , . spi)
7517
7551
}
7518
7552
try withTemporaryFile { file in
7519
- try localFileSystem. writeFileContents ( file. path, bytes:
7553
+ try localFileSystem. writeFileContents ( file. path, bytes:
7520
7554
" // swift-module-flags: -target arm64e-apple-macos12.0 "
7521
7555
)
7522
7556
let flags = try getAllModuleFlags ( VirtualPath . absolute ( file. path) )
@@ -8332,7 +8366,7 @@ final class SwiftDriverTests: XCTestCase {
8332
8366
XCTAssertTrue ( plannedJobs [ 0 ] . commandLine. contains ( . flag( " -load-pass-plugin=/path/to/plugin " ) ) )
8333
8367
#endif
8334
8368
}
8335
-
8369
+
8336
8370
func testSupplementaryOutputFileMapUsage( ) throws {
8337
8371
// Ensure filenames are escaped properly when using a supplementary output file map
8338
8372
try withTemporaryDirectory { path in
@@ -8363,7 +8397,7 @@ final class SwiftDriverTests: XCTestCase {
8363
8397
struct D {}
8364
8398
"""
8365
8399
)
8366
-
8400
+
8367
8401
let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
8368
8402
let invocationArguments = [ " swiftc " ,
8369
8403
" -parse-as-library " ,
0 commit comments