Skip to content

Commit bd50b23

Browse files
committed
Tests: repair the incremental compilation tests on Windows
These changes repair the test failure son Windows, which is required to bring the swift driver test suite back to fully passing on Windows as it was previously.
1 parent c0e01f6 commit bd50b23

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

Tests/SwiftDriverTests/IncrementalCompilationTests.swift

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ final class IncrementalCompilationTests: XCTestCase {
6161
var commonArgs: [String] {
6262
[
6363
"swiftc",
64+
"-Xcc", "-Xclang", "-Xcc", "-fbuiltin-headers-in-system-modules",
6465
"-module-name", module,
65-
"-o", derivedDataPath.appending(component: module + ".o").nativePathString(escaped: true),
66-
"-output-file-map", OFM.nativePathString(escaped: true),
66+
"-o", derivedDataPath.appending(component: module + ".o").nativePathString(escaped: false),
67+
"-output-file-map", OFM.nativePathString(escaped: false),
6768
"-driver-show-incremental",
6869
"-driver-show-job-lifecycle",
6970
"-enable-batch-mode",
@@ -72,7 +73,7 @@ final class IncrementalCompilationTests: XCTestCase {
7273
"-incremental",
7374
"-no-color-diagnostics",
7475
]
75-
+ inputPathsAndContents.map {$0.0.nativePathString(escaped: true)} .sorted()
76+
+ inputPathsAndContents.map({ $0.0.nativePathString(escaped: false) }).sorted()
7677
}
7778

7879
var explicitModuleCacheDir: AbsolutePath {
@@ -98,12 +99,12 @@ final class IncrementalCompilationTests: XCTestCase {
9899

99100
var explicitBuildArgs: [String] {
100101
["-explicit-module-build",
101-
"-module-cache-path", explicitModuleCacheDir.nativePathString(escaped: true),
102+
"-module-cache-path", explicitModuleCacheDir.nativePathString(escaped: false),
102103
// Disable implicit imports to keep tests simpler
103104
"-Xfrontend", "-disable-implicit-concurrency-module-import",
104105
"-Xfrontend", "-disable-implicit-string-processing-module-import",
105-
"-I", explicitCDependenciesPath.nativePathString(escaped: true),
106-
"-I", explicitSwiftDependenciesPath.nativePathString(escaped: true)] + extraExplicitBuildArgs
106+
"-I", explicitCDependenciesPath.nativePathString(escaped: false),
107+
"-I", explicitSwiftDependenciesPath.nativePathString(escaped: false)] + extraExplicitBuildArgs
107108
}
108109
var extraExplicitBuildArgs: [String] = []
109110

@@ -193,23 +194,21 @@ extension IncrementalCompilationTests {
193194
func testAutolinkOutputPath() throws {
194195
var env = ProcessEnv.vars
195196
env["SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK"] = "1"
196-
env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "/garbage/swift-autolink-extract"
197-
env["SWIFT_DRIVER_DSYMUTIL_EXEC"] = "/garbage/dsymutil"
198-
199-
var driver = try Driver(
200-
args: commonArgs
201-
+ ["-emit-library", "-target", "x86_64-unknown-linux"],
202-
env: env)
203-
let plannedJobs = try driver.planBuild()
204-
let autolinkExtractJob = try XCTUnwrap(
205-
plannedJobs
206-
.filter { $0.kind == .autolinkExtract }
207-
.first)
208-
let autoOuts = autolinkExtractJob.outputs.filter {$0.type == .autolink}
209-
XCTAssertEqual(autoOuts.count, 1)
210-
let autoOut = autoOuts[0]
197+
env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "//usr/bin/swift-autolink-extract"
198+
env["SWIFT_DRIVER_DSYMUTIL_EXEC"] = "//usr/bin/dsymutil"
199+
200+
var driver = try Driver(args: commonArgs + [
201+
"-emit-library", "-target", "x86_64-unknown-linux"
202+
], env: env)
203+
204+
let jobs = try driver.planBuild()
205+
let job = try XCTUnwrap(jobs.filter { $0.kind == .autolinkExtract }.first)
206+
207+
let outputs = job.outputs.filter { $0.type == .autolink }
208+
XCTAssertEqual(outputs.count, 1)
209+
211210
let expected = try AbsolutePath(validating: "\(module).autolink", relativeTo: derivedDataPath)
212-
XCTAssertEqual(autoOut.file.absolutePath, expected)
211+
XCTAssertEqual(outputs.first!.file.absolutePath, expected)
213212
}
214213
}
215214

@@ -518,7 +517,7 @@ extension IncrementalCompilationTests {
518517
// and repeat the initial build to settle into the "initial" state for the test
519518
try buildInitialState(checkDiagnostics: false, explicitModuleBuild: true)
520519
let modCacheEntries = try localFileSystem.getDirectoryContents(explicitModuleCacheDir)
521-
let nameOfGModule = try XCTUnwrap(modCacheEntries.first { $0.hasPrefix("G") && $0.hasSuffix(".swiftmodule")})
520+
let nameOfGModule = try XCTUnwrap(modCacheEntries.first { $0.hasPrefix("G") && $0.hasSuffix(".swiftmodule") })
522521
let pathToGModule = explicitModuleCacheDir.appending(component: nameOfGModule)
523522
// Rename the binary module to G.swiftmodule so that the next build's scan finds it.
524523
let newPathToGModule = explicitSwiftDependenciesPath.appending(component: "G.swiftmodule")
@@ -568,8 +567,8 @@ extension IncrementalCompilationTests {
568567
extension IncrementalCompilationTests {
569568
// A dependency has changed one of its inputs
570569
func testIncrementalImplicitBuildChangedDependency() throws {
571-
let extraAruments = ["-I", explicitCDependenciesPath.nativePathString(escaped: true),
572-
"-I", explicitSwiftDependenciesPath.nativePathString(escaped: true)]
570+
let extraAruments = ["-I", explicitCDependenciesPath.nativePathString(escaped: false),
571+
"-I", explicitSwiftDependenciesPath.nativePathString(escaped: false)]
573572
replace(contentsOf: "other", with: "import E;let bar = foo")
574573
try buildInitialState(checkDiagnostics: false, extraArguments: extraAruments)
575574
touch(try AbsolutePath(validating: explicitSwiftDependenciesPath.appending(component: "E.swiftinterface").pathString))

0 commit comments

Comments
 (0)