fix #4179 - bring back the current testrun symlink

This commit is contained in:
Ronny Pfannschmidt 2018-10-17 20:43:27 +02:00
parent 93bdbf7572
commit cc335d44a0
3 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1 @@
Restore the tmpdir behaviour of symlinking the current test run.

View File

@ -100,6 +100,26 @@ else:
_max = max
def _force_symlink(root, target, link_to):
"""helper to create the current symlink
its full of race conditions that are reasonably ok to ignore
for the contex of best effort linking to the latest testrun
the presumption being thatin case of much parallelism
the inaccuracy is going to be acceptable
"""
current_symlink = root.joinpath(target)
try:
current_symlink.unlink()
except OSError:
pass
try:
current_symlink.symlink_to(link_to)
except Exception:
pass
def make_numbered_dir(root, prefix):
"""create a directory with a increased number as suffix for the given prefix"""
for i in range(10):
@ -112,6 +132,7 @@ def make_numbered_dir(root, prefix):
except Exception:
pass
else:
_force_symlink(root, prefix + "current", new_path)
return new_path
else:
raise EnvironmentError(

View File

@ -196,6 +196,10 @@ class TestNumberedDir(object):
assert d.name.startswith(self.PREFIX)
assert d.name.endswith(str(i))
symlink = tmp_path.joinpath(self.PREFIX + "current")
assert symlink.is_symlink()
assert symlink.resolve() == d.resolve()
def test_cleanup_lock_create(self, tmp_path):
d = tmp_path.joinpath("test")
d.mkdir()