Bug 1048446 - [python-test] Add 'sequential' key to python.ini manifests so tests can opt out of running in parallel, r=jmaher

MozReview-Commit-ID: DQWJDdU9QHO
This commit is contained in:
Andrew Halberstadt
2017-06-01 09:50:15 -04:00
parent 44dc5b30c3
commit 1386807b19

View File

@@ -138,26 +138,38 @@ class MachCommands(MachCommandBase):
filters.append(mpf.subsuite(subsuite))
tests = mp.active_tests(filters=filters, disabled=False, **mozinfo.info)
parallel = []
sequential = []
for test in tests:
if test.get('sequential'):
sequential.append(test)
else:
parallel.append(test)
self.jobs = jobs
self.terminate = False
self.verbose = verbose
return_code = 0
with ThreadPoolExecutor(max_workers=self.jobs) as executor:
futures = [executor.submit(self._run_python_test, test['path'])
for test in tests]
try:
for future in as_completed(futures):
output, ret, test_path = future.result()
def on_test_finished(result):
output, ret, test_path = result
for line in output:
self.log(logging.INFO, 'python-test', {'line': line.rstrip()}, '{line}')
if ret and not return_code:
self.log(logging.ERROR, 'python-test', {'test_path': test_path, 'ret': ret}, 'Setting retcode to {ret} from {test_path}')
return_code = return_code or ret
self.log(logging.ERROR, 'python-test', {'test_path': test_path, 'ret': ret},
'Setting retcode to {ret} from {test_path}')
return return_code or ret
with ThreadPoolExecutor(max_workers=self.jobs) as executor:
futures = [executor.submit(self._run_python_test, test['path'])
for test in parallel]
try:
for future in as_completed(futures):
return_code = on_test_finished(future.result())
except KeyboardInterrupt:
# Hack to force stop currently running threads.
# https://gist.github.com/clchiou/f2608cbe54403edb0b13
@@ -165,7 +177,11 @@ class MachCommands(MachCommandBase):
thread._threads_queues.clear()
raise
self.log(logging.INFO, 'python-test', {'return_code': return_code}, 'Return code from mach python-test: {return_code}')
for test in sequential:
return_code = on_test_finished(self._run_python_test(test['path']))
self.log(logging.INFO, 'python-test', {'return_code': return_code},
'Return code from mach python-test: {return_code}')
return return_code
def _run_python_test(self, test_path):