Skip to content
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
60 changes: 45 additions & 15 deletions Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,16 +485,18 @@ final class ExplicitModuleBuildTests: XCTestCase {

let linkJob = try jobs.findJob(.link)
if driver.targetTriple.isDarwin {
XCTAssertTrue(linkJob.commandLine.contains("-possible-lswiftCore"))
XCTAssertTrue(linkJob.commandLine.contains("-possible-lswift_StringProcessing"))
XCTAssertTrue(linkJob.commandLine.contains("-possible-lobjc"))
XCTAssertTrue(linkJob.commandLine.contains("-possible-lswift_Concurrency"))
XCTAssertTrue(linkJob.commandLine.contains("-possible-lswiftSwiftOnoneSupport"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-possible-lswiftCore"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-possible-lswift_StringProcessing"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-possible-lobjc"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-possible-lswift_Concurrency"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-possible-lswiftSwiftOnoneSupport"))
} else if driver.targetTriple.isWindows {
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-lswiftCore"))
} else {
XCTAssertTrue(linkJob.commandLine.contains("-lswiftCore"))
XCTAssertTrue(linkJob.commandLine.contains("-lswift_StringProcessing"))
XCTAssertTrue(linkJob.commandLine.contains("-lswift_Concurrency"))
XCTAssertTrue(linkJob.commandLine.contains("-lswiftSwiftOnoneSupport"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-lswiftCore"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-lswift_StringProcessing"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-lswift_Concurrency"))
XCTAssertCommandLineContains(linkJob.commandLine, .flag("-lswiftSwiftOnoneSupport"))
}
}
}
Expand Down Expand Up @@ -610,6 +612,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
let dependencyGraph = try XCTUnwrap(driver.intermoduleDependencyGraph)

let checkForLinkLibrary = { (info: ModuleInfo, linkName: String, isFramework: Bool, shouldForceLoad: Bool) in
if driver.targetTriple.isWindows && linkName != "swiftCore" {
// Windows only links swiftCore.
return
}
let linkLibraries = try XCTUnwrap(info.linkLibraries)
let linkLibrary = try XCTUnwrap(linkLibraries.first { $0.linkName == linkName })
XCTAssertEqual(linkLibrary.isFramework, isFramework)
Expand Down Expand Up @@ -773,6 +779,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
} else if relativeOutputPathFileName.starts(with: "_Builtin_stdint-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("_Builtin_stdint"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "vcruntime-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("vcruntime"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "SAL-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("SAL"),
dependencyGraph: dependencyGraph)
} else if hostTriple.isMacOSX,
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0),
relativeOutputPathFileName.starts(with: "X-") {
Expand Down Expand Up @@ -823,7 +835,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
try testInputsPath.appending(component: "ExplicitModuleBuilds")
.appending(component: "Swift")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []

var driver = try Driver(args: ["swiftc",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
Expand Down Expand Up @@ -1135,6 +1147,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
} else if relativeOutputPathFileName.starts(with: "_Builtin_stdint-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("_Builtin_stdint"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "vcruntime-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("vcruntime"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "SAL-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("SAL"),
dependencyGraph: dependencyGraph)
} else {
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
}
Expand Down Expand Up @@ -1280,6 +1298,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
} else if relativeOutputPathFileName.starts(with: "_Builtin_stdint-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("_Builtin_stdint"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "vcruntime-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("vcruntime"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "SAL-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("SAL"),
dependencyGraph: dependencyGraph)
} else {
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
}
Expand Down Expand Up @@ -1400,6 +1424,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
} else if relativeOutputPathFileName.starts(with: "_Builtin_stdint-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("_Builtin_stdint"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "vcruntime-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("vcruntime"),
dependencyGraph: dependencyGraph)
} else if relativeOutputPathFileName.starts(with: "SAL-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("SAL"),
dependencyGraph: dependencyGraph)
} else {
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
}
Expand Down Expand Up @@ -2252,7 +2282,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0) {
expectedNumberOfDependencies = 13
} else if driver.targetTriple.isWindows {
expectedNumberOfDependencies = 13
expectedNumberOfDependencies = 14
} else {
expectedNumberOfDependencies = 12
}
Expand Down Expand Up @@ -2826,7 +2856,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
main.pathString])
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
let emitModuleJob = try XCTUnwrap(plannedJobs.findJobs(.emitModule).spm_only)
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-sdk"), .path(.absolute(mockSDKPath))]))
XCTAssertCommandLineContains(emitModuleJob.commandLine, .flag("-sdk"))
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-clang-target"), .flag("x86_64-apple-macosx10.15")]))
}
}
Expand Down Expand Up @@ -2856,7 +2886,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
main.pathString])
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
let emitModuleJob = try XCTUnwrap(plannedJobs.findJobs(.emitModule).spm_only)
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-sdk"), .path(.absolute(mockSDKPath))]))
XCTAssertCommandLineContains(emitModuleJob.commandLine, .flag("-sdk"))
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-clang-target"), .flag("x86_64-apple-macosx10.12")]))
}
}
Expand Down Expand Up @@ -2887,7 +2917,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
main.pathString])
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
let emitModuleJob = try XCTUnwrap(plannedJobs.findJobs(.emitModule).spm_only)
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-sdk"), .path(.absolute(mockSDKPath))]))
XCTAssertCommandLineContains(emitModuleJob.commandLine, .flag("-sdk"))
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-clang-target"), .flag("x86_64-apple-macosx10.15")]))
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-clang-target-variant"), .flag("x86_64-apple-ios13.1-macabi")]))
}
Expand Down Expand Up @@ -2920,7 +2950,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
main.pathString])
let plannedJobs = try driver.planBuild().removingAutolinkExtractJobs()
let emitModuleJob = try XCTUnwrap(plannedJobs.findJobs(.emitModule).spm_only)
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-sdk"), .path(.absolute(mockSDKPath))]))
XCTAssertCommandLineContains(emitModuleJob.commandLine, .flag("-sdk"))
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-clang-target"), .flag("x86_64-apple-macosx10.12")]))
XCTAssertTrue(emitModuleJob.commandLine.contains(subsequence: [.flag("-clang-target-variant"), .flag("x86_64-apple-ios14.0-macabi")]))
}
Expand Down
13 changes: 9 additions & 4 deletions Tests/SwiftDriverTests/IncrementalCompilationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ final class IncrementalCompilationTests: XCTestCase {
}
var extraExplicitBuildArgs: [String] = []

