Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore labels when provisioning #2917

Merged
merged 2 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/changelog/2916.bugfix.rst
Original file line number Diff line number Diff line change
@@ -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`.
3 changes: 2 additions & 1 deletion src/tox/session/env_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,8 @@ def _mark_active(self) -> None:
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]):
gaborbernat marked this conversation as resolved.
Show resolved Hide resolved
for label in labels:
for env_name in self._state.conf.core["labels"].get(label, []):
self._defined_envs_[env_name].is_active = True
Expand Down
15 changes: 11 additions & 4 deletions tests/test_provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down