I have a tox.ini
with several envs, like this example:
[tox]
envlist =
py37,
py38,
py39,
lint-{foo,bar,baz}
...
For several of my users, only a subset of these is useful at a time, usually all the py3
ones or all the lint-
ones.
Is there a syntax such that instead of tox -e py37,py38,py39
, one can say "run all envs (a subset of what tox finds via tox -a
) matching py3
"?
Alternatively, is there a way to group the envs so that one can say "run the test
envs" or "run the cleanup
envs" without losing the ability to call tox
to run them all?
I can write a separate script to handle this, but I'm searching for a built-in way to match.
The closest to a built-in way to filter tox environments by name is the TOX_SKIP_ENV
environment variable, which tox uses as a pattern for re.match (see source) with each environment name, skipping those that match.
So, for example, to only run the lint-
prefixed environments, one could:
env TOX_SKIP_ENV='^(?!lint-)' tox
Or, to skip all envs with py
or bar
anywhere in the name...
env TOX_SKIP_ENV='.*?(py|bar)' tox
There is a (currently unmaintained) tox plugin, tox-tags, aiming to provide roughly the tagging/grouping functionality I was thinking of.