Skip to content

Commit 29f41f7

Browse files
authored
Merge pull request #909 from compnerd/runnable
Enable Running the test suite on Windows
2 parents 4077fd0 + 244dfb8 commit 29f41f7

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

Sources/SwiftDriver/Toolchains/Toolchain.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ extension Toolchain {
168168
return path
169169
} else if let path = try? xcrunFind(executable: executable) {
170170
return path
171-
} else if ![executableName("swift-frontend"), executableName("swift")].contains(executable),
171+
} else if !["swift-frontend", "swift", "swift-frontend.exe", "swift.exe"].contains(executable),
172172
let parentDirectory = try? getToolPath(.swiftCompiler).parentDirectory,
173173
parentDirectory != executableDir,
174174
let path = lookupExecutablePath(filename: executable, searchPaths: [parentDirectory]) {

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,10 @@ extension IncrementalCompilationTests {
135135
/// autolink job.
136136
/// Much of the code below is taking from testLinking(), but uses the output file map code here.
137137
func testAutolinkOutputPath() {
138+
#if os(Windows)
139+
XCTSkip("Driver.init fatalError")
140+
return
141+
#endif
138142
var env = ProcessEnv.vars
139143
env["SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK"] = "1"
140144
env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "/garbage/swift-autolink-extract"

Tests/SwiftDriverTests/JobExecutorTests.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ final class JobExecutorTests: XCTestCase {
288288
}
289289

290290
func testStubProcessProtocol() throws {
291+
#if os(Windows)
292+
throw XCTSkip("processId.getter returning `-1`")
293+
#endif
291294
let job = Job(
292295
moduleName: "main",
293296
kind: .compile,
@@ -342,6 +345,9 @@ final class JobExecutorTests: XCTestCase {
342345
}
343346

344347
func testInputModifiedDuringSingleJobBuild() throws {
348+
#if os(Windows)
349+
throw XCTSkip("Requires -sdk")
350+
#endif
345351
try withTemporaryDirectory { path in
346352
let main = path.appending(component: "main.swift")
347353
try localFileSystem.writeFileContents(main) {
@@ -440,6 +446,9 @@ final class JobExecutorTests: XCTestCase {
440446
#if os(macOS)
441447
let toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
442448
return try ["-sdk", toolchain.sdk.get().pathString]
449+
#elseif os(Windows)
450+
let toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
451+
return try ["-sdk", toolchain.sdk.get().pathString]
443452
#else
444453
return []
445454
#endif

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ final class SwiftDriverTests: XCTestCase {
3838
let toolchain: Toolchain
3939
#if os(macOS)
4040
toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
41+
#elseif os(Windows)
42+
toolchain = WindowsToolchain(env: ProcessEnv.vars, executor: executor)
4143
#else
4244
toolchain = GenericUnixToolchain(env: ProcessEnv.vars, executor: executor)
4345
#endif
@@ -247,6 +249,9 @@ final class SwiftDriverTests: XCTestCase {
247249
}
248250

249251
func testRecordedInputModificationDates() throws {
252+
#if os(Windows)
253+
throw XCTSkip("TSCUtility.RelativePath failure")
254+
#endif
250255
try withTemporaryDirectory { path in
251256
guard let cwd = localFileSystem
252257
.currentWorkingDirectory else { fatalError() }
@@ -940,6 +945,9 @@ final class SwiftDriverTests: XCTestCase {
940945
}
941946

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

@@ -2684,6 +2692,8 @@ final class SwiftDriverTests: XCTestCase {
26842692
expectedDefaultContents = "-apple-macosx"
26852693
#elseif os(Linux) || os(Android)
26862694
expectedDefaultContents = "-unknown-linux"
2695+
#elseif os(Windows)
2696+
expectedDefaultContents = "-unknown-windows-msvc"
26872697
#else
26882698
expectedDefaultContents = "-"
26892699
#endif
@@ -3776,6 +3786,8 @@ final class SwiftDriverTests: XCTestCase {
37763786
env: ProcessEnv.vars)
37773787
#if os(macOS)
37783788
toolchain = DarwinToolchain(env: ProcessEnv.vars, executor: executor)
3789+
#elseif os(Windows)
3790+
toolchain = WindowsToolchain(env: ProcessEnv.vars, executor: executor)
37793791
#else
37803792
toolchain = GenericUnixToolchain(env: ProcessEnv.vars, executor: executor)
37813793
#endif

0 commit comments

Comments
 (0)