Skip to content

Commit

Permalink
Tests: repair the incremental compilation tests on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
compnerd committed Jan 17, 2025
1 parent c0e01f6 commit bd50b23
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions Tests/SwiftDriverTests/IncrementalCompilationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ final class IncrementalCompilationTests: XCTestCase {
var commonArgs: [String] {
[
"swiftc",
"-Xcc", "-Xclang", "-Xcc", "-fbuiltin-headers-in-system-modules",
"-module-name", module,
"-o", derivedDataPath.appending(component: module + ".o").nativePathString(escaped: true),
"-output-file-map", OFM.nativePathString(escaped: true),
"-o", derivedDataPath.appending(component: module + ".o").nativePathString(escaped: false),
"-output-file-map", OFM.nativePathString(escaped: false),
"-driver-show-incremental",
"-driver-show-job-lifecycle",
"-enable-batch-mode",
Expand All @@ -72,7 +73,7 @@ final class IncrementalCompilationTests: XCTestCase {
"-incremental",
"-no-color-diagnostics",
]
+ inputPathsAndContents.map {$0.0.nativePathString(escaped: true)} .sorted()
+ inputPathsAndContents.map({ $0.0.nativePathString(escaped: false) }).sorted()
}

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

var explicitBuildArgs: [String] {
["-explicit-module-build",
"-module-cache-path", explicitModuleCacheDir.nativePathString(escaped: true),
"-module-cache-path", explicitModuleCacheDir.nativePathString(escaped: false),
// Disable implicit imports to keep tests simpler
"-Xfrontend", "-disable-implicit-concurrency-module-import",
"-Xfrontend", "-disable-implicit-string-processing-module-import",
"-I", explicitCDependenciesPath.nativePathString(escaped: true),
"-I", explicitSwiftDependenciesPath.nativePathString(escaped: true)] + extraExplicitBuildArgs
"-I", explicitCDependenciesPath.nativePathString(escaped: false),
"-I", explicitSwiftDependenciesPath.nativePathString(escaped: false)] + extraExplicitBuildArgs
}
var extraExplicitBuildArgs: [String] = []

Expand Down Expand Up @@ -193,23 +194,21 @@ extension IncrementalCompilationTests {
func testAutolinkOutputPath() throws {
var env = ProcessEnv.vars
env["SWIFT_DRIVER_TESTS_ENABLE_EXEC_PATH_FALLBACK"] = "1"
env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "/garbage/swift-autolink-extract"
env["SWIFT_DRIVER_DSYMUTIL_EXEC"] = "/garbage/dsymutil"

var driver = try Driver(
args: commonArgs
+ ["-emit-library", "-target", "x86_64-unknown-linux"],
env: env)
let plannedJobs = try driver.planBuild()
let autolinkExtractJob = try XCTUnwrap(
plannedJobs
.filter { $0.kind == .autolinkExtract }
.first)
let autoOuts = autolinkExtractJob.outputs.filter {$0.type == .autolink}
XCTAssertEqual(autoOuts.count, 1)
let autoOut = autoOuts[0]
env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "//usr/bin/swift-autolink-extract"
env["SWIFT_DRIVER_DSYMUTIL_EXEC"] = "//usr/bin/dsymutil"

var driver = try Driver(args: commonArgs + [
"-emit-library", "-target", "x86_64-unknown-linux"
], env: env)

let jobs = try driver.planBuild()
let job = try XCTUnwrap(jobs.filter { $0.kind == .autolinkExtract }.first)

let outputs = job.outputs.filter { $0.type == .autolink }
XCTAssertEqual(outputs.count, 1)

let expected = try AbsolutePath(validating: "\(module).autolink", relativeTo: derivedDataPath)
XCTAssertEqual(autoOut.file.absolutePath, expected)
XCTAssertEqual(outputs.first!.file.absolutePath, expected)
}
}

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

0 comments on commit bd50b23

Please sign in to comment.