diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-04-23 17:34:31 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-04-23 17:34:31 +0300 |
commit | ff7c8b16473ed483316acba17472fcd829b0e660 (patch) | |
tree | 9c648cd915de918bbb574dd8b00b71a0af12dd98 | |
parent | 144b2314ce30708125f2d5488ee85ac1e6d0b458 (diff) | |
download | meson-ff7c8b16473ed483316acba17472fcd829b0e660.zip meson-ff7c8b16473ed483316acba17472fcd829b0e660.tar.gz meson-ff7c8b16473ed483316acba17472fcd829b0e660.tar.bz2 |
Run unit tests in-process too for extra speed.
-rwxr-xr-x | meson_test.py | 9 | ||||
-rwxr-xr-x | run_tests.py | 33 |
2 files changed, 30 insertions, 12 deletions
diff --git a/meson_test.py b/meson_test.py index f6f8fbd..d4a5b62 100755 --- a/meson_test.py +++ b/meson_test.py @@ -165,8 +165,8 @@ def run_tests(options, datafilename): drain_futures(futures) print('\nFull log written to %s.' % logfilename) -if __name__ == '__main__': - options = parser.parse_args() +def run(args): + options = parser.parse_args(args) if len(options.args) != 1: print('Test runner for Meson. Do not run on your own, mmm\'kay?') print('%s [data file]' % sys.argv[0]) @@ -175,5 +175,8 @@ if __name__ == '__main__': datafile = options.args[0] run_tests(options, datafile) if tests_failed: - sys.exit(1) + return 1 + return 0 +if __name__ == '__main__': + sys.exit(run(sys.argv[1:])) diff --git a/run_tests.py b/run_tests.py index 196307b..d830fe1 100755 --- a/run_tests.py +++ b/run_tests.py @@ -20,7 +20,7 @@ from io import StringIO import sys import environment import mesonlib -import meson +import meson, meson_test import argparse import xml.etree.ElementTree as ET import time @@ -147,7 +147,7 @@ def log_text_file(logfile, testdir, msg, stdo, stde): if stop: raise StopException() -def run_test_inprocess(commandlist): +def run_configure_inprocess(commandlist): old_stdout = sys.stdout sys.stdout = mystdout = StringIO() old_stderr = sys.stderr @@ -157,6 +157,20 @@ def run_test_inprocess(commandlist): sys.stderr = old_stderr return (returncode, mystdout.getvalue(), mystderr.getvalue()) +def run_test_inprocess(testdir): + old_stdout = sys.stdout + sys.stdout = mystdout = StringIO() + old_stderr = sys.stderr + sys.stderr = mystderr = StringIO() + old_cwd = os.getcwd() + os.chdir(testdir) + returncode = meson_test.run(['meson-private/meson_test_setup.dat']) + sys.stdout = old_stdout + sys.stderr = old_stderr + os.chdir(old_cwd) + return (returncode, mystdout.getvalue(), mystderr.getvalue()) + + def run_test(testdir, should_succeed): global compile_commands shutil.rmtree(test_build_dir) @@ -167,7 +181,7 @@ def run_test(testdir, should_succeed): gen_start = time.time() gen_command = [meson_command, '--prefix', '/usr', '--libdir', 'lib', testdir, test_build_dir]\ + unity_flags + backend_flags - (returncode, stdo, stde) = run_test_inprocess(gen_command) + (returncode, stdo, stde) = run_configure_inprocess(gen_command) gen_time = time.time() - gen_start if not should_succeed: if returncode != 0: @@ -190,13 +204,14 @@ def run_test(testdir, should_succeed): if pc.returncode != 0: return TestResult('Compiling source code failed.', stdo, stde, gen_time, build_time) test_start = time.time() - pt = subprocess.Popen(test_commands, cwd=test_build_dir, - stdout=subprocess.PIPE, stderr=subprocess.PIPE) - (o, e) = pt.communicate() + # Note that we don't test that running e.g. 'ninja test' actually + # works. One hopes that this is a common enough happening that + # it is picked up immediately on development. + (returncode, tstdo, tstde) = run_test_inprocess(test_build_dir) test_time = time.time() - test_start - stdo += o.decode('utf-8') - stde += e.decode('utf-8') - if pt.returncode != 0: + stdo += tstdo + stde += tstde + if returncode != 0: return TestResult('Running unit tests failed.', stdo, stde, gen_time, build_time, test_time) if len(install_commands) == 0: print("Skipping install test") |