Skip to content
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 docs/changelog/2195.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Let tox run fail when all envs are skipped -- by :user:`jugmac00`.
6 changes: 4 additions & 2 deletions src/tox/session/cmd/run/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -155,6 +156,7 @@ def _print(color_: int, message: str) -> None:
_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
Expand Down
2 changes: 1 addition & 1 deletion tests/session/cmd/test_sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down