signalpillar / tox-battery

Experiments with Tox plugin system
MIT License
33 stars 3 forks source link

Fix #10 custom naming of venv #12

Closed signalpillar closed 7 years ago

signalpillar commented 7 years ago

Problem

It is not supported reuse of venv between multiple testenvs. For instance::

[tox]
envlist = flake8, pylint, docs, unit

[testenv]
envdir = {toxworkdir}/env
deps =
    -rrequirements-test.txt
commands =
    flake8,lint,test: flake8
    pylint,lint,test: pylint
    docs: sphinx-build
    unit,test: pytest

In this case user set 'envdir' that makes all the registered testenvs share the same venv. In this case tox-bat will recreate same venv for each testenv as 'requirements-test.txt' file belongs to testenv not venv. In name of the .previous file we use testenv name and if file doesn't exist - environment needs to be recreated.

Solution

Change name of the .previous file to contain SHA1 of venv path used by testenv instead of its name. Normally when user doesn't change 'envdir' manually, each testenv has own venv and own .previous file. When user sets 'envdir' to be shared between some testenvs they will share the same .previous file.

Other changes

Small fix that sorts the parsed requirements and reshuffling or commenting doesn't cause recreating of the venv.

Testing

Added test for this particular case that checks venv is reused between two testenvs.

dgilland commented 7 years ago

:+1: