diff --git a/run_project_tests.py b/run_project_tests.py index 17e095b7a..d3da4e6c8 100755 --- a/run_project_tests.py +++ b/run_project_tests.py @@ -33,7 +33,7 @@ import time import multiprocessing import concurrent.futures as conc import re -from run_unittests import get_fake_options, run_configure_inprocess +from run_unittests import get_fake_options, run_configure from run_tests import get_backend_commands, get_backend_args_for_dir, Backend from run_tests import ensure_backend_detects_changes @@ -327,9 +327,9 @@ def _run_test(testdir, test_build_dir, install_dir, extra_args, compiler, backen test_args = parse_test_args(testdir) gen_start = time.time() # Configure in-process - gen_command = [meson_command, '--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir]\ + gen_args = ['--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir]\ + flags + test_args + extra_args - (returncode, stdo, stde) = run_configure_inprocess(gen_command) + (returncode, stdo, stde) = run_configure(meson_command, gen_args) try: logfile = os.path.join(test_build_dir, 'meson-logs/meson-log.txt') with open(logfile, errors='ignore') as f: diff --git a/run_tests.py b/run_tests.py index 79c963948..4ac458cdd 100755 --- a/run_tests.py +++ b/run_tests.py @@ -31,6 +31,12 @@ from glob import glob Backend = Enum('Backend', 'ninja vs xcode') +if 'MESON_EXE' in os.environ: + import shlex + meson_exe = shlex.split(os.environ['MESON_EXE']) +else: + meson_exe = None + if mesonlib.is_windows() or mesonlib.is_cygwin(): exe_suffix = '.exe' else: @@ -127,18 +133,28 @@ def get_fake_options(prefix): def should_run_linux_cross_tests(): return shutil.which('arm-linux-gnueabihf-gcc-7') and not platform.machine().lower().startswith('arm') -def run_configure_inprocess(commandlist): +def run_configure_inprocess(meson_command, commandlist): old_stdout = sys.stdout sys.stdout = mystdout = StringIO() old_stderr = sys.stderr sys.stderr = mystderr = StringIO() try: - returncode = mesonmain.run(commandlist[1:], commandlist[0]) + returncode = mesonmain.run(commandlist, meson_command) finally: sys.stdout = old_stdout sys.stderr = old_stderr return returncode, mystdout.getvalue(), mystderr.getvalue() +def run_configure_external(full_command): + pc, o, e = mesonlib.Popen_safe(full_command) + return pc.returncode, o, e + +def run_configure(meson_command, commandlist): + global meson_exe + if meson_exe: + return run_configure_external(meson_exe + commandlist) + return run_configure_inprocess(meson_command, commandlist) + class FakeEnvironment(object): def __init__(self): self.cross_info = None diff --git a/run_unittests.py b/run_unittests.py index 80c58ea0c..2d4dfbbe5 100755 --- a/run_unittests.py +++ b/run_unittests.py @@ -40,7 +40,7 @@ from mesonbuild.dependencies import PkgConfigDependency, ExternalProgram from run_tests import exe_suffix, get_fake_options, FakeEnvironment from run_tests import get_builddir_target_args, get_backend_commands, Backend -from run_tests import ensure_backend_detects_changes, run_configure_inprocess +from run_tests import ensure_backend_detects_changes, run_configure from run_tests import should_run_linux_cross_tests @@ -460,8 +460,9 @@ class BasePlatformTests(unittest.TestCase): # Get the backend # FIXME: Extract this from argv? self.backend = getattr(Backend, os.environ.get('MESON_UNIT_TEST_BACKEND', 'ninja')) - self.meson_args = [os.path.join(src_root, 'meson.py'), '--backend=' + self.backend.name] - self.meson_command = [sys.executable] + self.meson_args + self.meson_mainfile = os.path.join(src_root, 'meson.py') + self.meson_args = ['--backend=' + self.backend.name] + self.meson_command = [sys.executable, self.meson_mainfile] + self.meson_args self.mconf_command = [sys.executable, os.path.join(src_root, 'meson.py'), 'configure'] self.mintro_command = [sys.executable, os.path.join(src_root, 'meson.py'), 'introspect'] self.mtest_command = [sys.executable, os.path.join(src_root, 'meson.py'), 'test', '-C', self.builddir] @@ -527,7 +528,7 @@ class BasePlatformTests(unittest.TestCase): self.privatedir = os.path.join(self.builddir, 'meson-private') if inprocess: try: - out = run_configure_inprocess(self.meson_args + args + extra_args)[1] + out = run_configure(self.meson_mainfile, self.meson_args + args + extra_args)[1] except: self._print_meson_log() raise