@@ -1473,7 +1473,7 @@ final class SwiftDriverTests: XCTestCase {
14731473 let sampleOutputFileMap = OutputFileMap ( entries: pathyEntries)
14741474
14751475 try withTemporaryFile { file in
1476- try sampleOutputFileMap. store ( fileSystem: localFileSystem, file: file. path, diagnosticEngine : DiagnosticsEngine ( ) )
1476+ try sampleOutputFileMap. store ( fileSystem: localFileSystem, file: file. path)
14771477 let contentsForDebugging = try localFileSystem. readFileContents ( file. path) . cString
14781478 _ = contentsForDebugging
14791479 let recoveredOutputFileMap = try OutputFileMap . load ( fileSystem: localFileSystem, file: . absolute( file. path) , diagnosticEngine: DiagnosticsEngine ( ) )
@@ -8290,6 +8290,55 @@ final class SwiftDriverTests: XCTestCase {
82908290 XCTAssertTrue ( plannedJobs [ 0 ] . commandLine. contains ( . flag( " -load-pass-plugin=/path/to/plugin " ) ) )
82918291#endif
82928292 }
8293+
8294+ func testSupplementaryOutputFileMapUsage( ) throws {
8295+ // Ensure filenames are escaped properly when using a supplementary output file map
8296+ try withTemporaryDirectory { path in
8297+ try localFileSystem. changeCurrentWorkingDirectory ( to: path)
8298+ let moduleCachePath = path. appending ( component: " ModuleCache " )
8299+ try localFileSystem. createDirectory ( moduleCachePath)
8300+ let one = path. appending ( component: " one.swift " )
8301+ let two = path. appending ( component: " needs to escape spaces.swift " )
8302+ let three = path. appending ( component: #"another"one.swift"# )
8303+ let four = path. appending ( component: " 4.swift " )
8304+ try localFileSystem. writeFileContents ( one, bytes:
8305+ """
8306+ public struct A {}
8307+ """
8308+ )
8309+ try localFileSystem. writeFileContents ( two, bytes:
8310+ """
8311+ struct B {}
8312+ """
8313+ )
8314+ try localFileSystem. writeFileContents ( three, bytes:
8315+ """
8316+ struct C {}
8317+ """
8318+ )
8319+ try localFileSystem. writeFileContents ( four, bytes:
8320+ """
8321+ struct D {}
8322+ """
8323+ )
8324+
8325+ let sdkArgumentsForTesting = ( try ? Driver . sdkArgumentsForTesting ( ) ) ?? [ ]
8326+ let invocationArguments = [ " swiftc " ,
8327+ " -parse-as-library " ,
8328+ " -emit-library " ,
8329+ " -driver-filelist-threshold " , " 0 " ,
8330+ " -module-cache-path " , moduleCachePath. nativePathString ( escaped: true ) ,
8331+ " -working-directory " , path. nativePathString ( escaped: true ) ,
8332+ one. nativePathString ( escaped: true ) ,
8333+ two. nativePathString ( escaped: true ) ,
8334+ three. nativePathString ( escaped: true ) ,
8335+ four. nativePathString ( escaped: true ) ] + sdkArgumentsForTesting
8336+ var driver = try Driver ( args: invocationArguments)
8337+ let jobs = try driver. planBuild ( )
8338+ try driver. run ( jobs: jobs)
8339+ XCTAssertFalse ( driver. diagnosticEngine. hasErrors)
8340+ }
8341+ }
82938342}
82948343
82958344func assertString(
0 commit comments