diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2019-10-07 13:13:54 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-05-18 13:53:58 -0700 |
commit | af787874a8e4eab8222382128ccfb5549b31c801 (patch) | |
tree | 6f67ec9f0a3f6b48681d7f981e83732266916456 /mesonbuild | |
parent | 0ec94ca0629415d4b555e8ef38a5093a65e0539e (diff) | |
download | meson-af787874a8e4eab8222382128ccfb5549b31c801.zip meson-af787874a8e4eab8222382128ccfb5549b31c801.tar.gz meson-af787874a8e4eab8222382128ccfb5549b31c801.tar.bz2 |
pass exe_wrapper to test scripts through the environment
This adds a new MESON_EXE_WRAPPER environment variable containing the
string form of the exe_wrapper, if there is an exe_wrapper defined.
Fixes #4427
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/mtest.py | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 8806932..4aafe62 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -42,7 +42,7 @@ from . import build from . import environment from . import mlog from .dependencies import ExternalProgram -from .mesonlib import MesonException, get_wine_shortpath, split_args +from .mesonlib import MesonException, get_wine_shortpath, split_args, join_args from .backend.backends import TestProtocol if T.TYPE_CHECKING: @@ -609,20 +609,19 @@ class SingleTestRunner: return ['java', '-jar'] + self.test.fname elif not self.test.is_cross_built and run_with_mono(self.test.fname[0]): return ['mono'] + self.test.fname - else: - if self.test.is_cross_built and self.test.needs_exe_wrapper: - if self.test.exe_runner is None: - # Can not run test on cross compiled executable - # because there is no execute wrapper. - return None - elif self.test.cmd_is_built: - # If the command is not built (ie, its a python script), - # then we don't check for the exe-wrapper - if not self.test.exe_runner.found(): - msg = 'The exe_wrapper defined in the cross file {!r} was not ' \ - 'found. Please check the command and/or add it to PATH.' - raise TestException(msg.format(self.test.exe_runner.name)) - return self.test.exe_runner.get_command() + self.test.fname + elif self.test.cmd_is_built and self.test.needs_exe_wrapper: + if self.test.exe_runner is None: + # Can not run test on cross compiled executable + # because there is no execute wrapper. + return None + elif self.test.cmd_is_built: + # If the command is not built (ie, its a python script), + # then we don't check for the exe-wrapper + if not self.test.exe_runner.found(): + msg = ('The exe_wrapper defined in the cross file {!r} was not ' + 'found. Please check the command and/or add it to PATH.') + raise TestException(msg.format(self.test.exe_runner.name)) + return self.test.exe_runner.get_command() + self.test.fname return self.test.fname def run(self) -> TestRun: @@ -868,6 +867,9 @@ class TestHarness: env = os.environ.copy() test_env = test.env.get_env(env) env.update(test_env) + if (test.is_cross_built and test.needs_exe_wrapper and + test.exe_runner and test.exe_runner.found()): + env['MESON_EXE_WRAPPER'] = join_args(test.exe_runner.get_command()) return SingleTestRunner(test, test_env, env, options) def process_test_result(self, result: TestRun) -> None: |