Skip to content

Commit

Permalink
Create an empty envtmpdir before running the commands, instead of jus…
Browse files Browse the repository at this point in the history
…t clearing it if it already existed.

Fixes issue tox-dev#399.
  • Loading branch information
manueljacob committed Nov 7, 2016
1 parent 0de703c commit e305347
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_z_cmdline.py
Expand Up @@ -817,3 +817,30 @@ def verify_json_report_format(data, testenvs=True):
assert isinstance(pyinfo["version_info"], list)
assert pyinfo["version"]
assert pyinfo["executable"]


def test_envtmpdir(initproj, cmd):
initproj("foo", filedefs={
# This file first checks that envtmpdir is existent and empty. Then it
# creates an empty file in that directory. The tox command is run
# twice below, so this is to test whether the directory is cleared
# before the second run.
'check_empty_envtmpdir.py': '''if True:
import os
from sys import argv
envtmpdir = argv[1]
assert os.path.exists(envtmpdir)
assert os.listdir(envtmpdir) == []
open(os.path.join(envtmpdir, 'test'), 'w').close()
''',
'tox.ini': '''
[testenv]
commands=python check_empty_envtmpdir.py {envtmpdir}
'''
})

result = cmd.run("tox")
assert not result.ret

result = cmd.run("tox")
assert not result.ret
1 change: 1 addition & 0 deletions tox/venv.py
Expand Up @@ -327,6 +327,7 @@ def test(self, redirect=False):
with action:
self.status = 0
self.session.make_emptydir(self.envconfig.envtmpdir)
self.envconfig.envtmpdir.ensure(dir=1)
cwd = self.envconfig.changedir
env = self._getenv(testcommand=True)
# Display PYTHONHASHSEED to assist with reproducibility.
Expand Down

0 comments on commit e305347

Please sign in to comment.