override func setUp() {
override func setUpWithError() throws {
try super.setUpWithError()

self.tempDir = try! withTemporaryDirectory(removeTreeOnDeinit: false) {$0}
try! localFileSystem.createDirectory(explicitModuleCacheDir)
try! localFileSystem.createDirectory(derivedDataPath)
Expand Down Expand Up @@ -154,6 +156,9 @@ final class IncrementalCompilationTests: XCTestCase {
if driver.isFrontendArgSupported(.moduleLoadMode) {
self.extraExplicitBuildArgs = ["-Xfrontend", "-module-load-mode", "-Xfrontend", "prefer-interface"]
}

// Disable incremental tests on windows due to very different module setup.
try XCTSkipIf(driver.targetTriple.isWindows, "https://github.com/swiftlang/swift-driver/issues/2029")
}

deinit {
Expand Down Expand Up @@ -360,7 +365,7 @@ extension IncrementalCompilationTests {
XCTAssertFalse(mandatoryJobInputs.contains("other.swift"))
}

// External deps timestamp updated but contents are the same, and file-hashing is explicitly disabled
// External deps timestamp updated but contents are the same, and file-hashing is explicitly disabled
func testExplicitIncrementalBuildExternalDepsWithoutHashing() throws {
replace(contentsOf: "other", with: "import E;let bar = foo")
try buildInitialState(extraArguments: ["-disable-incremental-file-hashing"], explicitModuleBuild: true)
Expand All @@ -372,7 +377,7 @@ extension IncrementalCompilationTests {
XCTAssertTrue(mandatoryJobInputs.contains("main.swift"))
}

// Source file timestamps updated but contents are the same, and file-hashing is explicitly disabled
// Source file timestamps updated but contents are the same, and file-hashing is explicitly disabled
func testExplicitIncrementalBuildSourceFilesWithoutHashing() throws {
try buildInitialState(extraArguments: ["-disable-incremental-file-hashing"], explicitModuleBuild: true)
touch("main")
Expand Down Expand Up @@ -1043,7 +1048,7 @@ extension IncrementalCompilationTests {
}

private func testRemoval(_ options: RemovalTestOptions) throws {
setUp() // clear derived data, restore output file map
try setUpWithError() // clear derived data, restore output file map
print("\n*** testRemoval \(options) ***", to: &stderrStream); stderrStream.flush()

let newInput = "another"
Expand Down
2 changes: 2 additions & 0 deletions Tests/SwiftDriverTests/JobExecutorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ final class JobExecutorTests: XCTestCase {
let outputPath = path.appending(component: "finalOutput")
var driver = try Driver(args: ["swiftc", main.pathString,
"-save-temps",
"-sil-output-dir", path.pathString,
"-ir-output-dir", path.pathString,
"-driver-filelist-threshold", "0",
"-o", outputPath.pathString] + getHostToolchainSdkArg(executor),
envBlock: ProcessEnv.block,
Expand Down
Loading
Loading