Simulate rpath on windows by adding dll subdirectories to global path in tests.

pull/216/head
Jussi Pakkanen 9 years ago
parent d2fa9301ac
commit b7e391ead4
  1. 20
      backends.py
  2. 2
      meson_test.py

@ -20,7 +20,7 @@ from coredata import MesonException
class TestSerialisation: class TestSerialisation:
def __init__(self, name, fname, is_cross, exe_wrapper, is_parallel, cmd_args, env, def __init__(self, name, fname, is_cross, exe_wrapper, is_parallel, cmd_args, env,
should_fail, valgrind_args, timeout): should_fail, valgrind_args, timeout, extra_paths):
self.name = name self.name = name
self.fname = fname self.fname = fname
self.is_cross = is_cross self.is_cross = is_cross
@ -31,6 +31,7 @@ class TestSerialisation:
self.should_fail = should_fail self.should_fail = should_fail
self.valgrind_args = valgrind_args self.valgrind_args = valgrind_args
self.timeout = timeout self.timeout = timeout
self.extra_paths = extra_paths
# This class contains the basic functionality that is needed by all backends. # This class contains the basic functionality that is needed by all backends.
# Feel free to move stuff in and out of it as you see fit. # Feel free to move stuff in and out of it as you see fit.
@ -238,6 +239,17 @@ class Backend():
args += self.build_target_link_arguments(compiler, d.get_dependencies()) args += self.build_target_link_arguments(compiler, d.get_dependencies())
return args return args
def determine_windows_extra_paths(self, target):
'''On Windows there is no such thing as an rpath.
We must determine all locations of DLLs that this exe
links to and return them so they can be used in unit
tests.'''
if not isinstance(target, build.Executable):
print(target)
return []
prospectives = target.get_transitive_rpaths()
return [os.path.join(self.environment.get_build_dir(), i) for i in prospectives if len(i) > 0]
def write_test_file(self, datafile): def write_test_file(self, datafile):
arr = [] arr = []
for t in self.build.get_tests(): for t in self.build.get_tests():
@ -251,9 +263,13 @@ class Backend():
exe_wrapper = self.environment.cross_info.get('exe_wrapper', None) exe_wrapper = self.environment.cross_info.get('exe_wrapper', None)
else: else:
exe_wrapper = None exe_wrapper = None
if mesonlib.is_windows():
extra_paths = self.determine_windows_extra_paths(exe)
else:
extra_paths = []
ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper, ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper,
t.is_parallel, t.cmd_args, t.env, t.should_fail, t.valgrind_args, t.is_parallel, t.cmd_args, t.env, t.should_fail, t.valgrind_args,
t.timeout) t.timeout, extra_paths)
arr.append(ts) arr.append(ts)
pickle.dump(arr, datafile) pickle.dump(arr, datafile)

@ -95,6 +95,8 @@ def run_single_test(wrap, test):
starttime = time.time() starttime = time.time()
child_env = os.environ.copy() child_env = os.environ.copy()
child_env.update(test.env) child_env.update(test.env)
if len(test.extra_paths) > 0:
child_env['PATH'] = child_env['PATH'] + ';'.join([''] + test.extra_paths)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=child_env) env=child_env)
timed_out = False timed_out = False

Loading…
Cancel
Save