From 2a84e2d0df18c10868088f2fdd49fc9341412a96 Mon Sep 17 00:00:00 2001 From: guahki <85439599+guahki@users.noreply.github.com> Date: Thu, 9 Sep 2021 08:46:25 +0200 Subject: [PATCH] Only respect ALL environments when not in parallel fixes #2167 --- docs/changelog/2167.bugfix.rst | 1 + src/tox/config/__init__.py | 7 ++++--- tests/unit/config/test_config_parallel.py | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 docs/changelog/2167.bugfix.rst diff --git a/docs/changelog/2167.bugfix.rst b/docs/changelog/2167.bugfix.rst new file mode 100644 index 000000000..1d2802471 --- /dev/null +++ b/docs/changelog/2167.bugfix.rst @@ -0,0 +1 @@ +Fixed handling of ``-e ALL`` in parallel mode by ignoring the ``ALL`` in subprocesses -- by :user:`guahki`. diff --git a/src/tox/config/__init__.py b/src/tox/config/__init__.py index 54dbf0bd9..b51c86339 100644 --- a/src/tox/config/__init__.py +++ b/src/tox/config/__init__.py @@ -1498,9 +1498,10 @@ def _getenvdata(self, reader, config): env_list = [] envlist_explicit = False - if (from_option and "ALL" in from_option) or ( - not from_option and from_environ and "ALL" in from_environ.split(",") - ): + if ( + (from_option and "ALL" in from_option) + or (not from_option and from_environ and "ALL" in from_environ.split(",")) + ) and PARALLEL_ENV_VAR_KEY_PRIVATE not in os.environ: all_envs = self._getallenvs(reader) else: candidates = ( diff --git a/tests/unit/config/test_config_parallel.py b/tests/unit/config/test_config_parallel.py index 0e42a2c59..f070ca806 100644 --- a/tests/unit/config/test_config_parallel.py +++ b/tests/unit/config/test_config_parallel.py @@ -1,5 +1,7 @@ import pytest +from tox.config.parallel import ENV_VAR_KEY_PRIVATE as PARALLEL_ENV_VAR_KEY_PRIVATE + def test_parallel_default(newconfig): config = newconfig([], "") @@ -70,3 +72,17 @@ def test_depends_factor(newconfig): """, ) assert config.envconfigs["py"].depends == ("py37-cov", "py37-no", "py36-cov", "py36-no") + + +def test_parallel_env_selection_with_ALL(newconfig, monkeypatch): + # Regression test for #2167 + inisource = """ + [tox] + envlist = py,lint + """ + monkeypatch.setenv(PARALLEL_ENV_VAR_KEY_PRIVATE, "py") + config = newconfig(["-eALL"], inisource) + assert config.envlist == ["py"] + monkeypatch.setenv(PARALLEL_ENV_VAR_KEY_PRIVATE, "lint") + config = newconfig(["-eALL"], inisource) + assert config.envlist == ["lint"]