mirror of
https://github.com/fedora-python/tox-current-env.git
synced 2025-01-27 07:06:14 +01:00
tox 4: Abort the --print* options when no tox config was found
That way, Fedora packages using `%pyproject_buildrequires -t` will fail to build when the upstream project does not use tox at all or when the tox configuration is missing.
This commit is contained in:
parent
94c7ff899d
commit
5c627ae1ee
@ -167,6 +167,9 @@ The plugin is available also for tox 4. Differences in behavior between tox 3 an
|
||||
- The plugin does not check the requested Python version nor the environment name.
|
||||
If you let it run for multiple environments they'll all use the same Python.
|
||||
- Deprecated ``--print-deps-only`` option is no longer available.
|
||||
- Unlike tox 3, tox 4 can normally run without any tox configuration.
|
||||
When tox 4 runs with ``--print-deps-to`` or ``--print-extras-to`` without a tox configuration, it will fail.
|
||||
This was deliberately done to make Fedora packages misusing this option fail to build.
|
||||
|
||||
Use an isolated environment
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -61,6 +61,11 @@ def tox_add_option(parser):
|
||||
@impl
|
||||
def tox_add_core_config(core_conf, state):
|
||||
opt = state.conf.options
|
||||
if (opt.print_deps_to or opt.print_extras_to) and not core_conf.loaders:
|
||||
raise RuntimeError(
|
||||
"--print-deps-to and/or --print-extras-to cannot be used without a tox config. "
|
||||
"Seeing this error indicates this project either does not use tox at all or the tox configuration is missing."
|
||||
)
|
||||
|
||||
if opt.current_env or opt.print_deps_to or opt.print_extras_to:
|
||||
# We do not want to install the main package.
|
||||
|
@ -430,3 +430,24 @@ def test_report_installed(projdir):
|
||||
assert result.returncode == 0
|
||||
assert "tox==" in result.stdout
|
||||
assert "pytest==" in result.stdout
|
||||
|
||||
|
||||
@pytest.mark.parametrize("toxenv", envs_from_tox_ini())
|
||||
def test_print_deps_without_config_fails(projdir, toxenv, print_deps_stdout_arg):
|
||||
tox_ini = projdir / "tox.ini"
|
||||
tox_ini.unlink()
|
||||
# note: tox will traverse the filesystem up to find a config,
|
||||
# so if this (or the next) test fails,
|
||||
# check if you don't have a stray tox.ini in /tmp
|
||||
result = tox("-e", toxenv, print_deps_stdout_arg, check=False)
|
||||
assert result.returncode > 0
|
||||
assert "tox configuration is missing" in result.stderr
|
||||
|
||||
|
||||
@pytest.mark.parametrize("toxenv", envs_from_tox_ini())
|
||||
def test_print_extras_without_config_fails(projdir, toxenv):
|
||||
tox_ini = projdir / "tox.ini"
|
||||
tox_ini.unlink()
|
||||
result = tox("-e", toxenv, "--print-extras-to=-", check=False)
|
||||
assert result.returncode > 0
|
||||
assert "tox configuration is missing" in result.stderr
|
||||
|
Loading…
Reference in New Issue
Block a user