Skip to content

Commit

Permalink
Fix --sdistonly behaviour (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
q0w committed Dec 25, 2022
1 parent b0c3cf6 commit a36ff9d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2653.bugfix.rst
@@ -0,0 +1 @@
Fix ``--sdistonly`` behaviour.
6 changes: 5 additions & 1 deletion src/tox/session/cmd/run/common.py
Expand Up @@ -299,7 +299,11 @@ def _queue_and_wait(

def _run(tox_env: RunToxEnv) -> ToxEnvRunResult:
spinner.add(tox_env.conf.name)
return run_one(tox_env, options.parsed.no_test, suspend_display=live is False)
return run_one(
tox_env,
options.parsed.no_test or options.parsed.package_only,
suspend_display=live is False,
)

try:
executor = ThreadPoolExecutor(max_workers=max_workers, thread_name_prefix="tox-driver")
Expand Down
3 changes: 2 additions & 1 deletion src/tox/tox_env/runner.py
Expand Up @@ -165,7 +165,8 @@ def _register_package_conf(self) -> bool:

def _setup_pkg(self) -> None:
self._packages = self._build_packages()
self._install(self._packages, RunToxEnv.__name__, "package")
if not self.options.package_only:
self._install(self._packages, RunToxEnv.__name__, "package")
self._handle_journal_package(self.journal, self._packages)

@staticmethod
Expand Down
27 changes: 27 additions & 0 deletions tests/tox_env/test_tox_env_runner.py
@@ -0,0 +1,27 @@
from pathlib import Path

from tox.pytest import ToxProjectCreator


def test_package_only(
tox_project: ToxProjectCreator,
demo_pkg_inline: Path,
) -> None:
ini = "[testenv]\ncommands = python -c 'print('foo')'"
proj = tox_project(
{"tox.ini": ini, "pyproject.toml": (demo_pkg_inline / "pyproject.toml").read_text()},
base=demo_pkg_inline,
)
execute_calls = proj.patch_execute(lambda r: 0 if "install" in r.run_id else None)
result = proj.run("r", "--sdistonly")
result.assert_success()

expected_calls = [
(".pkg", "_optional_hooks"),
(".pkg", "get_requires_for_build_sdist"),
(".pkg", "build_wheel"),
(".pkg", "build_sdist"),
(".pkg", "_exit"),
]
found_calls = [(i[0][0].conf.name, i[0][3].run_id) for i in execute_calls.call_args_list]
assert found_calls == expected_calls

0 comments on commit a36ff9d

Please sign in to comment.