Skip to content

Enable Running the test suite on Windows #909

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 5 commits into from
Nov 12, 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
2 changes: 1 addition & 1 deletion Sources/SwiftDriver/Toolchains/Toolchain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ extension Toolchain {
return path
} else if let path = try? xcrunFind(executable: executable) {
return path
} else if ![executableName("swift-frontend"), executableName("swift")].contains(executable),
} else if !["swift-frontend", "swift", "swift-frontend.exe", "swift.exe"].contains(executable),
let parentDirectory = try? getToolPath(.swiftCompiler).parentDirectory,
parentDirectory != executableDir,
let path = lookupExecutablePath(filename: executable, searchPaths: [parentDirectory]) {
Expand Down
4 changes: 4 additions & 0 deletions Tests/SwiftDriverTests/IncrementalCompilationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ extension IncrementalCompilationTests {
/// autolink job.
/// Much of the code below is taking from testLinking(), but uses the output file map code here.
func testAutolinkOutputPath() {
#if os(Windows)
XCTSkip("Driver.init fatalError")
return
#endif
var env = ProcessEnv.vars
env["SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK"] = "1"
env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "/garbage/swift-autolink-extract"
Expand Down
9 changes: 9 additions & 0 deletions Tests/SwiftDriverTests/JobExecutorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ final class JobExecutorTests: XCTestCase {
}

func testStubProcessProtocol() throws {
#if os(Windows)
throw XCTSkip("processId.getter returning `-1`")
#endif
let job = Job(
moduleName: "main",
kind: .compile,
Expand Down Expand Up @@ -342,6 +345,9 @@ final class JobExecutorTests: XCTestCase {
}

func testInputModifiedDuringSingleJobBuild() throws {
#if os(Windows)
throw XCTSkip("Requires -sdk")
#endif
try withTemporaryDirectory { path in
let main = path.appending(component: "main.swift")
try localFileSystem.writeFileContents(main) {
Expand Down Expand Up @@ -440,6 +446,9 @@ final class JobExecutorTests: XCTestCase {
#if os(macOS)
let toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
return try ["-sdk", toolchain.sdk.get().pathString]
#elseif os(Windows)
let toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
return try ["-sdk", toolchain.sdk.get().pathString]
#else
return []
#endif
Expand Down
14 changes: 13 additions & 1 deletion Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ final class SwiftDriverTests: XCTestCase {
let toolchain: Toolchain
#if os(macOS)
toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
#elseif os(Windows)
toolchain = WindowsToolchain(env: ProcessEnv.vars, executor: executor)
#else
toolchain = GenericUnixToolchain(env: ProcessEnv.vars, executor: executor)
#endif
Expand Down Expand Up @@ -247,6 +249,9 @@ final class SwiftDriverTests: XCTestCase {
}

func testRecordedInputModificationDates() throws {
#if os(Windows)
throw XCTSkip("TSCUtility.RelativePath failure")
#endif
try withTemporaryDirectory { path in
guard let cwd = localFileSystem
.currentWorkingDirectory else { fatalError() }
Expand Down Expand Up @@ -940,6 +945,9 @@ final class SwiftDriverTests: XCTestCase {
}

func testOutputFileMapRelativePathArg() throws {
#if os(Windows)
throw XCTSkip("TSCUtility.RelativePath failure")
#endif
try withTemporaryDirectory { path in
guard let cwd = localFileSystem
.currentWorkingDirectory else { fatalError() }
Expand Down Expand Up @@ -985,7 +993,7 @@ final class SwiftDriverTests: XCTestCase {
let args = try Driver.expandResponseFiles(["swift", "compiler", "-Xlinker", "@loader_path", "@" + fooPath.pathString, "something"], fileSystem: localFileSystem, diagnosticsEngine: diags)
XCTAssertEqual(args, ["swift", "compiler", "-Xlinker", "@loader_path", "hello", "bye", "bye to you", "from", "bar", "something"])
XCTAssertEqual(diags.diagnostics.count, 1)
XCTAssert(diags.diagnostics.first!.description.contains("is recursively expanded"))
XCTAssert(diags.diagnostics.first?.description.contains("is recursively expanded") ?? false)
}
}

Expand Down Expand Up @@ -2673,6 +2681,8 @@ final class SwiftDriverTests: XCTestCase {
expectedDefaultContents = "-apple-macosx"
#elseif os(Linux) || os(Android)
expectedDefaultContents = "-unknown-linux"
#elseif os(Windows)
expectedDefaultContents = "-unknown-windows-msvc"
#else
expectedDefaultContents = "-"
#endif
Expand Down Expand Up @@ -3765,6 +3775,8 @@ final class SwiftDriverTests: XCTestCase {
env: ProcessEnv.vars)
#if os(macOS)
toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
#elseif os(Windows)
toolchain = WindowsToolchain(env: ProcessEnv.vars, executor: executor)
#else
toolchain = GenericUnixToolchain(env: ProcessEnv.vars, executor: executor)
#endif
Expand Down