Skip to content

Commit 8bc8927

Browse files
[Tests] Remove all hard-coded macOS targets in explicit module tests
Remove all the hard coded macOS tests for module scanning and planning. Feed stdlib and shims into the tests instead to support all targets for those tests.
1 parent 088ac1d commit 8bc8927

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

TestInputs/ExplicitModuleBuilds/CHeaders/G.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
1+
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
22
#include "X.h"
33
#endif
44

Tests/SwiftDriverTests/CachingBuildTests.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ final class CachingBuildTests: XCTestCase {
219219
}
220220

221221
func testCachingBuildJobs() throws {
222+
let (stdlibPath, shimsPath, _, hostTriple) = try getDriverArtifactsForScanning()
222223
try withTemporaryDirectory { path in
223224
let main = path.appending(component: "testCachingBuildJobs.swift")
224225
try localFileSystem.writeFileContents(main) {
@@ -235,9 +236,10 @@ final class CachingBuildTests: XCTestCase {
235236
cHeadersPath.appending(component: "Bridging.h")
236237
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
237238
var driver = try Driver(args: ["swiftc",
238-
"-target", "x86_64-apple-macosx11.0",
239239
"-I", cHeadersPath.nativePathString(escaped: true),
240240
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
241+
"-I", stdlibPath.nativePathString(escaped: true),
242+
"-I", shimsPath.nativePathString(escaped: true),
241243
"-explicit-module-build", "-v",
242244
"-cache-compile-job", "-cas-path", casPath.nativePathString(escaped: true),
243245
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
@@ -312,6 +314,12 @@ final class CachingBuildTests: XCTestCase {
312314
try checkCachingBuildJob(job: job, moduleId: .clang("_SwiftConcurrencyShims"),
313315
dependencyGraph: dependencyGraph)
314316
}
317+
else if hostTriple.isMacOSX,
318+
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0),
319+
relativeOutputPathFileName.starts(with: "X-") {
320+
try checkCachingBuildJob(job: job, moduleId: .clang("X"),
321+
dependencyGraph: dependencyGraph)
322+
}
315323
else {
316324
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
317325
}
@@ -453,6 +461,7 @@ final class CachingBuildTests: XCTestCase {
453461
/// Test generation of explicit module build jobs for dependency modules when the driver
454462
/// is invoked with -explicit-module-build, -verify-emitted-module-interface and -enable-library-evolution.
455463
func testExplicitModuleVerifyInterfaceJobs() throws {
464+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
456465
try withTemporaryDirectory { path in
457466
let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift")
458467
try localFileSystem.writeFileContents(main) {
@@ -470,9 +479,10 @@ final class CachingBuildTests: XCTestCase {
470479
let privateSwiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.private.swiftinterface")
471480
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
472481
var driver = try Driver(args: ["swiftc",
473-
"-target", "x86_64-apple-macosx11.0",
474482
"-I", cHeadersPath.nativePathString(escaped: true),
475483
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
484+
"-I", stdlibPath.nativePathString(escaped: true),
485+
"-I", shimsPath.nativePathString(escaped: true),
476486
"-emit-module-interface-path", swiftInterfacePath.nativePathString(escaped: true),
477487
"-emit-private-module-interface-path", privateSwiftInterfacePath.nativePathString(escaped: true),
478488
"-explicit-module-build", "-verify-emitted-module-interface",
@@ -769,12 +779,12 @@ final class CachingBuildTests: XCTestCase {
769779
// #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
770780
let expectedNumberOfDependencies: Int
771781
if driver.hostTriple.isMacOSX,
772-
driver.hostTriple.version(for: .macOS) >= Triple.Version(11, 0, 0) {
773-
expectedNumberOfDependencies = 11
782+
driver.hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0) {
783+
expectedNumberOfDependencies = 12
774784
} else if driver.targetTriple.isWindows {
775785
expectedNumberOfDependencies = 14
776786
} else {
777-
expectedNumberOfDependencies = 12
787+
expectedNumberOfDependencies = 11
778788
}
779789

780790
// Dispatch several iterations in parallel

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
275275
}
276276

277277
func testModuleDependencyBuildCommandUniqueDepFile() throws {
278+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
278279
try withTemporaryDirectory { path in
279280
let source0 = path.appending(component: "testModuleDependencyBuildCommandUniqueDepFile1.swift")
280281
let source1 = path.appending(component: "testModuleDependencyBuildCommandUniqueDepFile2.swift")
@@ -299,9 +300,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
299300
.appending(component: "Swift")
300301
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
301302
var driver = try Driver(args: ["swiftc",
302-
"-target", "x86_64-apple-macosx11.0",
303303
"-I", cHeadersPath.nativePathString(escaped: true),
304304
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
305+
"-I", stdlibPath.nativePathString(escaped: true),
306+
"-I", shimsPath.nativePathString(escaped: true),
305307
"-explicit-module-build",
306308
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
307309
source0.nativePathString(escaped: true),
@@ -331,6 +333,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
331333
/// Test generation of explicit module build jobs for dependency modules when the driver
332334
/// is invoked with -explicit-module-build
333335
func testBridgingHeaderDeps() throws {
336+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
334337
try withTemporaryDirectory { path in
335338
let main = path.appending(component: "testExplicitModuleBuildJobs.swift")
336339
try localFileSystem.writeFileContents(main, bytes:
@@ -350,9 +353,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
350353
.appending(component: "Swift")
351354
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
352355
var driver = try Driver(args: ["swiftc",
353-
"-target", "x86_64-apple-macosx11.0",
354356
"-I", cHeadersPath.nativePathString(escaped: true),
355357
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
358+
"-I", stdlibPath.nativePathString(escaped: true),
359+
"-I", shimsPath.nativePathString(escaped: true),
356360
"-explicit-module-build",
357361
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
358362
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
@@ -492,6 +496,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
492496
/// Test generation of explicit module build jobs for dependency modules when the driver
493497
/// is invoked with -explicit-module-build
494498
func testExplicitModuleBuildJobs() throws {
499+
let (stdlibPath, shimsPath, _, hostTriple) = try getDriverArtifactsForScanning()
495500
try withTemporaryDirectory { path in
496501
let main = path.appending(component: "testExplicitModuleBuildJobs.swift")
497502
try localFileSystem.writeFileContents(main, bytes:
@@ -512,9 +517,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
512517
.appending(component: "Swift")
513518
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
514519
var driver = try Driver(args: ["swiftc",
515-
"-target", "x86_64-apple-macosx11.0",
516520
"-I", cHeadersPath.nativePathString(escaped: true),
517521
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
522+
"-I", stdlibPath.nativePathString(escaped: true),
523+
"-I", shimsPath.nativePathString(escaped: true),
518524
"-explicit-module-build",
519525
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
520526
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
@@ -589,6 +595,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
589595
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("_SwiftConcurrencyShims"),
590596
dependencyGraph: dependencyGraph)
591597
}
598+
else if hostTriple.isMacOSX,
599+
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0),
600+
relativeOutputPathFileName.starts(with: "X-") {
601+
try checkExplicitModuleBuildJob(job: job, moduleId: .clang("X"),
602+
dependencyGraph: dependencyGraph)
603+
}
592604
else {
593605
XCTFail("Unexpected module dependency build job output: \(outputFilePath)")
594606
}
@@ -616,6 +628,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
616628
/// Test generation of explicit module build jobs for dependency modules when the driver
617629
/// is invoked with -explicit-module-build, -verify-emitted-module-interface and -enable-library-evolution.
618630
func testExplicitModuleVerifyInterfaceJobs() throws {
631+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
619632
try withTemporaryDirectory { path in
620633
let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift")
621634
try localFileSystem.writeFileContents(main) {
@@ -632,9 +645,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
632645
let privateSwiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.private.swiftinterface")
633646
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
634647
var driver = try Driver(args: ["swiftc",
635-
"-target", "x86_64-apple-macosx11.0",
636648
"-I", cHeadersPath.nativePathString(escaped: true),
637649
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
650+
"-I", stdlibPath.nativePathString(escaped: true),
651+
"-I", shimsPath.nativePathString(escaped: true),
638652
"-emit-module-interface-path", swiftInterfacePath.nativePathString(escaped: true),
639653
"-emit-private-module-interface-path", privateSwiftInterfacePath.nativePathString(escaped: true),
640654
"-explicit-module-build", "-verify-emitted-module-interface",
@@ -748,6 +762,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
748762
/// Test generation of explicit module build jobs for dependency modules when the driver
749763
/// is invoked with -explicit-module-build and -pch-output-dir
750764
func testExplicitModuleBuildPCHOutputJobs() throws {
765+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
751766
try withTemporaryDirectory { path in
752767
let main = path.appending(component: "testExplicitModuleBuildPCHOutputJobs.swift")
753768
try localFileSystem.writeFileContents(main, bytes:
@@ -769,9 +784,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
769784
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
770785
let pchOutputDir: AbsolutePath = path
771786
var driver = try Driver(args: ["swiftc",
772-
"-target", "x86_64-apple-macosx11.0",
773787
"-I", cHeadersPath.nativePathString(escaped: true),
774788
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
789+
"-I", stdlibPath.nativePathString(escaped: true),
790+
"-I", shimsPath.nativePathString(escaped: true),
775791
"-explicit-module-build",
776792
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
777793
"-pch-output-dir", pchOutputDir.nativePathString(escaped: true),
@@ -883,6 +899,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
883899
}
884900

885901
func testImmediateModeExplicitModuleBuild() throws {
902+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
886903
try withTemporaryDirectory { path in
887904
let main = path.appending(component: "testExplicitModuleBuildJobs.swift")
888905
try localFileSystem.writeFileContents(main, bytes: "import C\n")
@@ -895,9 +912,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
895912
.appending(component: "Swift")
896913
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
897914
var driver = try Driver(args: ["swift",
898-
"-target", "x86_64-apple-macosx11.0",
899915
"-I", cHeadersPath.nativePathString(escaped: true),
900916
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
917+
"-I", stdlibPath.nativePathString(escaped: true),
918+
"-I", shimsPath.nativePathString(escaped: true),
901919
"-explicit-module-build",
902920
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
903921

@@ -1723,12 +1741,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
17231741
// #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
17241742
let expectedNumberOfDependencies: Int
17251743
if hostTriple.isMacOSX,
1726-
hostTriple.version(for: .macOS) >= Triple.Version(11, 0, 0) {
1727-
expectedNumberOfDependencies = 11
1744+
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0) {
1745+
expectedNumberOfDependencies = 12
17281746
} else if driver.targetTriple.isWindows {
17291747
expectedNumberOfDependencies = 14
17301748
} else {
1731-
expectedNumberOfDependencies = 12
1749+
expectedNumberOfDependencies = 11
17321750
}
17331751

17341752
// Dispatch several iterations in parallel

0 commit comments

Comments
 (0)