Skip to content

[Tests] Remove all hard-coded macOS targets in explicit module tests #1690

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
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 TestInputs/ExplicitModuleBuilds/CHeaders/G.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
#include "X.h"
#endif

Expand Down
20 changes: 15 additions & 5 deletions Tests/SwiftDriverTests/CachingBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ final class CachingBuildTests: XCTestCase {
}

func testCachingBuildJobs() throws {
let (stdlibPath, shimsPath, _, hostTriple) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let main = path.appending(component: "testCachingBuildJobs.swift")
try localFileSystem.writeFileContents(main) {
Expand All @@ -235,9 +236,10 @@ final class CachingBuildTests: XCTestCase {
cHeadersPath.appending(component: "Bridging.h")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-explicit-module-build", "-v",
"-cache-compile-job", "-cas-path", casPath.nativePathString(escaped: true),
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
Expand Down Expand Up @@ -312,6 +314,12 @@ final class CachingBuildTests: XCTestCase {
try checkCachingBuildJob(job: job, moduleId: .clang("_SwiftConcurrencyShims"),
dependencyGraph: dependencyGraph)
}
else if hostTriple.isMacOSX,
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0),
relativeOutputPathFileName.starts(with: "X-") {
try checkCachingBuildJob(job: job, moduleId: .clang("X"),
dependencyGraph: dependencyGraph)
}
else {
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
}
Expand Down Expand Up @@ -453,6 +461,7 @@ final class CachingBuildTests: XCTestCase {
/// Test generation of explicit module build jobs for dependency modules when the driver
/// is invoked with -explicit-module-build, -verify-emitted-module-interface and -enable-library-evolution.
func testExplicitModuleVerifyInterfaceJobs() throws {
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift")
try localFileSystem.writeFileContents(main) {
Expand All @@ -470,9 +479,10 @@ final class CachingBuildTests: XCTestCase {
let privateSwiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.private.swiftinterface")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-emit-module-interface-path", swiftInterfacePath.nativePathString(escaped: true),
"-emit-private-module-interface-path", privateSwiftInterfacePath.nativePathString(escaped: true),
"-explicit-module-build", "-verify-emitted-module-interface",
Expand Down Expand Up @@ -769,12 +779,12 @@ final class CachingBuildTests: XCTestCase {
// #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
let expectedNumberOfDependencies: Int
if driver.hostTriple.isMacOSX,
driver.hostTriple.version(for: .macOS) >= Triple.Version(11, 0, 0) {
expectedNumberOfDependencies = 11
driver.hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0) {
expectedNumberOfDependencies = 12
} else if driver.targetTriple.isWindows {
expectedNumberOfDependencies = 14
} else {
expectedNumberOfDependencies = 12
expectedNumberOfDependencies = 11
}

// Dispatch several iterations in parallel
Expand Down
36 changes: 27 additions & 9 deletions Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
}

func testModuleDependencyBuildCommandUniqueDepFile() throws {
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let source0 = path.appending(component: "testModuleDependencyBuildCommandUniqueDepFile1.swift")
let source1 = path.appending(component: "testModuleDependencyBuildCommandUniqueDepFile2.swift")
Expand All @@ -299,9 +300,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
.appending(component: "Swift")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-explicit-module-build",
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
source0.nativePathString(escaped: true),
Expand Down Expand Up @@ -331,6 +333,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
/// Test generation of explicit module build jobs for dependency modules when the driver
/// is invoked with -explicit-module-build
func testBridgingHeaderDeps() throws {
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let main = path.appending(component: "testExplicitModuleBuildJobs.swift")
try localFileSystem.writeFileContents(main, bytes:
Expand All @@ -350,9 +353,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
.appending(component: "Swift")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-explicit-module-build",
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
Expand Down Expand Up @@ -492,6 +496,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
/// Test generation of explicit module build jobs for dependency modules when the driver
/// is invoked with -explicit-module-build
func testExplicitModuleBuildJobs() throws {
let (stdlibPath, shimsPath, _, hostTriple) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let main = path.appending(component: "testExplicitModuleBuildJobs.swift")
try localFileSystem.writeFileContents(main, bytes:
Expand All @@ -512,9 +517,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
.appending(component: "Swift")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-explicit-module-build",
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
Expand Down Expand Up @@ -589,6 +595,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("_SwiftConcurrencyShims"),
dependencyGraph: dependencyGraph)
}
else if hostTriple.isMacOSX,
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0),
relativeOutputPathFileName.starts(with: "X-") {
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("X"),
dependencyGraph: dependencyGraph)
}
else {
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
}
Expand Down Expand Up @@ -616,6 +628,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
/// Test generation of explicit module build jobs for dependency modules when the driver
/// is invoked with -explicit-module-build, -verify-emitted-module-interface and -enable-library-evolution.
func testExplicitModuleVerifyInterfaceJobs() throws {
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift")
try localFileSystem.writeFileContents(main) {
Expand All @@ -632,9 +645,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
let privateSwiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.private.swiftinterface")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-emit-module-interface-path", swiftInterfacePath.nativePathString(escaped: true),
"-emit-private-module-interface-path", privateSwiftInterfacePath.nativePathString(escaped: true),
"-explicit-module-build", "-verify-emitted-module-interface",
Expand Down Expand Up @@ -748,6 +762,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
/// Test generation of explicit module build jobs for dependency modules when the driver
/// is invoked with -explicit-module-build and -pch-output-dir
func testExplicitModuleBuildPCHOutputJobs() throws {
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let main = path.appending(component: "testExplicitModuleBuildPCHOutputJobs.swift")
try localFileSystem.writeFileContents(main, bytes:
Expand All @@ -769,9 +784,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
let pchOutputDir: AbsolutePath = path
var driver = try Driver(args: ["swiftc",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-explicit-module-build",
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
"-pch-output-dir", pchOutputDir.nativePathString(escaped: true),
Expand Down Expand Up @@ -883,6 +899,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
}

func testImmediateModeExplicitModuleBuild() throws {
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
try withTemporaryDirectory { path in
let main = path.appending(component: "testExplicitModuleBuildJobs.swift")
try localFileSystem.writeFileContents(main, bytes: "import C\n")
Expand All @@ -895,9 +912,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
.appending(component: "Swift")
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
var driver = try Driver(args: ["swift",
"-target", "x86_64-apple-macosx11.0",
"-I", cHeadersPath.nativePathString(escaped: true),
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-explicit-module-build",
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)

Expand Down Expand Up @@ -1723,12 +1741,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
// #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
let expectedNumberOfDependencies: Int
if hostTriple.isMacOSX,
hostTriple.version(for: .macOS) >= Triple.Version(11, 0, 0) {
expectedNumberOfDependencies = 11
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0) {
expectedNumberOfDependencies = 12
} else if driver.targetTriple.isWindows {
expectedNumberOfDependencies = 14
} else {
expectedNumberOfDependencies = 12
expectedNumberOfDependencies = 11
}

// Dispatch several iterations in parallel
Expand Down