Skip to content

Commit 4a55190

Browse files
authored
Merge pull request #950 from compnerd/quoting
Tests: handle differences in quoting on Windows
2 parents 96e45c8 + 9823928 commit 4a55190

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Tests/SwiftDriverTests/JobExecutorTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,13 @@ final class JobExecutorTests: XCTestCase {
384384
commandLine: [.path(.absolute(.init("/with space"))),
385385
.path(.absolute(.init("/withoutspace")))],
386386
inputs: [], primaryInputs: [], outputs: [])
387+
#if os(Windows)
388+
XCTAssertEqual(try executor.description(of: job, forceResponseFiles: false),
389+
#""/path/to/the tool" "/with space" /withoutspace"#)
390+
#else
387391
XCTAssertEqual(try executor.description(of: job, forceResponseFiles: false),
388392
"'/path/to/the tool' '/with space' /withoutspace")
393+
#endif
389394
}
390395

391396
func testInputModifiedDuringMultiJobBuild() throws {
@@ -440,7 +445,12 @@ final class JobExecutorTests: XCTestCase {
440445
let resolvedCommandLine = try resolver.resolve(
441446
.squashedArgumentList(option: "--opt=", args: [.path(tmpPath), .path(tmpPath2)]))
442447
XCTAssertEqual(resolvedCommandLine, "--opt=\(path.appending(component: "one.txt").pathString) \(path.appending(component: "two.txt").pathString)")
448+
#if os(Windows)
449+
XCTAssertEqual(resolvedCommandLine.spm_shellEscaped(),
450+
#""--opt=\#(path.appending(component: "one.txt").pathString) \#(path.appending(component: "two.txt").pathString)""#)
451+
#else
443452
XCTAssertEqual(resolvedCommandLine.spm_shellEscaped(), "'--opt=\(path.appending(component: "one.txt").pathString) \(path.appending(component: "two.txt").pathString)'")
453+
#endif
444454
}
445455
}
446456

Tests/SwiftOptionsTests/OptionParsingTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ final class SwiftDriverTests: XCTestCase {
2121
"input1", "-color-diagnostics", "-Ifoo", "-I", "bar spaces",
2222
"-I=wibble", "input2", "-module-name", "main",
2323
"-sanitize=a,b,c", "--", "-foo", "-bar"], for: .batch)
24+
#if os(Windows)
25+
XCTAssertEqual(results.description,
26+
#"input1 -color-diagnostics -I foo -I "bar spaces" -I=wibble input2 -module-name main -sanitize=a,b,c -- -foo -bar"#)
27+
#else
2428
XCTAssertEqual(results.description,
2529
"input1 -color-diagnostics -I foo -I 'bar spaces' -I=wibble input2 -module-name main -sanitize=a,b,c -- -foo -bar")
30+
#endif
2631
}
2732

2833
func testParseErrors() {

0 commit comments

Comments
 (0)