Bug 1659539 - [python-test] Remove '--python' and stop using pipenv to manage virtualenvs r=ahal
Pipenv is heavy weight and overkill for the purposes it is being used. We'd like to remove it from the tree and |mach python-test| was one of the last remanining use cases. Remove the `--python` command-line argument as a result. Users who wish to run unit tests with Python 2 can do `MACH_PY2=1 ./mach python-test ...` or `python2 ./mach python-test ...`. Also update a few unit tests that would break otherwise in the presence of this change. There were a couple lines in the `setup.py` for `mozlog` that were problematic for tests and was resulting in errors due to the `mozlog` plugin being loaded by `pytest` more than once. We just delete those lines and bump up the major version number of the package to fix it. Differential Revision: https://phabricator.services.mozilla.com/D88296
This commit is contained in:
@@ -27,7 +27,6 @@ from manifestparser import filters as mpf
|
||||
from mozbuild.base import (
|
||||
MachCommandBase,
|
||||
)
|
||||
from mozbuild.virtualenv import VirtualenvManager
|
||||
|
||||
from mach.decorators import (
|
||||
CommandArgument,
|
||||
@@ -92,17 +91,12 @@ class MachCommands(MachCommandBase):
|
||||
python_unbuffered=False, # Leave input buffered.
|
||||
append_env=append_env)
|
||||
|
||||
@Command('python-test', category='testing',
|
||||
description='Run Python unit tests with an appropriate test runner.')
|
||||
@Command('python-test', category='testing', virtualenv_name='python-test',
|
||||
description='Run Python unit tests with pytest.')
|
||||
@CommandArgument('-v', '--verbose',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Verbose output.')
|
||||
@CommandArgument('--python',
|
||||
default='3',
|
||||
help='Version of Python for Pipenv to use. When given a '
|
||||
'Python version, Pipenv will automatically scan your '
|
||||
'system for a Python that matches that given version.')
|
||||
@CommandArgument('-j', '--jobs',
|
||||
default=None,
|
||||
type=int,
|
||||
@@ -142,12 +136,11 @@ class MachCommands(MachCommandBase):
|
||||
subsuite=None,
|
||||
verbose=False,
|
||||
jobs=None,
|
||||
python=None,
|
||||
exitfirst=False,
|
||||
extra=None,
|
||||
**kwargs):
|
||||
self._activate_test_virtualenvs(python)
|
||||
|
||||
self.activate_virtualenv()
|
||||
if test_objects is None:
|
||||
from moztest.resolve import TestResolver
|
||||
resolver = self._spawn(TestResolver)
|
||||
@@ -238,38 +231,6 @@ class MachCommands(MachCommandBase):
|
||||
'Return code from mach python-test: {return_code}')
|
||||
return return_code
|
||||
|
||||
def _activate_test_virtualenvs(self, python):
|
||||
"""Make sure the test suite virtualenvs are set up and activated.
|
||||
|
||||
Args:
|
||||
python: Optional python version string we want to run the suite with.
|
||||
See the `--python` argument to the `mach python-test` command.
|
||||
"""
|
||||
from mozbuild.pythonutil import find_python3_executable
|
||||
|
||||
default_manager = self.virtualenv_manager
|
||||
|
||||
# Grab the default virtualenv properties before we activate other virtualenvs.
|
||||
python = python or default_manager.python_path
|
||||
py3_root = default_manager.virtualenv_root + '_py3'
|
||||
|
||||
self.activate_pipenv(os.path.dirname(default_manager.virtualenv_root),
|
||||
pipfile=None, populate=True, python=python)
|
||||
|
||||
# If the current process is running under Python 2, the Python 3
|
||||
# virtualenv may not be set up yet. To avoid problems in tests
|
||||
# that implicitly depend on the Python 3 virtualenv we ensure the Python 3
|
||||
# virtualenv is up to date before the tests start.
|
||||
if not six.PY3:
|
||||
python3, version = find_python3_executable(min_version='3.5.0')
|
||||
py3_manager = VirtualenvManager(
|
||||
default_manager.topsrcdir,
|
||||
py3_root,
|
||||
default_manager.log_handle,
|
||||
default_manager.manifest_path,
|
||||
)
|
||||
py3_manager.ensure(python3)
|
||||
|
||||
def _run_python_test(self, test):
|
||||
from mozprocess import ProcessHandler
|
||||
|
||||
|
||||
Reference in New Issue
Block a user