Skip to content

Commit c3da8e7

Browse files
zeroshiftgaborbernat
authored andcommitted
Add environment variable to disable parallel spinner for CI tools (#1311)
* Adding TOX_PARALLEL_NO_SPINNER to disable spinner for CI tools. * Adding unit tests for TOX_PARALLEL_NO_SPINNER env var. * Updating CONTRIBUTORS and changelog for TOX_PARALLEL_NO_SPINNER env var.
1 parent 643c2fd commit c3da8e7

File tree

6 files changed

+43
-1
lines changed

6 files changed

+43
-1
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Mikhail Kyshtymov
6060
Monty Taylor
6161
Morgan Fainberg
6262
Nick Douma
63+
Nick Prendergast
6364
Oliver Bestwalter
6465
Paweł Adamczak
6566
Philip Thiem

docs/changelog/1184.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adding ```TOX_PARALLEL_NO_SPINNER``` environment variable to disable the spinner in parallel mode for the purposes of clean output when using CI tools - by :user:`zeroshift`

src/tox/session/commands/help.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ def show_help(config):
1111
"passed into test command environments"
1212
)
1313
reporter.line("PY_COLORS: 0 disable colorized output, 1 enable (default)")
14+
reporter.line("TOX_PARALLEL_NO_SPINNER: 1 disable spinner for CI, 0 enable (default)")

src/tox/session/commands/run/parallel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
def run_parallel(config, venv_dict):
1414
"""here we'll just start parallel sub-processes"""
1515
live_out = config.option.parallel_live
16+
disable_spinner = bool(os.environ.get("TOX_PARALLEL_NO_SPINNER") == "1")
1617
args = [sys.executable, MAIN_FILE] + config.args
1718
try:
1819
position = args.index("--")
@@ -25,7 +26,9 @@ def run_parallel(config, venv_dict):
2526
semaphore = Semaphore(max_parallel)
2627
finished = Event()
2728

28-
show_progress = not live_out and reporter.verbosity() > reporter.Verbosity.QUIET
29+
show_progress = (
30+
not disable_spinner and not live_out and reporter.verbosity() > reporter.Verbosity.QUIET
31+
)
2932

3033
with Spinner(enabled=show_progress) as spinner:
3134

tests/unit/config/test_config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,17 @@ def test_passenv_glob_from_global_env(self, newconfig, monkeypatch):
11641164
assert "A1" in env.passenv
11651165
assert "A2" in env.passenv
11661166

1167+
def test_no_spinner(self, newconfig, monkeypatch):
1168+
monkeypatch.setenv("TOX_PARALLEL_NO_SPINNER", "1")
1169+
config = newconfig(
1170+
"""
1171+
[testenv]
1172+
passenv = TOX_PARALLEL_NO_SPINNER
1173+
"""
1174+
)
1175+
env = config.envconfigs["python"]
1176+
assert "TOX_PARALLEL_NO_SPINNER" in env.passenv
1177+
11671178
def test_changedir_override(self, newconfig):
11681179
config = newconfig(
11691180
"""

tests/unit/session/test_parallel.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,28 @@ def test_parallel_show_output(cmd, initproj, monkeypatch):
189189
assert "stderr env" not in result.out, result.output()
190190
assert "stdout always" in result.out, result.output()
191191
assert "stderr always" in result.out, result.output()
192+
193+
194+
def test_parallel_no_spinner(cmd, initproj, monkeypatch):
195+
monkeypatch.setenv(str("TOX_PARALLEL_NO_SPINNER"), str("1"))
196+
initproj(
197+
"pkg123-0.7",
198+
filedefs={
199+
"tox.ini": """
200+
[tox]
201+
envlist = a, b
202+
isolated_build = true
203+
[testenv]
204+
commands=python -c "import sys; print(sys.executable)"
205+
[testenv:b]
206+
depends = a
207+
""",
208+
"pyproject.toml": """
209+
[build-system]
210+
requires = ["setuptools >= 35.0.2"]
211+
build-backend = 'setuptools.build_meta'
212+
""",
213+
},
214+
)
215+
result = cmd("--parallel", "all")
216+
result.assert_success()

0 commit comments

Comments
 (0)