Skip to content

Commit 4069077

Browse files
committed
[Test][SwiftPM] Fix SwiftPM tests to run with DYLD_LIBRARY_PATH set.
We should set `DYLD_LIBRARY_PATH` when running the tests, otherwise we'll pick up the wrong libraries.
1 parent 47049b4 commit 4069077

File tree

1 file changed

+13
-1
lines changed
  • utils/swift_build_support/swift_build_support/products

1 file changed

+13
-1
lines changed

utils/swift_build_support/swift_build_support/products/swiftpm.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ def is_before_build_script_impl_product(cls):
4242
def should_build(self, host_target):
4343
return True
4444

45+
def _get_test_environment(self, host_target):
46+
env = {}
47+
if platform.system() == 'Darwin':
48+
# the resulting binaries would search first in /usr/lib/swift,
49+
# we need to prefer the libraries we just built
50+
env['DYLD_LIBRARY_PATH'] = os.path.join(
51+
_get_toolchain_path(host_target, self, self.args),
52+
'usr', 'lib', 'swift', 'macosx')
53+
return env
54+
4555
def run_bootstrap_script(
4656
self,
4757
action,
@@ -50,6 +60,8 @@ def run_bootstrap_script(
5060
*,
5161
compile_only_for_running_host_architecture=False,
5262
):
63+
test_environment = self._get_test_environment(host_target)
64+
5365
script_path = os.path.join(
5466
self.source_dir, 'Utilities', 'bootstrap')
5567

@@ -115,7 +127,7 @@ def run_bootstrap_script(
115127

116128
helper_cmd.extend(additional_params)
117129

118-
shell.call(helper_cmd)
130+
shell.call(helper_cmd, env=test_environment)
119131

120132
def build(self, host_target):
121133
self.run_bootstrap_script(

0 commit comments

Comments
 (0)