summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasen Furer <m_github@0x26.net>2023-02-07 18:18:25 -0800
committerGitHub <noreply@github.com>2023-02-07 18:18:25 -0800
commitc01bcf4d28e88673aed8706eff3ec7fbed1f63e4 (patch)
treede0b39374440c203061e6ddd33a16b7d89da3f6d
parentae523ef510ff309145bf692869d67bfd474787e7 (diff)
downloadtox-git-c01bcf4d28e88673aed8706eff3ec7fbed1f63e4.tar.gz
Ignore labels when provisioning (#2917)
Fix https://github.com/tox-dev/tox/issues/2916
-rw-r--r--docs/changelog/2916.bugfix.rst3
-rw-r--r--src/tox/session/env_select.py3
-rw-r--r--tests/test_provision.py15
3 files changed, 16 insertions, 5 deletions
diff --git a/docs/changelog/2916.bugfix.rst b/docs/changelog/2916.bugfix.rst
new file mode 100644
index 00000000..51858b2b
--- /dev/null
+++ b/docs/changelog/2916.bugfix.rst
@@ -0,0 +1,3 @@
+Ignore labels when tox will provision a runtime environment (``.tox``) so that environment configurations which depend
+on provisioned plugins or specific tox versions are not accessed in the outer tox process where the configuration would
+be invalid - by :user:`masenf`.
diff --git a/src/tox/session/env_select.py b/src/tox/session/env_select.py
index 52f11953..f091474d 100644
--- a/src/tox/session/env_select.py
+++ b/src/tox/session/env_select.py
@@ -315,7 +315,8 @@ class EnvSelector:
if labels or factors:
for env_info in self._defined_envs_.values():
env_info.is_active = False # if any was selected reset
- if labels:
+ # ignore labels when provisioning will occur
+ if labels and (self._provision is None or not self._provision[0]):
for label in labels:
for env_name in self._state.conf.core["labels"].get(label, []):
self._defined_envs_[env_name].is_active = True
diff --git a/tests/test_provision.py b/tests/test_provision.py
index 4a5bc1a2..290e48dc 100644
--- a/tests/test_provision.py
+++ b/tests/test_provision.py
@@ -195,14 +195,21 @@ def test_provision_no_recreate_json(tox_project: ToxProjectCreator) -> None:
def test_provision_plugin_runner(tox_project: ToxProjectCreator, tmp_path: Path, plugin_testenv: str) -> None:
"""Ensure that testenv runner doesn't affect the provision env."""
log = tmp_path / "out.log"
- proj = tox_project({"tox.ini": f"[tox]\nrequires=demo-pkg-inline\n[{plugin_testenv}]\nrunner=example"})
- result_first = proj.run("r", "-e", "py", "--result-json", str(log))
- result_first.assert_success()
+ proj = tox_project(
+ {"tox.ini": f"[tox]\nrequires=demo-pkg-inline\nlabels=l=py\n[{plugin_testenv}]\nrunner=example"},
+ )
prov_msg = (
f"ROOT: will run in automatically provisioned tox, host {sys.executable} is missing"
f" [requires (has)]: demo-pkg-inline"
)
- assert prov_msg in result_first.out
+
+ result_env = proj.run("r", "-e", "py", "--result-json", str(log))
+ result_env.assert_success()
+ assert prov_msg in result_env.out
+
+ result_label = proj.run("r", "-m", "l", "--result-json", str(log))
+ result_label.assert_success()
+ assert prov_msg in result_label.out
@pytest.mark.integration()