diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-04-23 17:08:08 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-04-23 17:08:08 +0300 |
commit | 144b2314ce30708125f2d5488ee85ac1e6d0b458 (patch) | |
tree | 3dbc89cbcfd8cbb436de0c58c3ee4952ac35facd | |
parent | b5cec55835b2d6dca38c52a7786ecef79b448bd7 (diff) | |
download | meson-144b2314ce30708125f2d5488ee85ac1e6d0b458.zip meson-144b2314ce30708125f2d5488ee85ac1e6d0b458.tar.gz meson-144b2314ce30708125f2d5488ee85ac1e6d0b458.tar.bz2 |
Run Meson test invocations in-process because spawning a new Python process for each is too slow.
-rwxr-xr-x | run_tests.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/run_tests.py b/run_tests.py index 9e81649..196307b 100755 --- a/run_tests.py +++ b/run_tests.py @@ -16,8 +16,11 @@ from glob import glob import os, subprocess, shutil, sys, platform, signal +from io import StringIO +import sys import environment import mesonlib +import meson import argparse import xml.etree.ElementTree as ET import time @@ -144,6 +147,16 @@ def log_text_file(logfile, testdir, msg, stdo, stde): if stop: raise StopException() +def run_test_inprocess(commandlist): + old_stdout = sys.stdout + sys.stdout = mystdout = StringIO() + old_stderr = sys.stderr + sys.stderr = mystderr = StringIO() + returncode = meson.run(commandlist) + sys.stdout = old_stdout + sys.stderr = old_stderr + return (returncode, mystdout.getvalue(), mystderr.getvalue()) + def run_test(testdir, should_succeed): global compile_commands shutil.rmtree(test_build_dir) @@ -152,18 +165,15 @@ def run_test(testdir, should_succeed): os.mkdir(install_dir) print('Running test: ' + testdir) gen_start = time.time() - gen_command = [sys.executable, meson_command, '--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir]\ + gen_command = [meson_command, '--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir]\ + unity_flags + backend_flags - p = subprocess.Popen(gen_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (stdo, stde) = p.communicate() + (returncode, stdo, stde) = run_test_inprocess(gen_command) gen_time = time.time() - gen_start - stdo = stdo.decode('utf-8') - stde = stde.decode('utf-8') if not should_succeed: - if p.returncode != 0: + if returncode != 0: return TestResult('', stdo, stde, gen_time) return TestResult('Test that should have failed succeeded', stdo, stde, gen_time) - if p.returncode != 0: + if returncode != 0: return TestResult('Generating the build system failed.', stdo, stde, gen_time) if 'msbuild' in compile_commands[0]: sln_name = glob(os.path.join(test_build_dir, '*.sln'))[0] |