Skip to content

Commit

Permalink
XXX: test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pv committed Jun 28, 2015
1 parent 626fe47 commit a38d41a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 35 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ install:
build: false

test_script:
- "%CMD_IN_ENV% python setup.py test -a --tb=native"
- "%CMD_IN_ENV% python setup.py test -a -ktest_presence"
67 changes: 33 additions & 34 deletions asv/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,38 +809,37 @@ def long_path_open(filename, *a, **kw):
return open(_long_path_prefix(filename), *a, **kw)

def long_path_rmtree(path, ignore_errors=False):
if ignore_errors:
onerror = None
path = _long_path_prefix(path)
if not ignore_errors and os.path.isdir(path):
_rm_rf(path)
else:
onerror = _remove_readonly

# File deletion can fail e.g. if some background process (file
# indexing service, etc.) opens the files in the meantime.
# Moreover, a successful return from os.unlink or os.rmdir
# only means that the file will be deleted after all handles
# have closed; it may still remain in directory listings etc.,
# but in a pending-deletion state (operations raise access
# denied).

try:
shutil.rmtree(_long_path_prefix(path),
ignore_errors=ignore_errors,
onerror=onerror)
except OSError as err:
if not ignore_errors and err.errno == 5 and os.path.isdir(path):
# Try again with rd, which should use the appropriate
# Windows APIs for recursive deletion
check_call(['cmd', '/c', 'rd', '/s', '/q', path])
else:
raise

# Wait for the files to disappear
basename = os.path.basename(path)
dirname = _long_path_prefix(os.path.dirname(path))
if not ignore_errors and basename in os.listdir(dirname):
sleep_time = 0.05
for retry in range(5):
time.sleep(sleep_time)
sleep_time *= 2
if basename not in os.listdir(dirname):
break
shutil.rmtree(path, ignore_errors=ignore_errors)

# _rm_rf comes from conda/install.py

def _rm_rf(path, max_retries=5):
"""
Completely delete path
max_retries is the number of times to retry on failure. The default is
5. This only applies to deleting a directory.
"""
for i in range(max_retries):
try:
shutil.rmtree(path)
return
except OSError:
try:
shutil.rmtree(path, onerror=_remove_readonly)
return
except OSError:
pass

p = subprocess.Popen(['cmd', '/c', 'rd', '/s', '/q', path])
stdout, stderr = p.communicate()
if p.returncode == 0:
if not os.path.isdir(path):
return
time.sleep(i)

# Final time. pass exceptions to caller.
shutil.rmtree(path)
3 changes: 3 additions & 0 deletions test/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_presence_checks(tmpdir):
environments = list(environment.get_environments(conf))

for env in environments:
time.sleep(10)
env.create()

# Check env is recreated when info file is clobbered
Expand All @@ -107,6 +108,7 @@ def test_presence_checks(tmpdir):
data['python'] = '3.4'
data = util.write_json(info_fn, data)
env._is_setup = False
time.sleep(10)
env.create()
data = util.load_json(info_fn)
assert data['python'] == '2.7'
Expand All @@ -131,6 +133,7 @@ def test_presence_checks(tmpdir):
assert some_removed

env._is_setup = False
time.sleep(10)
env.create()
assert os.path.isfile(pip_fn)
env.run(['-c', 'import os'])

0 comments on commit a38d41a

Please sign in to comment.