aboutsummaryrefslogtreecommitdiff
path: root/run_tests.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2016-04-01 20:51:11 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2016-04-01 23:06:19 +0300
commit81e37e1220c601734d3a6f14df46d49cb44f02ea (patch)
tree4c843dbcb5fa2ea4a95d4391a44483a134e8e7c3 /run_tests.py
parent95877155857f3ddd0789f81590e909e84061f9bf (diff)
downloadmeson-81e37e1220c601734d3a6f14df46d49cb44f02ea.zip
meson-81e37e1220c601734d3a6f14df46d49cb44f02ea.tar.gz
meson-81e37e1220c601734d3a6f14df46d49cb44f02ea.tar.bz2
Run tests in parallel.
Diffstat (limited to 'run_tests.py')
-rwxr-xr-xrun_tests.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/run_tests.py b/run_tests.py
index a3ec0dc..e42e10d 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -28,6 +28,8 @@ from mesonbuild.scripts import meson_test, meson_benchmark
import argparse
import xml.etree.ElementTree as ET
import time
+import multiprocessing
+import concurrent.futures as conc
from mesonbuild.mesonmain import backendlist
@@ -195,7 +197,9 @@ def parse_test_args(testdir):
pass
return args
-def run_test(testdir, extra_args, should_succeed):
+def run_test(skipped, testdir, extra_args, should_succeed):
+ if skipped:
+ return None
with tempfile.TemporaryDirectory(prefix='b ', dir='.') as build_dir:
with tempfile.TemporaryDirectory(prefix='i ', dir=os.getcwd()) as install_dir:
try:
@@ -292,18 +296,24 @@ def run_tests(extra_args):
build_time = 0
test_time = 0
+ executor = conc.ProcessPoolExecutor(max_workers=multiprocessing.cpu_count())
+
for name, test_cases, skipped in all_tests:
current_suite = ET.SubElement(junit_root, 'testsuite', {'name' : name, 'tests' : str(len(test_cases))})
if skipped:
print('\nNot running %s tests.\n' % name)
else:
print('\nRunning %s tests.\n' % name)
+ futures = []
for t in test_cases:
# Jenkins screws us over by automatically sorting test cases by name
# and getting it wrong by not doing logical number sorting.
(testnum, testbase) = os.path.split(t)[-1].split(' ', 1)
testname = '%.3d %s' % (int(testnum), testbase)
- if skipped:
+ result = executor.submit(run_test, skipped, t, extra_args, name != 'failing')
+ for (testname, result) in futures:
+ futures.append((testname, result))
+ if result is None:
current_test = ET.SubElement(current_suite, 'testcase', {'name' : testname,
'classname' : name})
ET.SubElement(current_test, 'skipped', {})
@@ -311,7 +321,6 @@ def run_tests(extra_args):
skipped_tests += 1
else:
ts = time.time()
- result = run_test(t, extra_args, name != 'failing')
te = time.time()
conf_time += result.conftime
build_time += result.buildtime