@@ -4861,17 +4861,42 @@ final class SwiftDriverTests: XCTestCase {
4861
4861
4862
4862
// In-process query
4863
4863
do {
4864
- let targetInfoArgs = [ " -print-target-info " , " -sdk " , " bar " , " -resource-dir " , " baz " ]
4864
+ let targetInfoArgs = [ " -print-target-info " , " -sdk " , " / bar" , " -resource-dir " , " baz " ]
4865
4865
let driver = try Driver ( args: [ " swift " ] + targetInfoArgs)
4866
+ let printTargetInfoJob = try driver. toolchain. printTargetInfoJob ( target: nil , targetVariant: nil ,
4867
+ sdkPath: . absolute( driver. absoluteSDKPath!) ,
4868
+ swiftCompilerPrefixArgs: [ ] )
4869
+ var printTargetInfoCommand = try Driver . itemizedJobCommand ( of: printTargetInfoJob, useResponseFiles: . disabled, using: ArgsResolver ( fileSystem: InMemoryFileSystem ( ) ) )
4870
+ Driver . sanitizeCommandForLibScanInvocation ( & printTargetInfoCommand)
4866
4871
let swiftScanLibPath = try XCTUnwrap ( driver. toolchain. lookupSwiftScanLib ( ) )
4867
4872
if localFileSystem. exists ( swiftScanLibPath) {
4868
4873
let libSwiftScanInstance = try SwiftScan ( dylib: swiftScanLibPath)
4869
4874
if libSwiftScanInstance. canQueryTargetInfo ( ) {
4870
4875
XCTAssertTrue ( try driver. verifyBeingAbleToQueryTargetInfoInProcess ( workingDirectory: localFileSystem. currentWorkingDirectory,
4871
- invocationCommand: targetInfoArgs) )
4876
+ invocationCommand: printTargetInfoCommand,
4877
+ expectedSDKPath: " /bar " ) )
4872
4878
}
4873
4879
}
4880
+ }
4874
4881
4882
+ // Ensure that quoted paths are always escaped on the in-process query commands
4883
+ do {
4884
+ let targetInfoArgs = [ " -print-target-info " , " -sdk " , " /tmp/foo bar " , " -resource-dir " , " baz " ]
4885
+ let driver = try Driver ( args: [ " swift " ] + targetInfoArgs)
4886
+ let printTargetInfoJob = try driver. toolchain. printTargetInfoJob ( target: nil , targetVariant: nil ,
4887
+ sdkPath: . absolute( driver. absoluteSDKPath!) ,
4888
+ swiftCompilerPrefixArgs: [ ] )
4889
+ var printTargetInfoCommand = try Driver . itemizedJobCommand ( of: printTargetInfoJob, useResponseFiles: . disabled, using: ArgsResolver ( fileSystem: InMemoryFileSystem ( ) ) )
4890
+ Driver . sanitizeCommandForLibScanInvocation ( & printTargetInfoCommand)
4891
+ let swiftScanLibPath = try XCTUnwrap ( driver. toolchain. lookupSwiftScanLib ( ) )
4892
+ if localFileSystem. exists ( swiftScanLibPath) {
4893
+ let libSwiftScanInstance = try SwiftScan ( dylib: swiftScanLibPath)
4894
+ if libSwiftScanInstance. canQueryTargetInfo ( ) {
4895
+ XCTAssertTrue ( try driver. verifyBeingAbleToQueryTargetInfoInProcess ( workingDirectory: localFileSystem. currentWorkingDirectory,
4896
+ invocationCommand: printTargetInfoCommand,
4897
+ expectedSDKPath: " /tmp/foo bar " ) )
4898
+ }
4899
+ }
4875
4900
}
4876
4901
4877
4902
do {
0 commit comments