Skip to content

Add environment variable to disable parallel spinner for CI tools #1311

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

Merged
merged 3 commits into from
May 23, 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 @@ -60,6 +60,7 @@ Mikhail Kyshtymov
Monty Taylor
Morgan Fainberg
Nick Douma
Nick Prendergast
Oliver Bestwalter
Paweł Adamczak
Philip Thiem
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/1184.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +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`
1 change: 1 addition & 0 deletions src/tox/session/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ def show_help(config):
"passed into test command environments"
)
reporter.line("PY_COLORS: 0 disable colorized output, 1 enable (default)")
reporter.line("TOX_PARALLEL_NO_SPINNER: 1 disable spinner for CI, 0 enable (default)")
5 changes: 4 additions & 1 deletion src/tox/session/commands/run/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
def run_parallel(config, venv_dict):
"""here we'll just start parallel sub-processes"""
live_out = config.option.parallel_live
disable_spinner = bool(os.environ.get("TOX_PARALLEL_NO_SPINNER") == "1")
args = [sys.executable, MAIN_FILE] + config.args
try:
position = args.index("--")
Expand All @@ -25,7 +26,9 @@ def run_parallel(config, venv_dict):
semaphore = Semaphore(max_parallel)
finished = Event()

show_progress = not live_out and reporter.verbosity() > reporter.Verbosity.QUIET
show_progress = (
not disable_spinner and not live_out and reporter.verbosity() > reporter.Verbosity.QUIET
)

with Spinner(enabled=show_progress) as spinner:

Expand Down
11 changes: 11 additions & 0 deletions tests/unit/config/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,17 @@ def test_passenv_glob_from_global_env(self, newconfig, monkeypatch):
assert "A1" in env.passenv
assert "A2" in env.passenv

def test_no_spinner(self, newconfig, monkeypatch):
monkeypatch.setenv("TOX_PARALLEL_NO_SPINNER", "1")
config = newconfig(
"""
[testenv]
passenv = TOX_PARALLEL_NO_SPINNER
"""
)
env = config.envconfigs["python"]
assert "TOX_PARALLEL_NO_SPINNER" in env.passenv

def test_changedir_override(self, newconfig):
config = newconfig(
"""
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/session/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,28 @@ def test_parallel_show_output(cmd, initproj, monkeypatch):
assert "stderr env" not in result.out, result.output()
assert "stdout always" in result.out, result.output()
assert "stderr always" in result.out, result.output()


def test_parallel_no_spinner(cmd, initproj, monkeypatch):
monkeypatch.setenv(str("TOX_PARALLEL_NO_SPINNER"), str("1"))
initproj(
"pkg123-0.7",
filedefs={
"tox.ini": """
[tox]
envlist = a, b
isolated_build = true
[testenv]
commands=python -c "import sys; print(sys.executable)"
[testenv:b]
depends = a
""",
"pyproject.toml": """
[build-system]
requires = ["setuptools >= 35.0.2"]
build-backend = 'setuptools.build_meta'
""",
},
)
result = cmd("--parallel", "all")
result.assert_success()