Skip to content

Commit 73b616b

Browse files
committed
Fix executable tests by passing in the SDK path explicitly.
As-is, these tests are sensitive to the environment and are currently failing with: ``` ld: library not found for -lobjc ``` Passing in the sdk path explicitly should make them pass and be more resilient.
1 parent f0b22be commit 73b616b

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

Package.resolved

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
557557
$0 <<< "import G;"
558558
}
559559

560+
let sdkArgumentsForTesting = try Driver.sdkArgumentsForTesting() ?? []
560561
let packageRootPath = URL(fileURLWithPath: #file).pathComponents
561562
.prefix(while: { $0 != "Tests" }).joined(separator: "/").dropFirst()
562563
let testInputsPath = packageRootPath + "/TestInputs"
@@ -567,7 +568,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
567568
"-I", swiftModuleInterfacesPath,
568569
"-experimental-explicit-module-build",
569570
"-working-directory", path.pathString,
570-
main.pathString],
571+
main.pathString] + sdkArgumentsForTesting,
571572
env: ProcessEnv.vars)
572573
let jobs = try driver.planBuild()
573574
try driver.run(jobs: jobs)

Tests/SwiftDriverTests/JobExecutorTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,10 @@ final class JobExecutorTests: XCTestCase {
474474
fileSystem: localFileSystem,
475475
env: ProcessEnv.vars)
476476
let outputPath = path.appending(component: "finalOutput")
477+
let sdkArgumentsForTesting = try Driver.sdkArgumentsForTesting() ?? []
477478
var driver = try Driver(args: ["swiftc", main.pathString,
478479
"-driver-filelist-threshold", "0",
479-
"-o", outputPath.pathString],
480+
"-o", outputPath.pathString] + sdkArgumentsForTesting,
480481
env: ProcessEnv.vars,
481482
diagnosticsEngine: diags,
482483
fileSystem: localFileSystem,
@@ -511,10 +512,11 @@ final class JobExecutorTests: XCTestCase {
511512
fileSystem: localFileSystem,
512513
env: ProcessEnv.vars)
513514
let outputPath = path.appending(component: "finalOutput")
515+
let sdkArgumentsForTesting = try Driver.sdkArgumentsForTesting() ?? []
514516
var driver = try Driver(args: ["swiftc", main.pathString,
515517
"-save-temps",
516518
"-driver-filelist-threshold", "0",
517-
"-o", outputPath.pathString],
519+
"-o", outputPath.pathString] + sdkArgumentsForTesting,
518520
env: ProcessEnv.vars,
519521
diagnosticsEngine: diags,
520522
fileSystem: localFileSystem,
@@ -549,10 +551,11 @@ final class JobExecutorTests: XCTestCase {
549551
fileSystem: localFileSystem,
550552
env: ProcessEnv.vars)
551553
let outputPath = path.appending(component: "finalOutput")
554+
let sdkArgumentsForTesting = try Driver.sdkArgumentsForTesting() ?? []
552555
var driver = try Driver(args: ["swiftc", main.pathString,
553556
"-driver-filelist-threshold", "0",
554557
"-Xfrontend", "-debug-crash-immediately",
555-
"-o", outputPath.pathString],
558+
"-o", outputPath.pathString] + sdkArgumentsForTesting,
556559
env: ProcessEnv.vars,
557560
diagnosticsEngine: diags,
558561
fileSystem: localFileSystem,

Tests/SwiftDriverTests/ParsableMessageTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,10 @@ final class ParsableMessageTests: XCTestCase {
354354
$0 <<< "print(\"hello, world!\")"
355355
}
356356
let diags = DiagnosticsEngine()
357+
let sdkArgumentsForTesting = try Driver.sdkArgumentsForTesting() ?? []
357358
var driver = try Driver(args: ["swiftc", main.pathString,
358359
"-use-frontend-parseable-output",
359-
"-o", output.pathString],
360+
"-o", output.pathString] + sdkArgumentsForTesting,
360361
env: ProcessEnv.vars,
361362
diagnosticsEngine: diags,
362363
fileSystem: localFileSystem)

0 commit comments

Comments
 (0)