Skip to content

Tests: handle differences in quoting on Windows #950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Tests/SwiftDriverTests/JobExecutorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,13 @@ final class JobExecutorTests: XCTestCase {
commandLine: [.path(.absolute(.init("/with space"))),
.path(.absolute(.init("/withoutspace")))],
inputs: [], primaryInputs: [], outputs: [])
#if os(Windows)
XCTAssertEqual(try executor.description(of: job, forceResponseFiles: false),
#""/path/to/the tool" "/with space" /withoutspace"#)
#else
XCTAssertEqual(try executor.description(of: job, forceResponseFiles: false),
"'/path/to/the tool' '/with space' /withoutspace")
#endif
}

func testInputModifiedDuringMultiJobBuild() throws {
Expand Down Expand Up @@ -440,7 +445,12 @@ final class JobExecutorTests: XCTestCase {
let resolvedCommandLine = try resolver.resolve(
.squashedArgumentList(option: "--opt=", args: [.path(tmpPath), .path(tmpPath2)]))
XCTAssertEqual(resolvedCommandLine, "--opt=\(path.appending(component: "one.txt").pathString) \(path.appending(component: "two.txt").pathString)")
#if os(Windows)
XCTAssertEqual(resolvedCommandLine.spm_shellEscaped(),
#""--opt=\#(path.appending(component: "one.txt").pathString) \#(path.appending(component: "two.txt").pathString)""#)
#else
XCTAssertEqual(resolvedCommandLine.spm_shellEscaped(), "'--opt=\(path.appending(component: "one.txt").pathString) \(path.appending(component: "two.txt").pathString)'")
#endif
}
}

Expand Down
5 changes: 5 additions & 0 deletions Tests/SwiftOptionsTests/OptionParsingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ final class SwiftDriverTests: XCTestCase {
"input1", "-color-diagnostics", "-Ifoo", "-I", "bar spaces",
"-I=wibble", "input2", "-module-name", "main",
"-sanitize=a,b,c", "--", "-foo", "-bar"], for: .batch)
#if os(Windows)
XCTAssertEqual(results.description,
#"input1 -color-diagnostics -I foo -I "bar spaces" -I=wibble input2 -module-name main -sanitize=a,b,c -- -foo -bar"#)
#else
XCTAssertEqual(results.description,
"input1 -color-diagnostics -I foo -I 'bar spaces' -I=wibble input2 -module-name main -sanitize=a,b,c -- -foo -bar")
#endif
}

func testParseErrors() {
Expand Down