Skip to content

Commit

Permalink
Imply --parallel when --parallel-no-spinner is passed (#3159)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
tusharsadhwani and pre-commit-ci[bot] committed Nov 29, 2023
1 parent ddb006f commit 7bbf89e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/changelog/3158.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``--parallel-no-spinner`` flag now implies ``--parallel``
4 changes: 2 additions & 2 deletions docs/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ Parallel mode
- ``auto`` to limit it to CPU count,
- or pass an integer to set that limit.
- Parallel mode displays a progress spinner while running tox environments in parallel, and reports outcome of these as
soon as they have been completed with a human readable duration timing attached. This spinner can be disabled via the
``--parallel-no-spinner`` flag.
soon as they have been completed with a human readable duration timing attached. To run parallelly without the spinner,
you can use the ``--parallel-no-spinner`` flag.
- Parallel mode by default shows output only of failed environments and ones marked as :ref:`parallel_show_output`
``=True``.
- There's now a concept of dependency between environments (specified via :ref:`depends`), tox will re-order the
Expand Down
2 changes: 1 addition & 1 deletion src/tox/session/cmd/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def legacy(state: State) -> int:
option.env = CliEnv(["py"])
option.devenv_path = Path(option.devenv_path)
return devenv(state)
if option.parallel != 0: # only 0 means sequential
if option.parallel_no_spinner is True or option.parallel != 0: # only 0 means sequential
return run_parallel(state)
return run_sequential(state)

Expand Down
4 changes: 2 additions & 2 deletions src/tox/session/cmd/run/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def parallel_flags(
"--parallel-no-spinner",
action="store_true",
dest="parallel_no_spinner",
help="do not show the spinner",
help="run tox environments in parallel, but don't show the spinner, implies --parallel",
)


Expand All @@ -83,7 +83,7 @@ def run_parallel(state: State) -> int:
option = state.conf.options
return execute(
state,
max_workers=option.parallel,
max_workers=None if option.parallel_no_spinner is True else option.parallel,
has_spinner=option.parallel_no_spinner is False and option.parallel_live is False,
live=option.parallel_live,
)
27 changes: 27 additions & 0 deletions tests/session/cmd/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
from subprocess import PIPE, Popen
from time import sleep
from typing import TYPE_CHECKING
from unittest import mock

import pytest

from tox.session.cmd.run import parallel
from tox.session.cmd.run.parallel import parse_num_processes
from tox.tox_env.api import ToxEnv
from tox.tox_env.errors import Fail
Expand Down Expand Up @@ -169,3 +171,28 @@ def test_parallel_requires_arg(tox_project: ToxProjectCreator) -> None:
outcome = tox_project({"tox.ini": ""}).run("p", "-p", "-h")
outcome.assert_failed()
assert "argument -p/--parallel: expected one argument" in outcome.err


def test_parallel_no_spinner(tox_project: ToxProjectCreator) -> None:
"""Ensure passing `--parallel-no-spinner` implies `--parallel`."""
with mock.patch.object(parallel, "execute") as mocked:
tox_project({"tox.ini": ""}).run("p", "--parallel-no-spinner")

mocked.assert_called_once_with(
mock.ANY,
max_workers=None,
has_spinner=False,
live=False,
)


def test_parallel_no_spinner_legacy(tox_project: ToxProjectCreator) -> None:
with mock.patch.object(parallel, "execute") as mocked:
tox_project({"tox.ini": ""}).run("--parallel-no-spinner")

mocked.assert_called_once_with(
mock.ANY,
max_workers=None,
has_spinner=False,
live=False,
)

0 comments on commit 7bbf89e

Please sign in to comment.