diff options
author | Jürgen Gmach <juergen.gmach@googlemail.com> | 2021-09-10 10:00:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-10 09:00:15 +0100 |
commit | 6a4174e0aeef61511a1bde5f9c00c731d27c56fa (patch) | |
tree | b16f51a4bb95fa3508915cd2cd97e2142624a3f6 | |
parent | 8cdcc0639d6002cb34817bad8f7050f3dc66d35b (diff) | |
download | tox-git-6a4174e0aeef61511a1bde5f9c00c731d27c56fa.tar.gz |
Let tox run fail when all envs are skipped (#2206)
-rw-r--r-- | docs/changelog/2195.feature.rst | 1 | ||||
-rw-r--r-- | src/tox/session/cmd/run/common.py | 6 | ||||
-rw-r--r-- | tests/session/cmd/test_sequential.py | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/docs/changelog/2195.feature.rst b/docs/changelog/2195.feature.rst new file mode 100644 index 00000000..ae4d3f4c --- /dev/null +++ b/docs/changelog/2195.feature.rst @@ -0,0 +1 @@ +Let tox run fail when all envs are skipped -- by :user:`jugmac00`. diff --git a/src/tox/session/cmd/run/common.py b/src/tox/session/cmd/run/common.py index 857c59a7..7dd0a527 100644 --- a/src/tox/session/cmd/run/common.py +++ b/src/tox/session/cmd/run/common.py @@ -144,9 +144,10 @@ def report(start: float, runs: List[ToxEnvRunResult], is_colored: bool) -> int: def _print(color_: int, message: str) -> None: print(f"{color_ if is_colored else ''}{message}{Fore.RESET if is_colored else ''}") - all_good = True + successful, skipped = [], [] for run in runs: - all_good &= run.code == Outcome.OK or run.ignore_outcome + successful.append(run.code == Outcome.OK or run.ignore_outcome) + skipped.append(run.skipped) duration_individual = [o.elapsed for o in run.outcomes] extra = f"+cmd[{','.join(f'{i:.2f}' for i in duration_individual)}]" if duration_individual else "" setup = run.duration - sum(duration_individual) @@ -155,6 +156,7 @@ def report(start: float, runs: List[ToxEnvRunResult], is_colored: bool) -> int: _print(color, out) duration = time.monotonic() - start + all_good = all(successful) and not all(skipped) if all_good: _print(Fore.GREEN, f" congratulations :) ({duration:.2f} seconds)") return Outcome.OK diff --git a/tests/session/cmd/test_sequential.py b/tests/session/cmd/test_sequential.py index 35622b68..b358eecc 100644 --- a/tests/session/cmd/test_sequential.py +++ b/tests/session/cmd/test_sequential.py @@ -410,7 +410,7 @@ def test_platform_does_not_match_package_env(tox_project: ToxProjectCreator, dem ini = "[testenv]\npackage=wheel\n[testenv:.pkg]\nplatform=wrong_platform" proj = tox_project({"tox.ini": ini, "pyproject.toml": toml, "build.py": build}) result = proj.run("r", "-e", "a,b") - result.assert_success() + result.assert_failed() # tox run fails as all envs are skipped assert "a: SKIP" in result.out assert "b: SKIP" in result.out msg = f"skipped because platform {sys.platform} does not match wrong_platform for package environment .pkg" |