Bug 1494090 - Added -x option to |mach python-test| r=ahal

Bug 1494090 - Added -x option to |mach python-test|

Differential Revision: https://phabricator.services.mozilla.com/D47321

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Anmol Agarwal 2019-09-30 20:18:08 +00:00
Родитель 4ffdad9bca
Коммит 35d00cbafb
1 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -85,6 +85,10 @@ class MachCommands(MachCommandBase):
type=int,
help='Number of concurrent jobs to run. Default is the number of CPUs '
'in the system.')
@CommandArgument('-x', '--exitfirst',
default=False,
action='store_true',
help='Runs all tests sequentially and breaks at the first failure.')
@CommandArgument('--subsuite',
default=None,
help=('Python subsuite to run. If not specified, all subsuites are run. '
@ -108,6 +112,7 @@ class MachCommands(MachCommandBase):
verbose=False,
jobs=None,
python=None,
exitfirst=False,
**kwargs):
python = python or self.virtualenv_manager.python_path
self.activate_pipenv(pipfile=None, populate=True, python=python)
@ -147,11 +152,17 @@ class MachCommands(MachCommandBase):
parallel = []
sequential = []
for test in tests:
if test.get('sequential'):
sequential.append(test)
else:
parallel.append(test)
os.environ.setdefault('PYTEST_ADDOPTS', '')
if exitfirst:
sequential = tests
os.environ['PYTEST_ADDOPTS'] += " -x"
else:
for test in tests:
if test.get('sequential'):
sequential.append(test)
else:
parallel.append(test)
self.jobs = jobs or cpu_count()
self.terminate = False
@ -186,6 +197,8 @@ class MachCommands(MachCommandBase):
for test in sequential:
return_code = on_test_finished(self._run_python_test(test))
if return_code and exitfirst:
break
self.log(logging.INFO, 'python-test', {'return_code': return_code},
'Return code from mach python-test: {return_code}')