Transfer test parallelism data from source to test runner.

pull/15/head
Jussi Pakkanen 11 years ago
parent 26bf87d1dc
commit ff1ac7eed1
  1. 12
      backends.py
  2. 8
      interpreter.py
  3. 17
      meson_test.py

@ -94,6 +94,14 @@ def do_conf_file(src, dst, confdata):
pass
os.replace(dst_tmp, dst)
class TestSerialisation:
def __init__(self, name, fname, is_cross, exe_wrapper, is_parallel):
self.name = name
self.fname = fname
self.is_cross = is_cross
self.exe_runner = exe_wrapper
self.is_parallel = is_parallel
# It may seem a bit silly that this Backend class exists on its own
# rather than being a part of NinjaBackend, which is the only class
# that uses Backend. The point is that common functionality
@ -483,14 +491,14 @@ class NinjaBackend(Backend):
def write_test_file(self, datafile):
arr = []
for t in self.build.get_tests():
name = t.get_name()
fname = os.path.join(self.environment.get_build_dir(), self.get_target_filename(t.get_exe()))
is_cross = self.environment.is_cross_build()
if is_cross:
exe_wrapper = self.environment.cross_info.get('exe_wrapper', None)
else:
exe_wrapper = None
arr.append([name, fname, is_cross, exe_wrapper])
ts = TestSerialisation(t.get_name(), fname, is_cross, exe_wrapper, t.is_parallel)
arr.append(ts)
pickle.dump(arr, datafile)
def generate_dep_gen_rules(self, outfile):

@ -642,10 +642,11 @@ class SharedLibrary(BuildTarget):
return aliases
class Test(InterpreterObject):
def __init__(self, name, exe):
def __init__(self, name, exe, is_parallel):
InterpreterObject.__init__(self)
self.name = name
self.exe = exe
self.is_parallel = is_parallel
def get_exe(self):
return self.exe
@ -1121,7 +1122,10 @@ class Interpreter():
def func_test(self, node, args, kwargs):
self.validate_arguments(args, 2, [str, Executable])
t = Test(args[0], args[1])
par = kwargs.get('is_parallel', True)
if not isinstance(par, bool):
raise InterpreterException('Keyword argument is_parallel must be a boolean.')
t = Test(args[0], args[1], par)
self.build.tests.append(t)
mlog.debug('Adding test "', mlog.bold(args[0]), '".', sep='')

@ -100,24 +100,21 @@ def run_tests(options, datafilename):
num_workers = int(os.environ[varname])
except ValueError:
write_log('Invalid value in %s, using 1 thread.' % varname)
num_workers = 1
else:
num_workers = multiprocessing.cpu_count()
executor = conc.ThreadPoolExecutor(max_workers=num_workers)
futures = []
for i, test in enumerate(tests):
name = test[0]
fname = test[1]
is_cross = test[2]
exe_runner = test[3]
is_parallel = False
if not is_parallel:
if not test.is_parallel:
drain_futures(futures)
futures = []
f = run_single_test(wrap, fname, is_cross, exe_runner)
print_stats(numlen, tests, name, f, i, logfile)
res = run_single_test(wrap, test.fname, test.is_cross, test.exe_runner)
print_stats(numlen, tests, test.name, res, i, logfile)
else:
f = executor.submit(run_single_test, wrap, fname, is_cross, exe_runner)
futures.append((f, numlen, tests, name, f, i, logfile))
f = executor.submit(run_single_test, wrap, test.fname,
test.is_cross, test.exe_runner)
futures.append((f, numlen, tests, test.name, f, i, logfile))
drain_futures(futures)
print('\nFull log written to %s.' % logfilename)

Loading…
Cancel
Save