From 611c012fd25dab360582b0f20e5ec9522ea55bc3 Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Fri, 17 Nov 2023 00:43:22 +0530 Subject: [PATCH 1/9] Imply --parallel when --parallel-no-spinner passed --- docs/user_guide.rst | 4 ++-- src/tox/session/cmd/legacy.py | 2 +- src/tox/session/cmd/run/parallel.py | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/user_guide.rst b/docs/user_guide.rst index d08be62a8..3b2421ac7 100644 --- a/docs/user_guide.rst +++ b/docs/user_guide.rst @@ -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 paralelly 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 diff --git a/src/tox/session/cmd/legacy.py b/src/tox/session/cmd/legacy.py index 92a91fcf7..a78d8bac7 100644 --- a/src/tox/session/cmd/legacy.py +++ b/src/tox/session/cmd/legacy.py @@ -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) diff --git a/src/tox/session/cmd/run/parallel.py b/src/tox/session/cmd/run/parallel.py index 9b7e28434..f7109aff1 100644 --- a/src/tox/session/cmd/run/parallel.py +++ b/src/tox/session/cmd/run/parallel.py @@ -74,7 +74,8 @@ 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", ) @@ -83,7 +84,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, ) From b0a5288e00da279f5f393629cd36eeddda0771d0 Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Fri, 17 Nov 2023 00:46:09 +0530 Subject: [PATCH 2/9] pre-commit fixes --- docs/user_guide.rst | 2 +- src/tox/session/cmd/run/parallel.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/user_guide.rst b/docs/user_guide.rst index 3b2421ac7..73a475dfc 100644 --- a/docs/user_guide.rst +++ b/docs/user_guide.rst @@ -394,7 +394,7 @@ 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. To run paralelly without the spinner, + 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``. diff --git a/src/tox/session/cmd/run/parallel.py b/src/tox/session/cmd/run/parallel.py index f7109aff1..d02eb1f03 100644 --- a/src/tox/session/cmd/run/parallel.py +++ b/src/tox/session/cmd/run/parallel.py @@ -74,8 +74,7 @@ def parallel_flags( "--parallel-no-spinner", action="store_true", dest="parallel_no_spinner", - help="run tox environments in parallel, but don't show the spinner," - " implies --parallel", + help="run tox environments in parallel, but don't show the spinner, implies --parallel", ) From 799b6da90e663cf901c0fd05e47728d8f3526822 Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Fri, 17 Nov 2023 00:50:08 +0530 Subject: [PATCH 3/9] Add changelog entry --- docs/changelog/3158.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/changelog/3158.bugfix.rst diff --git a/docs/changelog/3158.bugfix.rst b/docs/changelog/3158.bugfix.rst new file mode 100644 index 000000000..2ac847987 --- /dev/null +++ b/docs/changelog/3158.bugfix.rst @@ -0,0 +1 @@ +``--parallel-no-spinner`` flag now implies ``--parallel`` \ No newline at end of file From 510d4cdba1f3fcd0d81d36942e3b33a73765bcc6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Nov 2023 19:20:39 +0000 Subject: [PATCH 4/9] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/changelog/3158.bugfix.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog/3158.bugfix.rst b/docs/changelog/3158.bugfix.rst index 2ac847987..e73912381 100644 --- a/docs/changelog/3158.bugfix.rst +++ b/docs/changelog/3158.bugfix.rst @@ -1 +1 @@ -``--parallel-no-spinner`` flag now implies ``--parallel`` \ No newline at end of file +``--parallel-no-spinner`` flag now implies ``--parallel`` From 9e560a205ec156fa3e222388ad100d8973be06bd Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Wed, 29 Nov 2023 02:00:12 +0530 Subject: [PATCH 5/9] Add test for parallel-no-spinner --- tests/session/cmd/test_parallel.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/session/cmd/test_parallel.py b/tests/session/cmd/test_parallel.py index 8ab93a787..61aa8f8d6 100644 --- a/tests/session/cmd/test_parallel.py +++ b/tests/session/cmd/test_parallel.py @@ -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 @@ -169,3 +171,27 @@ 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( + state=mock.ANY, + max_workers=None, + has_spinner=False, + live=False, + ) + + # Test legacy parser + with mock.patch.object(parallel, "execute") as mocked: + tox_project({"tox.ini": ""}).run("--parallel-no-spinner") + + mocked.assert_called_once_with( + state=mock.ANY, + max_workers=None, + has_spinner=False, + live=False, + ) From c08dfddf0cb7b6dd97d9eed9ae0878d984b11a62 Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Wed, 29 Nov 2023 02:08:11 +0530 Subject: [PATCH 6/9] fix mock test signature --- tests/session/cmd/test_parallel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/session/cmd/test_parallel.py b/tests/session/cmd/test_parallel.py index 61aa8f8d6..9c10bc198 100644 --- a/tests/session/cmd/test_parallel.py +++ b/tests/session/cmd/test_parallel.py @@ -179,7 +179,7 @@ def test_parallel_no_spinner(tox_project: ToxProjectCreator) -> None: tox_project({"tox.ini": ""}).run("p", "--parallel-no-spinner") mocked.assert_called_once_with( - state=mock.ANY, + mock.ANY, max_workers=None, has_spinner=False, live=False, @@ -190,7 +190,7 @@ def test_parallel_no_spinner(tox_project: ToxProjectCreator) -> None: tox_project({"tox.ini": ""}).run("--parallel-no-spinner") mocked.assert_called_once_with( - state=mock.ANY, + mock.ANY, max_workers=None, has_spinner=False, live=False, From 18a4f4c7916ff9922fd3d64be28e43c6c4b4b770 Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Wed, 29 Nov 2023 02:13:54 +0530 Subject: [PATCH 7/9] Separate legacy parser into its own test --- tests/session/cmd/test_parallel.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/session/cmd/test_parallel.py b/tests/session/cmd/test_parallel.py index 9c10bc198..a546a263a 100644 --- a/tests/session/cmd/test_parallel.py +++ b/tests/session/cmd/test_parallel.py @@ -185,7 +185,8 @@ def test_parallel_no_spinner(tox_project: ToxProjectCreator) -> None: live=False, ) - # Test legacy parser + +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") From cb8f71ab8538fb5ff00ff0c244bb0615fd054a08 Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Wed, 29 Nov 2023 02:21:43 +0530 Subject: [PATCH 8/9] undo unneeded change --- src/tox/session/cmd/legacy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tox/session/cmd/legacy.py b/src/tox/session/cmd/legacy.py index a78d8bac7..92a91fcf7 100644 --- a/src/tox/session/cmd/legacy.py +++ b/src/tox/session/cmd/legacy.py @@ -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_no_spinner is True or option.parallel != 0: # only 0 means sequential + if option.parallel != 0: # only 0 means sequential return run_parallel(state) return run_sequential(state) From 88b381f287684f98c643f91d93a07b2a0c06687b Mon Sep 17 00:00:00 2001 From: Tushar Sadhwani Date: Wed, 29 Nov 2023 02:33:17 +0530 Subject: [PATCH 9/9] Revert "undo unneeded change" This reverts commit cb8f71ab8538fb5ff00ff0c244bb0615fd054a08. --- src/tox/session/cmd/legacy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tox/session/cmd/legacy.py b/src/tox/session/cmd/legacy.py index 92a91fcf7..a78d8bac7 100644 --- a/src/tox/session/cmd/legacy.py +++ b/src/tox/session/cmd/legacy.py @@ -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)