summaryrefslogtreecommitdiff
path: root/src/tox
diff options
context:
space:
mode:
authorJürgen Gmach <juergen.gmach@googlemail.com>2021-03-20 18:45:28 +0100
committerGitHub <noreply@github.com>2021-03-20 17:45:28 +0000
commit813e62c384ee5ae6dfe500187cb52758d8479730 (patch)
tree82bc0f2a2963a70385f1f5370af2e7ef372bcdb2 /src/tox
parentec50a6f2ccdf83a070d0037d7e685aa3c843821e (diff)
downloadtox-git-813e62c384ee5ae6dfe500187cb52758d8479730.tar.gz
Show skipped envs in reports on platform mismatch (#1970)
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
Diffstat (limited to 'src/tox')
-rw-r--r--src/tox/provision.py7
-rw-r--r--src/tox/pytest.py2
-rw-r--r--src/tox/session/cmd/run/common.py6
-rw-r--r--src/tox/session/cmd/run/single.py2
-rw-r--r--src/tox/tox_env/api.py19
-rw-r--r--src/tox/tox_env/python/runner.py7
6 files changed, 26 insertions, 17 deletions
diff --git a/src/tox/provision.py b/src/tox/provision.py
index 9710a70e..ef06a813 100644
--- a/src/tox/provision.py
+++ b/src/tox/provision.py
@@ -14,7 +14,9 @@ from tox.config.loader.memory import MemoryLoader
from tox.config.sets import CoreConfigSet
from tox.execute.api import StdinSource
from tox.plugin.impl import impl
+from tox.report import HandledError
from tox.session.state import State
+from tox.tox_env.errors import Skip
from tox.tox_env.python.req_file import RequirementsFile
from tox.tox_env.python.runner import PythonRun
from tox.tox_env.python.virtual_env.package.api import PackageType
@@ -108,7 +110,10 @@ def run_provision(deps: List[Requirement], state: State) -> int: # noqa
env_python = tox_env.env_python()
logging.info("will run in a automatically provisioned python environment under %s", env_python)
recreate = state.options.no_recreate_provision is False if state.options.recreate else False
- tox_env.ensure_setup(recreate=recreate)
+ try:
+ tox_env.ensure_setup(recreate=recreate)
+ except Skip as exception:
+ raise HandledError(f"cannot provision tox environment {tox_env.conf['env_name']} because {exception}")
args: List[str] = [str(env_python), "-m", "tox"]
args.extend(state.args)
outcome = tox_env.execute(cmd=args, stdin=StdinSource.user_only(), show=True, run_id="provision")
diff --git a/src/tox/pytest.py b/src/tox/pytest.py
index 03c73750..29c98107 100644
--- a/src/tox/pytest.py
+++ b/src/tox/pytest.py
@@ -401,7 +401,7 @@ def pytest_configure(config: PyTestConfig) -> None:
config.addinivalue_line("markers", "plugin_test")
-@pytest.mark.trylast
+@pytest.mark.trylast()
def pytest_collection_modifyitems(config: PyTestConfig, items: List[Function]) -> None:
# do not require flags if called directly
if len(items) == 1: # pragma: no cover # hard to test
diff --git a/src/tox/session/cmd/run/common.py b/src/tox/session/cmd/run/common.py
index cf5b753d..4e28e848 100644
--- a/src/tox/session/cmd/run/common.py
+++ b/src/tox/session/cmd/run/common.py
@@ -179,9 +179,9 @@ def execute(state: State, max_workers: Optional[int], has_spinner: bool, live: b
results: List[ToxEnvRunResult] = []
future_to_env: Dict["Future[ToxEnvRunResult]", ToxEnv] = {}
to_run_list: List[str] = []
- for env in state.env_list(): # ensure envs can be constructed and are active
- if state.tox_env(env).active:
- to_run_list.append(env)
+ for env in state.env_list(): # ensure envs can be constructed
+ state.tox_env(env)
+ to_run_list.append(env)
previous, has_previous = None, False
try:
spinner = ToxSpinner(has_spinner, state, len(to_run_list))
diff --git a/src/tox/session/cmd/run/single.py b/src/tox/session/cmd/run/single.py
index 21a347e8..ba65d702 100644
--- a/src/tox/session/cmd/run/single.py
+++ b/src/tox/session/cmd/run/single.py
@@ -42,7 +42,7 @@ def _evaluate(tox_env: RunToxEnv, recreate: bool, no_test: bool) -> Tuple[bool,
tox_env.ensure_setup(recreate=recreate)
code, outcomes = run_commands(tox_env, no_test)
except Skip as exception:
- LOGGER.warning("skipped environment because %s", exception)
+ LOGGER.warning("skipped because %s", exception)
skipped = True
except ToxBackendFailed as exception:
LOGGER.error("%s", exception)
diff --git a/src/tox/tox_env/api.py b/src/tox/tox_env/api.py
index 5e6a999a..51e81d01 100644
--- a/src/tox/tox_env/api.py
+++ b/src/tox/tox_env/api.py
@@ -18,7 +18,7 @@ from tox.execute.api import Execute, ExecuteStatus, Outcome, StdinSource
from tox.execute.request import ExecuteRequest
from tox.journal import EnvJournal
from tox.report import OutErr, ToxHandler
-from tox.tox_env.errors import Recreate
+from tox.tox_env.errors import Recreate, Skip
from .info import Info
@@ -169,6 +169,7 @@ class ToxEnv(ABC):
self._handle_env_tmp_dir()
def ensure_setup(self, recreate: bool = False) -> None:
+ self.check_platform()
if self.setup_done is True:
return
if self.conf["recreate"]:
@@ -183,6 +184,14 @@ class ToxEnv(ABC):
self.setup()
self.setup_has_been_done()
+ def check_platform(self) -> None:
+ """skip env when platform does not match"""
+ platform_str: str = self.conf["platform"]
+ if platform_str:
+ match = re.fullmatch(platform_str, self.runs_on_platform)
+ if match is None:
+ raise Skip(f"platform {self.runs_on_platform} does not match {platform_str}")
+
def setup_has_been_done(self) -> None:
"""called when setup is done"""
@@ -348,13 +357,5 @@ class ToxEnv(ABC):
def runs_on_platform(self) -> str:
raise NotImplementedError
- @property
- def active(self) -> bool:
- platform_str: str = self.conf["platform"]
- if not platform_str:
- return True
- match = re.fullmatch(platform_str, self.runs_on_platform)
- return match is not None
-
_CWD = Path.cwd()
diff --git a/src/tox/tox_env/python/runner.py b/src/tox/tox_env/python/runner.py
index 2b2f3a7a..257e4761 100644
--- a/src/tox/tox_env/python/runner.py
+++ b/src/tox/tox_env/python/runner.py
@@ -10,7 +10,7 @@ from tox.config.cli.parser import Parsed
from tox.config.sets import CoreConfigSet, EnvConfigSet
from tox.journal import EnvJournal
from tox.report import ToxHandler
-from tox.tox_env.errors import Recreate
+from tox.tox_env.errors import Recreate, Skip
from tox.tox_env.package import PackageToxEnv
from ..runner import RunToxEnv
@@ -65,7 +65,10 @@ class PythonRun(Python, RunToxEnv, ABC):
if explicit_install_package is None:
# 1. install package dependencies
with package_env.display_context(suspend=self.has_display_suspended):
- package_deps = package_env.get_package_dependencies(self.conf)
+ try:
+ package_deps = package_env.get_package_dependencies(self.conf)
+ except Skip as exception:
+ raise Skip(f"{exception.args[0]} for package environment {package_env.conf['env_name']}")
self.cached_install([PythonDep(p) for p in package_deps], PythonRun.__name__, "package_deps")
# 2. install the package