Bug 1433941 - Passed remainder arguments as it is |mach python-test| r=ahal

Differential Revision: https://phabricator.services.mozilla.com/D47832
This commit is contained in:
Anmol Agarwal
2019-10-04 18:32:37 +00:00
parent 74db5a29ed
commit 542e3c2852
3 changed files with 10 additions and 2 deletions

View File

@@ -97,6 +97,10 @@ class MachCommands(MachCommandBase):
metavar='TEST',
help=('Tests to run. Each test can be a single file or a directory. '
'Default test resolution relies on PYTHON_UNITTEST_MANIFESTS.'))
@CommandArgument('extra', nargs=argparse.REMAINDER,
metavar='PYTEST ARGS',
help=('Arguments that aren\'t recognized by mach. These will be '
'passed as it is to pytest'))
def python_test(self, *args, **kwargs):
try:
tempdir = os.environ[b'PYTHON_TEST_TMP'] = str(tempfile.mkdtemp(suffix='-python-test'))
@@ -113,6 +117,7 @@ class MachCommands(MachCommandBase):
jobs=None,
python=None,
exitfirst=False,
extra=None,
**kwargs):
python = python or self.virtualenv_manager.python_path
self.activate_pipenv(pipfile=None, populate=True, python=python)
@@ -154,6 +159,9 @@ class MachCommands(MachCommandBase):
sequential = []
os.environ.setdefault('PYTEST_ADDOPTS', '')
if extra:
os.environ['PYTEST_ADDOPTS'] += " " + " ".join(extra)
if exitfirst:
sequential = tests
os.environ['PYTEST_ADDOPTS'] += " -x"