Skip to content

Commit 0def445

Browse files
abertelrudshahmishal
authored andcommitted
Fix invalid assumptions leading to unit test failures on Apple Silicon. (#3328)
rdar://75113176 (cherry picked from commit 3ff6f8b)
1 parent 690ce46 commit 0def445

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
@@ -142,7 +142,7 @@ final class BuildPlanTests: XCTestCase {
142142
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
143143
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
144144
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
145-
"-target", "x86_64-apple-macosx10.10", "-Xlinker", "-add_ast_path",
145+
"-target", defaultTargetTriple, "-Xlinker", "-add_ast_path",
146146
"-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule", "-Xlinker", "-add_ast_path",
147147
"-Xlinker", "/path/to/build/debug/lib.swiftmodule",
148148
]
@@ -454,7 +454,7 @@ final class BuildPlanTests: XCTestCase {
454454
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
455455
"@/path/to/build/release/exe.product/Objects.LinkFileList",
456456
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
457-
"-target", "x86_64-apple-macosx10.10",
457+
"-target", defaultTargetTriple,
458458
])
459459
#else
460460
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -556,7 +556,7 @@ final class BuildPlanTests: XCTestCase {
556556
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
557557
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
558558
"-runtime-compatibility-version", "none",
559-
"-target", "x86_64-apple-macosx10.10",
559+
"-target", defaultTargetTriple,
560560
])
561561
#else
562562
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -707,7 +707,7 @@ final class BuildPlanTests: XCTestCase {
707707
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
708708
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
709709
"-runtime-compatibility-version", "none",
710-
"-target", "x86_64-apple-macosx10.10",
710+
"-target", defaultTargetTriple,
711711
])
712712
#else
713713
XCTAssertEqual(try result.buildProduct(for: "exe").linkArguments(), [
@@ -783,7 +783,7 @@ final class BuildPlanTests: XCTestCase {
783783
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
784784
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
785785
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
786-
"-target", "x86_64-apple-macosx10.10",
786+
"-target", defaultTargetTriple,
787787
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
788788
])
789789
#else
@@ -936,7 +936,7 @@ final class BuildPlanTests: XCTestCase {
936936
"-Xlinker", "-rpath", "-Xlinker", "@loader_path/../../../",
937937
"@/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList",
938938
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
939-
"-target", "x86_64-apple-macosx\(version)",
939+
"-target", "\(hostTriple.tripleString(forPlatformVersion: version))",
940940
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.swiftmodule",
941941
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/FooTests.swiftmodule",
942942
])
@@ -993,7 +993,7 @@ final class BuildPlanTests: XCTestCase {
993993
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
994994
"@/path/to/build/debug/exe.product/Objects.LinkFileList",
995995
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
996-
"-target", "x86_64-apple-macosx10.10",
996+
"-target", defaultTargetTriple,
997997
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/exe.build/exe.swiftmodule",
998998
])
999999
#else
@@ -1091,7 +1091,7 @@ final class BuildPlanTests: XCTestCase {
10911091
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
10921092
"@/path/to/build/debug/Foo.product/Objects.LinkFileList",
10931093
"-Xlinker", "-rpath", "-Xlinker", "/fake/path/lib/swift/macosx",
1094-
"-target", "x86_64-apple-macosx10.10",
1094+
"-target", defaultTargetTriple,
10951095
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Foo.build/Foo.swiftmodule"
10961096
])
10971097

@@ -1102,7 +1102,7 @@ final class BuildPlanTests: XCTestCase {
11021102
"-Xlinker", "-install_name", "-Xlinker", "@rpath/libBar-Baz.dylib",
11031103
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
11041104
"@/path/to/build/debug/Bar-Baz.product/Objects.LinkFileList",
1105-
"-target", "x86_64-apple-macosx10.10",
1105+
"-target", defaultTargetTriple,
11061106
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/Bar.swiftmodule"
11071107
])
11081108
#else
@@ -1182,7 +1182,7 @@ final class BuildPlanTests: XCTestCase {
11821182
"-Xlinker", "-install_name", "-Xlinker", "@rpath/liblib.dylib",
11831183
"-Xlinker", "-rpath", "-Xlinker", "@loader_path",
11841184
"@/path/to/build/debug/lib.product/Objects.LinkFileList",
1185-
"-target", "x86_64-apple-macosx10.10",
1185+
"-target", defaultTargetTriple,
11861186
"-Xlinker", "-add_ast_path", "-Xlinker", "/path/to/build/debug/lib.swiftmodule",
11871187
]
11881188
#else
@@ -1252,9 +1252,9 @@ final class BuildPlanTests: XCTestCase {
12521252
XCTAssertEqual(lib.moduleMap, AbsolutePath("/path/to/build/debug/lib.build/module.modulemap"))
12531253

12541254
#if os(macOS)
1255-
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"])
1255+
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])
12561256

1257-
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"])
1257+
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])
12581258
#else
12591259
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])
12601260
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])
@@ -1811,14 +1811,14 @@ final class BuildPlanTests: XCTestCase {
18111811

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

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

0 commit comments

Comments
 (0)