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

Inject TOX_PARALLEL_ENV environment variables #1139

Merged
merged 2 commits into from
Jan 15, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Mark Hirota
Matt Good
Matt Jeffery
Mattieu Agopian
Michael Manganiello
Mikhail Kyshtymov
Monty Taylor
Morgan Fainberg
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1139.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tox will inject the ``TOX_PARALLEL_ENV`` environment variable, set to the current running tox environment name, only when running in parallel mode.
1 change: 1 addition & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ tox will inject the following environment variables that you can use to test tha
- ``TOX_ENV_NAME`` is set to the current running tox environment name
- ``TOX_ENV_DIR`` is set to the current tox environments working dir.
- ``TOX_PACKAGE`` the packaging phases outcome path (useful to inspect and make assertion of the built package itself).
- ``TOX_PARALLEL_ENV`` is set to the current running tox environment name, only when running in parallel mode.

:note: this applies for all tox envs (isolated packaging too) and all external
commands called (e.g. install command - pip).
Expand Down
10 changes: 9 additions & 1 deletion src/tox/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,15 @@ def passenv(testenv_config, value):
# Flatten the list to deal with space-separated values.
value = list(itertools.chain.from_iterable([x.split(" ") for x in value]))

passenv = {"PATH", "PIP_INDEX_URL", "LANG", "LANGUAGE", "LD_LIBRARY_PATH", "TOX_WORK_DIR"}
passenv = {
"PATH",
"PIP_INDEX_URL",
"LANG",
"LANGUAGE",
"LD_LIBRARY_PATH",
"TOX_WORK_DIR",
str(PARALLEL_ENV_VAR_KEY),
}

# read in global passenv settings
p = os.environ.get("TOX_TESTENV_PASSENV", None)
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
is_section_substitution,
parseconfig,
)
from tox.config.parallel import ENV_VAR_KEY as PARALLEL_ENV_VAR_KEY
gaborbernat marked this conversation as resolved.
Show resolved Hide resolved
from tox.venv import VirtualEnv


Expand Down Expand Up @@ -1047,6 +1048,7 @@ def test_passenv_as_multiline_list(self, newconfig, monkeypatch, plat):
assert "LANG" in envconfig.passenv
assert "LANGUAGE" in envconfig.passenv
assert "LD_LIBRARY_PATH" in envconfig.passenv
assert PARALLEL_ENV_VAR_KEY in envconfig.passenv
assert "A123A" in envconfig.passenv
assert "A123B" in envconfig.passenv

Expand Down