-
-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use _TOX_PARALLEL_ENV environment variable to control the behav… (#1446)
...but keep the TOX_PARALLEL_ENV variable for others to consume. The problem with using environment variables to let tox know it's being run as a parallel worker is the following: Either you don't pass the environment variable, but the test frameworks and test suites are unaware that tox is running in parallel. This makes it hard for cases like pytest-django: #1139 Or you pass the environment variable, but it makes tox invoked within tox think it is a parallel worker even when it isn't. This makes it hard to test various tox plugins that invoke tox in their integration test suite: Fixes #1444 By introducing two variables we can use one ("private", _TOX_PARALLEL_ENV) to control the behavior of tox (and don't pass it) and another ("public", TOX_PARALLEL_ENV) to let the tests and test frameworks know tox is running in parallel (and pass it by default). The integration test is a tad complicated invoking subprocess.Popen instead of subprocess.run, to support Python 2.7 and 3.4.
- Loading branch information
1 parent
3980da7
commit 0a44dcc
Showing
9 changed files
with
85 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Fix nested tox execution in the parallel mode by separating the environment | ||
variable that let's tox know it is invoked in the parallel mode | ||
(``_TOX_PARALLEL_ENV``) from the variable that informs the tests that tox is | ||
running in parallel mode (``TOX_PARALLEL_ENV``). | ||
— by :user:`hroncok` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
def test_parallel_inception(initproj, cmd): | ||
initproj( | ||
"inception-1.2.3", | ||
filedefs={ | ||
# the outer config just has one env: graham | ||
"tox.ini": """ | ||
[tox] | ||
envlist = graham | ||
skipsdist = True | ||
[testenv] | ||
commands = | ||
python runner.py | ||
""", | ||
# the inner config has 3 different envs, 1 of them is graham | ||
"inner": { | ||
"tox.ini": """ | ||
[tox] | ||
envlist = graham,john,terry | ||
skipsdist = True | ||
[testenv] | ||
commands = | ||
python -c 'pass' | ||
""" | ||
}, | ||
# the outer test runs the inner tox and asserts all 3 envs were run | ||
"runner.py": """ | ||
import os | ||
import subprocess | ||
import sys | ||
os.chdir("inner") | ||
p = subprocess.Popen(("tox"), stdout=subprocess.PIPE, universal_newlines=True) | ||
stdout, _ = p.communicate() | ||
sys.stdout.write(stdout) | ||
assert "graham" in stdout | ||
assert "john" in stdout | ||
assert "terry" in stdout | ||
""", | ||
}, | ||
add_missing_setup_py=False, | ||
) | ||
|
||
result = cmd("-p", "all", "-o") | ||
result.assert_success() | ||
|
||
# 1 from the outer, 1 from the inner | ||
assert result.out.count("graham: commands succeeded") == 2 | ||
# those gentlemen are only inside | ||
assert result.out.count("john: commands succeeded") == 1 | ||
assert result.out.count("terry: commands succeeded") == 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters