testrun crashes unnecessarily due to package / skipsdist handling
obestwalter opened this issue · comments
Oliver Bestwalter commented
The way this is handled currently is plain wrong. If any testenv is marked as direct via envname or testenv attribute and a non-direct testenv is invoked, this happens:
Traceback (most recent call last):
File "/home/ob/oss/tox-dev/tox-direct/.venv/bin/tox", line 8, in <module>
sys.exit(cmdline())
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/tox/session/__init__.py", line 44, in cmdline
main(args)
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/tox/session/__init__.py", line 69, in main
exit_code = session.runcommand()
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/tox/session/__init__.py", line 197, in runcommand
return self.subcommand_test()
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/tox/session/__init__.py", line 225, in subcommand_test
run_sequential(self.config, self.venv_dict)
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/tox/session/commands/run/sequential.py", line 9, in run_sequential
if venv.setupenv():
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/tox/venv.py", line 628, in setupenv
status = self.update(action=action)
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/tox/venv.py", line 270, in update
self.hook.tox_testenv_create(action=action, venv=self)
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/home/ob/oss/tox-dev/tox-direct/.venv/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/home/ob/oss/tox-dev/tox-direct/src/tox_direct/hookimpls.py", line 90, in tox_testenv_create
raise NormalEnvNeedsPackage(
tox_direct.hookimpls.NormalEnvNeedsPackage: NormalEnvNeedsPackage: [tox-direct] FATAL: tox env 'publish' needs a package.
Do not run this env as part of a direct run or run everything in the host (including package build) by running with --direct-yolo flag.
WARNING: this will change the host environment.
This happens only because the check if a testrun is direct looks at all testenvs instead of only the ones that are part of the current run.
It is also not necessary to crash at all, when skipsdist is handled more intelligently.
https://github.com/obestwalter/tox-direct/tree/refactor-and-make-less-dumb contains a sketch general improvements and a fix for this problem.