Bug 1665494 - In mach python-test, don't install requirements.txt in parallel r=ahal

If you set a `DEFAULT` `requirements` file in a Python test manifest, the current implementation of `python-test` will try (and usually fail) to install the file once for every test file in parallel. Instead, initializing the environment should be done once when the command starts up.

Differential Revision: https://phabricator.services.mozilla.com/D90475
This commit is contained in:
Ricky Stewart
2020-09-18 01:38:46 +00:00
parent 3ec8cb6e1b
commit 61223e3eaf

View File

@@ -181,6 +181,14 @@ class MachCommands(MachCommandBase):
if extra:
os.environ['PYTEST_ADDOPTS'] += " " + " ".join(extra)
installed_requirements = set()
for test in tests:
if (test.get('requirements') and
test['requirements'] not in installed_requirements):
self.virtualenv_manager.install_pip_requirements(
test['requirements'], quiet=True)
installed_requirements.add(test['requirements'])
if exitfirst:
sequential = tests
os.environ['PYTEST_ADDOPTS'] += " -x"
@@ -234,9 +242,6 @@ class MachCommands(MachCommandBase):
def _run_python_test(self, test):
from mozprocess import ProcessHandler
if test.get('requirements'):
self.virtualenv_manager.install_pip_requirements(test['requirements'], quiet=True)
output = []
def _log(line):