Skip to content

Commit 089b61d

Browse files
committed
[Test][SwiftPM] Fix SwiftPM tests to run with DYLD_LIBRARY_PATH set.
We need to tell SwiftPM's tests to run with `DYLD_LIBRARY_PATH` pointing to the new runtimes, otherwise they'll fail.
1 parent b0671c9 commit 089b61d

File tree

1 file changed

+21
-2
lines changed
  • utils/swift_build_support/swift_build_support/products

1 file changed

+21
-2
lines changed

utils/swift_build_support/swift_build_support/products/swiftpm.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# ----------------------------------------------------------------------------
1212

1313
import os
14+
import platform
1415

1516
from . import cmark
1617
from . import foundation
@@ -23,7 +24,7 @@
2324
from . import swift_testing
2425
from . import xctest
2526
from .. import shell
26-
from ..targets import StdlibDeploymentTarget
27+
from ..targets import StdlibDeploymentTarget, darwin_toolchain_prefix
2728

2829

2930
class SwiftPM(product.Product):
@@ -50,6 +51,10 @@ def run_bootstrap_script(
5051
*,
5152
compile_only_for_running_host_architecture=False,
5253
):
54+
toolchain_path = _get_toolchain_path(host_target, self, self.args)
55+
swift_lib_path = os.path.join(toolchain_path,
56+
'usr', 'lib', 'swift', 'macosx')
57+
5358
script_path = os.path.join(
5459
self.source_dir, 'Utilities', 'bootstrap')
5560

@@ -79,7 +84,8 @@ def run_bootstrap_script(
7984
"--cmake-path", self.toolchain.cmake,
8085
"--ninja-path", self.toolchain.ninja,
8186
"--build-dir", self.build_dir,
82-
"--llbuild-build-dir", llbuild_build_dir
87+
"--llbuild-build-dir", llbuild_build_dir,
88+
"--extra-dynamic-library-path", swift_lib_path
8389
]
8490

8591
# Pass Dispatch directory down if we built it
@@ -169,3 +175,16 @@ def get_dependencies(cls):
169175
xctest.XCTest,
170176
llbuild.LLBuild,
171177
swift_testing.SwiftTesting]
178+
179+
def _get_toolchain_path(host_target, product, args):
180+
# TODO check if we should prefer using product.install_toolchain_path
181+
# this logic initially was inside run_build_script_helper
182+
# and was factored out so it can be used in testing as well
183+
184+
toolchain_path = product.host_install_destdir(host_target)
185+
if platform.system() == 'Darwin':
186+
# The prefix is an absolute path, so concatenate without os.path.
187+
toolchain_path += \
188+
darwin_toolchain_prefix(args.install_prefix)
189+
190+
return toolchain_path

0 commit comments

Comments
 (0)