validate:launcher: Handle test that can't be run in parralel

This commit is contained in:
Thibault Saunier 2017-06-07 15:06:10 -04:00
parent 58cbc9fbfb
commit 9a45cd41a9
2 changed files with 30 additions and 19 deletions

View file

@ -49,7 +49,8 @@ class MesonTest(Test):
timeout = int(child_env.pop('CK_DEFAULT_TIMEOUT', test.timeout))
Test.__init__(self, test.fname[0], name, options,
reporter, timeout=timeout, hard_timeout=timeout)
reporter, timeout=timeout, hard_timeout=timeout,
is_parallel=test.is_parallel)
self.mesontest = test

View file

@ -65,7 +65,7 @@ class Test(Loggable):
def __init__(self, application_name, classname, options,
reporter, duration=0, timeout=DEFAULT_TIMEOUT,
hard_timeout=None, extra_env_variables=None,
expected_failures=None):
expected_failures=None, is_parallel=True):
"""
@timeout: The timeout during which the value return by get_current_value
keeps being exactly equal
@ -100,6 +100,7 @@ class Test(Loggable):
extra_env_variables = extra_env_variables or {}
self.extra_env_variables = extra_env_variables
self.optional = False
self.is_parallel = is_parallel
self.clean()
@ -1268,27 +1269,36 @@ class TestsManager(Loggable):
self.total_num_tests = total_num_tests
self.starting_test_num = starting_test_num
num_jobs = min(self.options.num_jobs, len(self.tests))
tests_left = list(self.tests)
alone_tests = []
tests = []
for test in self.tests:
if test.is_parallel:
tests.append(test)
else:
alone_tests.append(test)
max_num_jobs = min(self.options.num_jobs, len(tests))
jobs_running = 0
for i in range(num_jobs):
if not self.start_new_job(tests_left):
break
jobs_running += 1
while jobs_running != 0:
test = self.tests_wait()
jobs_running -= 1
self.print_test_num(test)
res = test.test_end()
self.reporter.after_test(test)
if res != Result.PASSED and (self.options.forever or
self.options.fatal_error):
return test.result
if self.start_new_job(tests_left):
for num_jobs, tests in [(max_num_jobs, tests), (1, alone_tests)]:
tests_left = list(tests)
for i in range(num_jobs):
if not self.start_new_job(tests_left):
break
jobs_running += 1
while jobs_running != 0:
test = self.tests_wait()
jobs_running -= 1
self.print_test_num(test)
res = test.test_end()
self.reporter.after_test(test)
if res != Result.PASSED and (self.options.forever or
self.options.fatal_error):
return test.result
if self.start_new_job(tests_left):
jobs_running += 1
return Result.PASSED
def print_test_num(self, test):