Skip to content

Commit 9c61dd1

Browse files
committed
Tests: adjust tests for Darwin
The Darwin toolchain is incomplete, missing `swift-autolink-extract`. Add a workaround for the missing tool to allow the tests to pass. This then uncovers another issue with ASi builds where the prebuilt NDK is only available on x86_64 hosts. While we could loosen the NDK lookup, we do still occassionally use some of the tools, so for now lets limit the test to x86_64. Fixes: #1682
1 parent c764a39 commit 9c61dd1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Tests/SwiftDriverTests/SwiftDriverTests.swift

+10-3
Original file line numberDiff line numberDiff line change
@@ -7932,11 +7932,14 @@ final class SwiftDriverTests: XCTestCase {
79327932

79337933
func testAndroidNDK() throws {
79347934
try withTemporaryDirectory { path in
7935+
var env = ProcessEnv.vars
7936+
env["SWIFT_DRIVER_SWIFT_AUTOLINK_EXTRACT_EXEC"] = "/garbage/swift-autolink-extract"
7937+
79357938
do {
79367939
let sysroot = path.appending(component: "sysroot")
79377940
var driver = try Driver(args: [
79387941
"swiftc", "-target", "aarch64-unknown-linux-android", "-sysroot", sysroot.pathString, #file
7939-
])
7942+
], env: env)
79407943
let jobs = try driver.planBuild().removingAutolinkExtractJobs()
79417944
let frontend = try XCTUnwrap(jobs.first)
79427945
XCTAssertTrue(frontend.commandLine.contains(subsequence: [
@@ -7946,7 +7949,7 @@ final class SwiftDriverTests: XCTestCase {
79467949
}
79477950

79487951
do {
7949-
var env = ProcessEnv.vars
7952+
var env = env
79507953
env["ANDROID_NDK_ROOT"] = path.appending(component: "ndk").nativePathString(escaped: false)
79517954

79527955
let sysroot = path.appending(component: "sysroot")
@@ -7961,10 +7964,12 @@ final class SwiftDriverTests: XCTestCase {
79617964
]))
79627965
}
79637966

7967+
// The default NDK prebuilts are x86_64 hosts only currently as if r27.
7968+
#if arch(x86_64)
79647969
do {
79657970
let sysroot = path.appending(component: "ndk")
79667971

7967-
var env = ProcessEnv.vars
7972+
var env = env
79687973
env["ANDROID_NDK_ROOT"] = sysroot.nativePathString(escaped: false)
79697974

79707975
#if os(Windows)
@@ -7980,11 +7985,13 @@ final class SwiftDriverTests: XCTestCase {
79807985
], env: env)
79817986
let jobs = try driver.planBuild().removingAutolinkExtractJobs()
79827987
let frontend = try XCTUnwrap(jobs.first)
7988+
print(frontend.commandLine)
79837989
XCTAssertTrue(frontend.commandLine.contains(subsequence: [
79847990
.flag("-sysroot"),
79857991
.path(.absolute(sysroot.appending(components: "toolchains", "llvm", "prebuilt", "\(os)-x86_64", "sysroot"))),
79867992
]))
79877993
}
7994+
#endif
79887995
}
79897996
}
79907997

0 commit comments

Comments
 (0)