Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --sdistonly behaviour #2775

Merged
merged 1 commit into from Dec 25, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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