diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-11-22 00:47:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-22 00:47:20 +0200 |
commit | d882b6fbd466940d452cfaa890bd9270e10a93b4 (patch) | |
tree | d1ed9d893da50afb4ed3e6f031da91949f1d67ee /run_tests.py | |
parent | fdb48a3a0f0425a6bd4a71a2e004479080955df8 (diff) | |
parent | f9e88cd37e6babc1de476398f54a540f3eeca1c7 (diff) | |
download | meson-d882b6fbd466940d452cfaa890bd9270e10a93b4.zip meson-d882b6fbd466940d452cfaa890bd9270e10a93b4.tar.gz meson-d882b6fbd466940d452cfaa890bd9270e10a93b4.tar.bz2 |
Merge pull request #2498 from mesonbuild/runpython
Add possibility to run Python scripts with current interpreter
Diffstat (limited to 'run_tests.py')
-rwxr-xr-x | run_tests.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/run_tests.py b/run_tests.py index 79c9639..b287a1a 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 @@ -207,11 +223,12 @@ if __name__ == '__main__': 'coverage.process_startup()\n') env['COVERAGE_PROCESS_START'] = '.coveragerc' env['PYTHONPATH'] = os.pathsep.join([td] + env.get('PYTHONPATH', [])) - returncode += subprocess.call([sys.executable, 'run_unittests.py', '-v'], env=env) + returncode += subprocess.call(mesonlib.python_command + ['run_unittests.py', '-v'], env=env) # Ubuntu packages do not have a binary without -6 suffix. if should_run_linux_cross_tests(): print(mlog.bold('Running cross compilation tests.').get_text(mlog.colorize_console)) print() - returncode += subprocess.call([sys.executable, 'run_cross_test.py', 'cross/ubuntu-armhf.txt'], env=env) - returncode += subprocess.call([sys.executable, 'run_project_tests.py'] + sys.argv[1:], env=env) + returncode += subprocess.call(mesonlib.python_command + ['run_cross_test.py', 'cross/ubuntu-armhf.txt'], + env=env) + returncode += subprocess.call(mesonlib.python_command + ['run_project_tests.py'] + sys.argv[1:], env=env) sys.exit(returncode) |