@@ -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 " ) )
@@ -4649,7 +4683,7 @@ final class SwiftDriverTests: XCTestCase {
4649
4683
// in addition to the usual flag.
4650
4684
try withTemporaryDirectory { path in
4651
4685
let completePath : AbsolutePath = path. appending ( component: " profile.profdata " )
4652
-
4686
+
4653
4687
try localFileSystem. writeFileContents ( completePath, bytes: . init( ) )
4654
4688
var driver = try Driver ( args: [ " swiftc " , " foo.swift " ,
4655
4689
" -working-directory " , path. pathString,
@@ -7437,7 +7471,7 @@ final class SwiftDriverTests: XCTestCase {
7437
7471
XCTAssertEqual ( try getLibraryLevel ( flags) , . spi)
7438
7472
}
7439
7473
try withTemporaryFile { file in
7440
- try localFileSystem. writeFileContents ( file. path, bytes:
7474
+ try localFileSystem. writeFileContents ( file. path, bytes:
7441
7475
" // swift-module-flags: -target arm64e-apple-macos12.0 "
7442
7476
)
7443
7477
let flags = try getAllModuleFlags ( VirtualPath . absolute ( file. path) )
@@ -8253,7 +8287,7 @@ final class SwiftDriverTests: XCTestCase {
8253
8287
XCTAssertTrue ( plannedJobs [ 0 ] . commandLine. contains ( . flag( " -load-pass-plugin=/path/to/plugin " ) ) )
8254
8288
#endif
8255
8289
}
8256
-
8290
+
8257
8291
func testSupplementaryOutputFileMapUsage( ) throws {
8258
8292
// Ensure filenames are escaped properly when using a supplementary output file map
8259
8293
try withTemporaryDirectory { path in
@@ -8284,7 +8318,7 @@ final class SwiftDriverTests: XCTestCase {
8284
8318
struct D {}
8285
8319
"""
8286
8320
)
8287
-
8321
+
8288
8322
let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
8289
8323
let invocationArguments = [ " swiftc " ,
8290
8324
" -parse-as-library " ,
0 commit comments