Skip to content

Commit 7c991a3

Browse files
committed
Guard tests that rely on being able to use/locate Darwin-host-specific libraries.
1 parent 02e34c3 commit 7c991a3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/SwiftDriver/Toolchains/DarwinToolchain.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ import SwiftOptions
165165
targetTriple: Triple,
166166
targetVariantTriple: Triple?,
167167
diagnosticsEngine: DiagnosticsEngine) throws {
168-
// On non-darwin hosts, libArcLite is not relevant
168+
// On non-darwin hosts, libArcLite won't be found and a warning will be emitted
169+
// Guard for the sake of tests runnin on all platforms
169170
#if os(macOS)
170171
// Validating arclite library path when link-objc-runtime.
171172
validateLinkObjcRuntimeARCLiteLib(&parsedOptions,

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,8 @@ final class SwiftDriverTests: XCTestCase {
11321132

11331133
do {
11341134
// static linking
1135+
// Locating relevant libraries is dependent on being a macOS host
1136+
#if os(macOS)
11351137
var driver = try Driver(args: commonArgs + ["-emit-library", "-static", "-L", "/tmp", "-Xlinker", "-w", "-target", "x86_64-apple-macosx10.9", "-lto=llvm-full"], env: env)
11361138
let plannedJobs = try driver.planBuild()
11371139

@@ -1161,6 +1163,7 @@ final class SwiftDriverTests: XCTestCase {
11611163
XCTAssertFalse(cmd.contains("-lto_library"))
11621164
XCTAssertFalse(cmd.contains("-syslibroot"))
11631165
XCTAssertFalse(cmd.contains("-no_objc_category_merging"))
1166+
#endif
11641167
}
11651168

11661169
do {
@@ -1186,12 +1189,15 @@ final class SwiftDriverTests: XCTestCase {
11861189

11871190
do {
11881191
// lto linking
1192+
// Locating relevant libraries is dependent on being a macOS host
1193+
#if os(macOS)
11891194
var driver1 = try Driver(args: commonArgs + ["-emit-executable", "-target", "x86_64-apple-macosx10.15", "-lto=llvm-thin"], env: env)
11901195
let plannedJobs1 = try driver1.planBuild()
11911196
XCTAssertFalse(plannedJobs1.contains(where: { $0.kind == .autolinkExtract }))
11921197
let linkJob1 = plannedJobs1.first(where: { $0.kind == .link })
11931198
XCTAssertTrue(linkJob1?.tool.name.contains("ld"))
11941199
XCTAssertTrue(linkJob1?.commandLine.contains(.flag("-lto_library")))
1200+
#endif
11951201

11961202
var driver2 = try Driver(args: commonArgs + ["-emit-executable", "-target", "x86_64-unknown-linux", "-lto=llvm-thin"], env: env)
11971203
let plannedJobs2 = try driver2.planBuild()
@@ -2377,7 +2383,10 @@ final class SwiftDriverTests: XCTestCase {
23772383
return
23782384
}
23792385
}
2386+
// On non-darwin hosts, libArcLite won't be found and a warning will be emitted
2387+
#if os(macOS)
23802388
try assertNoDriverDiagnostics(args: "swiftc", "-c", "-target", "x86_64-apple-macosx10.14", "-link-objc-runtime", "foo.swift")
2389+
#endif
23812390
}
23822391

23832392
func testProfileArgValidation() throws {
@@ -3481,6 +3490,7 @@ final class SwiftDriverTests: XCTestCase {
34813490
}
34823491

34833492
func testLTOLibraryArg() throws {
3493+
#if os(macOS)
34843494
do {
34853495
var driver = try Driver(args: ["swiftc", "foo.swift", "-lto=llvm-thin", "-target", "x86_64-apple-macos11.0"])
34863496
let plannedJobs = try driver.planBuild()
@@ -3499,6 +3509,7 @@ final class SwiftDriverTests: XCTestCase {
34993509
XCTAssertEqual(plannedJobs.map(\.kind), [.compile, .link])
35003510
XCTAssertFalse(plannedJobs[1].commandLine.contains("-lto_library"))
35013511
}
3512+
#endif
35023513
}
35033514

35043515
func testBCasTopLevelOutput() throws {

0 commit comments

Comments
 (0)