Skip to content

Commit bb03664

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 bb03664

File tree

3 files changed

+31
-15
lines changed

3 files changed

+31
-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: 9 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, _, _) = 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),
@@ -453,6 +455,7 @@ final class CachingBuildTests: XCTestCase {
453455
/// Test generation of explicit module build jobs for dependency modules when the driver
454456
/// is invoked with -explicit-module-build, -verify-emitted-module-interface and -enable-library-evolution.
455457
func testExplicitModuleVerifyInterfaceJobs() throws {
458+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
456459
try withTemporaryDirectory { path in
457460
let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift")
458461
try localFileSystem.writeFileContents(main) {
@@ -470,9 +473,10 @@ final class CachingBuildTests: XCTestCase {
470473
let privateSwiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.private.swiftinterface")
471474
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
472475
var driver = try Driver(args: ["swiftc",
473-
"-target", "x86_64-apple-macosx11.0",
474476
"-I", cHeadersPath.nativePathString(escaped: true),
475477
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
478+
"-I", stdlibPath.nativePathString(escaped: true),
479+
"-I", shimsPath.nativePathString(escaped: true),
476480
"-emit-module-interface-path", swiftInterfacePath.nativePathString(escaped: true),
477481
"-emit-private-module-interface-path", privateSwiftInterfacePath.nativePathString(escaped: true),
478482
"-explicit-module-build", "-verify-emitted-module-interface",
@@ -769,12 +773,12 @@ final class CachingBuildTests: XCTestCase {
769773
// #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
770774
let expectedNumberOfDependencies: Int
771775
if driver.hostTriple.isMacOSX,
772-
driver.hostTriple.version(for: .macOS) >= Triple.Version(11, 0, 0) {
773-
expectedNumberOfDependencies = 11
776+
driver.hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0) {
777+
expectedNumberOfDependencies = 12
774778
} else if driver.targetTriple.isWindows {
775779
expectedNumberOfDependencies = 14
776780
} else {
777-
expectedNumberOfDependencies = 12
781+
expectedNumberOfDependencies = 11
778782
}
779783

780784
// Dispatch several iterations in parallel

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 21 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, _, _) = 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)
@@ -616,6 +622,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
616622
/// Test generation of explicit module build jobs for dependency modules when the driver
617623
/// is invoked with -explicit-module-build, -verify-emitted-module-interface and -enable-library-evolution.
618624
func testExplicitModuleVerifyInterfaceJobs() throws {
625+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
619626
try withTemporaryDirectory { path in
620627
let main = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.swift")
621628
try localFileSystem.writeFileContents(main) {
@@ -632,9 +639,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
632639
let privateSwiftInterfacePath: AbsolutePath = path.appending(component: "testExplicitModuleVerifyInterfaceJobs.private.swiftinterface")
633640
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
634641
var driver = try Driver(args: ["swiftc",
635-
"-target", "x86_64-apple-macosx11.0",
636642
"-I", cHeadersPath.nativePathString(escaped: true),
637643
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
644+
"-I", stdlibPath.nativePathString(escaped: true),
645+
"-I", shimsPath.nativePathString(escaped: true),
638646
"-emit-module-interface-path", swiftInterfacePath.nativePathString(escaped: true),
639647
"-emit-private-module-interface-path", privateSwiftInterfacePath.nativePathString(escaped: true),
640648
"-explicit-module-build", "-verify-emitted-module-interface",
@@ -748,6 +756,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
748756
/// Test generation of explicit module build jobs for dependency modules when the driver
749757
/// is invoked with -explicit-module-build and -pch-output-dir
750758
func testExplicitModuleBuildPCHOutputJobs() throws {
759+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
751760
try withTemporaryDirectory { path in
752761
let main = path.appending(component: "testExplicitModuleBuildPCHOutputJobs.swift")
753762
try localFileSystem.writeFileContents(main, bytes:
@@ -769,9 +778,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
769778
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
770779
let pchOutputDir: AbsolutePath = path
771780
var driver = try Driver(args: ["swiftc",
772-
"-target", "x86_64-apple-macosx11.0",
773781
"-I", cHeadersPath.nativePathString(escaped: true),
774782
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
783+
"-I", stdlibPath.nativePathString(escaped: true),
784+
"-I", shimsPath.nativePathString(escaped: true),
775785
"-explicit-module-build",
776786
"-import-objc-header", bridgingHeaderpath.nativePathString(escaped: true),
777787
"-pch-output-dir", pchOutputDir.nativePathString(escaped: true),
@@ -883,6 +893,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
883893
}
884894

885895
func testImmediateModeExplicitModuleBuild() throws {
896+
let (stdlibPath, shimsPath, _, _) = try getDriverArtifactsForScanning()
886897
try withTemporaryDirectory { path in
887898
let main = path.appending(component: "testExplicitModuleBuildJobs.swift")
888899
try localFileSystem.writeFileContents(main, bytes: "import C\n")
@@ -895,9 +906,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
895906
.appending(component: "Swift")
896907
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
897908
var driver = try Driver(args: ["swift",
898-
"-target", "x86_64-apple-macosx11.0",
899909
"-I", cHeadersPath.nativePathString(escaped: true),
900910
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
911+
"-I", stdlibPath.nativePathString(escaped: true),
912+
"-I", shimsPath.nativePathString(escaped: true),
901913
"-explicit-module-build",
902914
main.nativePathString(escaped: true)] + sdkArgumentsForTesting)
903915

@@ -1723,12 +1735,12 @@ final class ExplicitModuleBuildTests: XCTestCase {
17231735
// #if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000
17241736
let expectedNumberOfDependencies: Int
17251737
if hostTriple.isMacOSX,
1726-
hostTriple.version(for: .macOS) >= Triple.Version(11, 0, 0) {
1727-
expectedNumberOfDependencies = 11
1738+
hostTriple.version(for: .macOS) < Triple.Version(11, 0, 0) {
1739+
expectedNumberOfDependencies = 12
17281740
} else if driver.targetTriple.isWindows {
17291741
expectedNumberOfDependencies = 14
17301742
} else {
1731-
expectedNumberOfDependencies = 12
1743+
expectedNumberOfDependencies = 11
17321744
}
17331745

17341746
// Dispatch several iterations in parallel

0 commit comments

Comments
 (0)