Skip to content

Commit 3ff6f8b

Browse files
authored
Fix invalid assumptions leading to unit test failures on Apple Silicon. (#3328)
rdar://75113176
1 parent 6eec455 commit 3ff6f8b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

Tests/BuildTests/BuildPlanTests.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
4+
Copyright (c) 2014 - 2021 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See http://swift.org/LICENSE.txt for license information
@@ -141,7 +141,7 @@ final class BuildPlanTests: XCTestCase {
141141
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
142142
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
143143
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
144-
"-target", "x86_64-apple-macosx10.10", "-Xlinker", "-add_ast_path",
144+
"-target", defaultTargetTriple, "-Xlinker", "-add_ast_path",
145145
"-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule", "-Xlinker", "-add_ast_path",
146146
"-Xlinker", "/path/to/build/debug/lib.swiftmodule",
147147
]
@@ -453,7 +453,7 @@ final class BuildPlanTests: XCTestCase {
453453
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
454454
"@/path/to/build/release/exe.product/Objects.LinkFileList",
455455
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
456-
"-target", "x86_64-apple-macosx10.10",
456+
"-target", defaultTargetTriple,
457457
])
458458
#else
459459
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -555,7 +555,7 @@ final class BuildPlanTests: XCTestCase {
555555
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
556556
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
557557
"-runtime-compatibility-version", "none",
558-
"-target", "x86_64-apple-macosx10.10",
558+
"-target", defaultTargetTriple,
559559
])
560560
#else
561561
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -706,7 +706,7 @@ final class BuildPlanTests: XCTestCase {
706706
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
707707
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
708708
"-runtime-compatibility-version", "none",
709-
"-target", "x86_64-apple-macosx10.10",
709+
"-target", defaultTargetTriple,
710710
])
711711
#else
712712
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -782,7 +782,7 @@ final class BuildPlanTests: XCTestCase {
782782
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
783783
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
784784
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
785-
"-target", "x86_64-apple-macosx10.10",
785+
"-target", defaultTargetTriple,
786786
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
787787
])
788788
#else
@@ -935,7 +935,7 @@ final class BuildPlanTests: XCTestCase {
935935
"-Xlinker", "-rpath", "-Xlinker", "@loader_path/../../../",
936936
"@/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList",
937937
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
938-
"-target", "x86_64-apple-macosx\(version)",
938+
"-target", "\(hostTriple.tripleString(forPlatformVersion: version))",
939939
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.swiftmodule",
940940
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/FooTests.swiftmodule",
941941
])
@@ -992,7 +992,7 @@ final class BuildPlanTests: XCTestCase {
992992
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
993993
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
994994
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
995-
"-target", "x86_64-apple-macosx10.10",
995+
"-target", defaultTargetTriple,
996996
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
997997
])
998998
#else
@@ -1090,7 +1090,7 @@ final class BuildPlanTests: XCTestCase {
10901090
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
10911091
"@/path/to/build/debug/Foo.product/Objects.LinkFileList",
10921092
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
1093-
"-target", "x86_64-apple-macosx10.10",
1093+
"-target", defaultTargetTriple,
10941094
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.build/Foo.swiftmodule"
10951095
])
10961096

@@ -1101,7 +1101,7 @@ final class BuildPlanTests: XCTestCase {
11011101
"-Xlinker", "-install_name", "-Xlinker", "@rpath/libBar-Baz.dylib",
11021102
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
11031103
"@/path/to/build/debug/Bar-Baz.product/Objects.LinkFileList",
1104-
"-target", "x86_64-apple-macosx10.10",
1104+
"-target", defaultTargetTriple,
11051105
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Bar.swiftmodule"
11061106
])
11071107
#else
@@ -1181,7 +1181,7 @@ final class BuildPlanTests: XCTestCase {
11811181
"-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib",
11821182
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
11831183
"@/path/to/build/debug/lib.product/Objects.LinkFileList",
1184-
"-target", "x86_64-apple-macosx10.10",
1184+
"-target", defaultTargetTriple,
11851185
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/lib.swiftmodule",
11861186
]
11871187
#else
@@ -1251,9 +1251,9 @@ final class BuildPlanTests: XCTestCase {
12511251
XCTAssertEqual(lib.moduleMap, AbsolutePath("/path/to/build/debug/lib.build/module.modulemap"))
12521252

12531253
#if os(macOS)
1254-
XCTAssertEqual(try result.buildProduct(for: "lib").linkArguments(), ["/fake/path/to/swiftc", "-lc++", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/liblib.dylib", "-module-name", "lib", "-emit-library", "-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/lib.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", "x86_64-apple-macosx10.10"])
1254+
XCTAssertEqual(try result.buildProduct(for: "lib").linkArguments(), ["/fake/path/to/swiftc", "-lc++", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/liblib.dylib", "-module-name", "lib", "-emit-library", "-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/lib.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])
12551255

1256-
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), ["/fake/path/to/swiftc", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/exe.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", "x86_64-apple-macosx10.10"])
1256+
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), ["/fake/path/to/swiftc", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable", "-Xlinker", "-rpath", "-Xlinker", "@loader_path", "@/path/to/build/debug/exe.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])
12571257
#else
12581258
XCTAssertEqual(try result.buildProduct(for: "lib").linkArguments(), ["/fake/path/to/swiftc", "-lstdc++", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/liblib.so", "-module-name", "lib", "-emit-library", "-Xlinker", "-rpath=$ORIGIN", "@/path/to/build/debug/lib.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])
12591259
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), ["/fake/path/to/swiftc", "-L", "/path/to/build/debug", "-o", "/path/to/build/debug/exe", "-module-name", "exe", "-emit-executable", "-Xlinker", "-rpath=$ORIGIN", "@/path/to/build/debug/exe.product/Objects.LinkFileList", "-runtime-compatibility-version", "none", "-target", defaultTargetTriple])
@@ -1810,14 +1810,14 @@ final class BuildPlanTests: XCTestCase {
18101810

18111811
let aTarget = try result.target(for: "ATarget").swiftTarget().compileArguments()
18121812
#if os(macOS)
1813-
XCTAssertMatch(aTarget, ["-target", "x86_64-apple-macosx10.13", .anySequence])
1813+
XCTAssertMatch(aTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.13")), .anySequence])
18141814
#else
18151815
XCTAssertMatch(aTarget, [.equal("-target"), .equal(defaultTargetTriple), .anySequence] )
18161816
#endif
18171817

18181818
let bTarget = try result.target(for: "BTarget").swiftTarget().compileArguments()
18191819
#if os(macOS)
1820-
XCTAssertMatch(bTarget, ["-target", "x86_64-apple-macosx10.12", .anySequence])
1820+
XCTAssertMatch(bTarget, [.equal("-target"), .equal(hostTriple.tripleString(forPlatformVersion: "10.12")), .anySequence])
18211821
#else
18221822
XCTAssertMatch(bTarget, [.equal("-target"), .equal(defaultTargetTriple), .anySequence] )
18231823
#endif

0 commit comments

Comments
 (0)