mirror of
https://github.com/fedora-python/tox-current-env.git
synced 2025-01-11 08:56:14 +01:00
Make --print-deps-only quite inert
This commit is contained in:
parent
9fec5a14a7
commit
ab18ab9088
@ -24,10 +24,8 @@ def tox_addoption(parser):
|
||||
|
||||
@tox.hookimpl
|
||||
def tox_configure(config):
|
||||
"""Stores options in the config. Makes all commands external"""
|
||||
if config.option.print_deps_only:
|
||||
config.skipsdist = True
|
||||
elif config.option.current_env:
|
||||
"""Stores options in the config. Makes all commands external and skips sdist"""
|
||||
if config.option.current_env or config.option.print_deps_only:
|
||||
config.skipsdist = True
|
||||
for testenv in config.envconfigs:
|
||||
config.envconfigs[testenv].whitelist_externals = "*"
|
||||
@ -43,7 +41,10 @@ class InterpreterMismatch(tox.exception.InterpreterNotFound):
|
||||
def tox_testenv_create(venv, action):
|
||||
"""We create a fake virtualenv with just the symbolic link"""
|
||||
config = venv.envconfig.config
|
||||
if config.option.current_env or config.option.print_deps_only:
|
||||
if config.option.print_deps_only:
|
||||
# We don't need anything
|
||||
return True
|
||||
if config.option.current_env:
|
||||
version_info = venv.envconfig.python_info.version_info
|
||||
if version_info[:2] != sys.version_info[:2]:
|
||||
raise InterpreterMismatch(
|
||||
@ -85,22 +86,17 @@ def is_proper_venv(venv):
|
||||
|
||||
|
||||
def unsupported_raise(config, venv):
|
||||
if not config.option.recreate:
|
||||
if not (
|
||||
config.option.current_env or config.option.print_deps_only
|
||||
) and is_current_env_link(venv):
|
||||
if config.option.recreate:
|
||||
return
|
||||
regular = not (config.option.current_env or config.option.print_deps_only)
|
||||
if regular and is_current_env_link(venv):
|
||||
raise tox.exception.ConfigError(
|
||||
"Regular tox run after --current-env or --print-deps-only tox run is not supported without --recreate (-r)."
|
||||
)
|
||||
elif is_proper_venv(venv):
|
||||
if config.option.current_env:
|
||||
elif config.option.current_env and is_proper_venv(venv):
|
||||
raise tox.exception.ConfigError(
|
||||
"--current-env after regular tox run is not supported without --recreate (-r)."
|
||||
)
|
||||
elif config.option.print_deps_only:
|
||||
raise tox.exception.ConfigError(
|
||||
"--print-deps-only after regular tox run is not supported without --recreate (-r)."
|
||||
)
|
||||
|
||||
|
||||
@tox.hookimpl
|
||||
@ -114,6 +110,7 @@ def tox_testenv_install_deps(venv, action):
|
||||
|
||||
@tox.hookimpl
|
||||
def tox_runtest(venv, redirect):
|
||||
"""If --print-deps-only, prints deps instead of running tests"""
|
||||
config = venv.envconfig.config
|
||||
unsupported_raise(config, venv)
|
||||
if config.option.print_deps_only:
|
||||
|
@ -3,6 +3,7 @@ import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
|
||||
@ -46,10 +47,39 @@ def test_all_toxenv_current_env_skip_missing():
|
||||
assert result.returncode == 0
|
||||
|
||||
|
||||
def test_native_toxenv_print_deps_only():
|
||||
result = tox("-e", NATIVE_TOXENV, "--print-deps-only")
|
||||
assert result.stdout.splitlines()[0] == "six"
|
||||
assert result.stdout.splitlines()[1] == "py"
|
||||
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38"])
|
||||
def test_print_deps_only(toxenv):
|
||||
result = tox("-e", toxenv, "--print-deps-only")
|
||||
expected = textwrap.dedent(
|
||||
f"""
|
||||
six
|
||||
py
|
||||
___________________________________ summary ____________________________________
|
||||
{toxenv}: commands succeeded
|
||||
congratulations :)
|
||||
"""
|
||||
).lstrip()
|
||||
assert result.stdout == expected
|
||||
|
||||
|
||||
def test_allenvs_print_deps_only():
|
||||
result = tox("--print-deps-only")
|
||||
expected = textwrap.dedent(
|
||||
"""
|
||||
six
|
||||
py
|
||||
six
|
||||
py
|
||||
six
|
||||
py
|
||||
___________________________________ summary ____________________________________
|
||||
py36: commands succeeded
|
||||
py37: commands succeeded
|
||||
py38: commands succeeded
|
||||
congratulations :)
|
||||
"""
|
||||
).lstrip()
|
||||
assert result.stdout == expected
|
||||
|
||||
|
||||
def test_regular_run():
|
||||
@ -82,11 +112,10 @@ def test_regular_recreate_after_current():
|
||||
assert "not supported" not in result.stderr
|
||||
|
||||
|
||||
@pytest.mark.parametrize("option", ["--current-env", "--print-deps-only"])
|
||||
def test_current_after_regular_is_not_supported(option):
|
||||
def test_current_after_regular_is_not_supported():
|
||||
result = tox("-e", NATIVE_TOXENV)
|
||||
assert f"/.tox/{NATIVE_TOXENV}/bin/python" in result.stdout
|
||||
result = tox("-e", NATIVE_TOXENV, option, prune=False, check=False)
|
||||
result = tox("-e", NATIVE_TOXENV, "--current-env", prune=False, check=False)
|
||||
assert result.returncode > 0
|
||||
assert "not supported" in result.stderr
|
||||
|
||||
@ -96,3 +125,28 @@ def test_current_recreate_after_regular():
|
||||
assert f"/.tox/{NATIVE_TOXENV}/bin/python" in result.stdout
|
||||
result = tox("-re", NATIVE_TOXENV, "--current-env", prune=False)
|
||||
assert result.stdout.splitlines()[0] == NATIVE_EXECUTABLE
|
||||
|
||||
|
||||
def test_current_after_deps_only():
|
||||
# this is quite fast, so we can do it several times
|
||||
first = True
|
||||
for _ in range(3):
|
||||
result = tox("-e", NATIVE_TOXENV, "--print-deps-only", prune=first)
|
||||
first = False
|
||||
assert "bin/python" not in result.stdout
|
||||
assert "six" in result.stdout
|
||||
result = tox("-re", NATIVE_TOXENV, "--current-env", prune=False)
|
||||
assert result.stdout.splitlines()[0] == NATIVE_EXECUTABLE
|
||||
|
||||
|
||||
def test_regular_after_deps_only():
|
||||
result = tox("-e", NATIVE_TOXENV, "--print-deps-only")
|
||||
assert "bin/python" not in result.stdout
|
||||
assert "six" in result.stdout
|
||||
|
||||
result = tox("-re", NATIVE_TOXENV, prune=False)
|
||||
assert result.stdout.splitlines()[0] != NATIVE_EXECUTABLE
|
||||
|
||||
result = tox("-e", NATIVE_TOXENV, "--print-deps-only", prune=False)
|
||||
assert "bin/python" not in result.stdout
|
||||
assert "six" in result.stdout
|
||||
|
Loading…
Reference in New Issue
Block a user