Skip to content

Commit 7bbf89e

Browse files
Imply --parallel when --parallel-no-spinner is passed (#3159)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ddb006f commit 7bbf89e

File tree

5 files changed

+33
-5
lines changed

5 files changed

+33
-5
lines changed

docs/changelog/3158.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``--parallel-no-spinner`` flag now implies ``--parallel``

docs/user_guide.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ Parallel mode
394394
- ``auto`` to limit it to CPU count,
395395
- or pass an integer to set that limit.
396396
- Parallel mode displays a progress spinner while running tox environments in parallel, and reports outcome of these as
397-
soon as they have been completed with a human readable duration timing attached. This spinner can be disabled via the
398-
``--parallel-no-spinner`` flag.
397+
soon as they have been completed with a human readable duration timing attached. To run parallelly without the spinner,
398+
you can use the ``--parallel-no-spinner`` flag.
399399
- Parallel mode by default shows output only of failed environments and ones marked as :ref:`parallel_show_output`
400400
``=True``.
401401
- There's now a concept of dependency between environments (specified via :ref:`depends`), tox will re-order the

src/tox/session/cmd/legacy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def legacy(state: State) -> int:
110110
option.env = CliEnv(["py"])
111111
option.devenv_path = Path(option.devenv_path)
112112
return devenv(state)
113-
if option.parallel != 0: # only 0 means sequential
113+
if option.parallel_no_spinner is True or option.parallel != 0: # only 0 means sequential
114114
return run_parallel(state)
115115
return run_sequential(state)
116116

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def parallel_flags(
7474
"--parallel-no-spinner",
7575
action="store_true",
7676
dest="parallel_no_spinner",
77-
help="do not show the spinner",
77+
help="run tox environments in parallel, but don't show the spinner, implies --parallel",
7878
)
7979

8080

@@ -83,7 +83,7 @@ def run_parallel(state: State) -> int:
8383
option = state.conf.options
8484
return execute(
8585
state,
86-
max_workers=option.parallel,
86+
max_workers=None if option.parallel_no_spinner is True else option.parallel,
8787
has_spinner=option.parallel_no_spinner is False and option.parallel_live is False,
8888
live=option.parallel_live,
8989
)

tests/session/cmd/test_parallel.py

+27
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
from subprocess import PIPE, Popen
77
from time import sleep
88
from typing import TYPE_CHECKING
9+
from unittest import mock
910

1011
import pytest
1112

13+
from tox.session.cmd.run import parallel
1214
from tox.session.cmd.run.parallel import parse_num_processes
1315
from tox.tox_env.api import ToxEnv
1416
from tox.tox_env.errors import Fail
@@ -169,3 +171,28 @@ def test_parallel_requires_arg(tox_project: ToxProjectCreator) -> None:
169171
outcome = tox_project({"tox.ini": ""}).run("p", "-p", "-h")
170172
outcome.assert_failed()
171173
assert "argument -p/--parallel: expected one argument" in outcome.err
174+
175+
176+
def test_parallel_no_spinner(tox_project: ToxProjectCreator) -> None:
177+
"""Ensure passing `--parallel-no-spinner` implies `--parallel`."""
178+
with mock.patch.object(parallel, "execute") as mocked:
179+
tox_project({"tox.ini": ""}).run("p", "--parallel-no-spinner")
180+
181+
mocked.assert_called_once_with(
182+
mock.ANY,
183+
max_workers=None,
184+
has_spinner=False,
185+
live=False,
186+
)
187+
188+
189+
def test_parallel_no_spinner_legacy(tox_project: ToxProjectCreator) -> None:
190+
with mock.patch.object(parallel, "execute") as mocked:
191+
tox_project({"tox.ini": ""}).run("--parallel-no-spinner")
192+
193+
mocked.assert_called_once_with(
194+
mock.ANY,
195+
max_workers=None,
196+
has_spinner=False,
197+
live=False,
198+
)

0 commit comments

Comments
 (0)