fix race condition as reported by Ralf Schmitt

This commit is contained in:
holger krekel
2011-04-14 21:35:27 +02:00
parent bd30e96ab0
commit d9c5f18478
3 changed files with 24 additions and 6 deletions

View File

@@ -14,11 +14,11 @@ class TestStatRecorder:
changed = sd.check()
assert changed
tmp.ensure("new.py")
p = tmp.ensure("new.py")
changed = sd.check()
assert changed
tmp.join("new.py").remove()
p.remove()
changed = sd.check()
assert changed
@@ -36,6 +36,24 @@ class TestStatRecorder:
changed = sd.check()
assert changed
def test_filechange_deletion_race(self, tmpdir, monkeypatch):
tmp = tmpdir
sd = StatRecorder([tmp])
changed = sd.check()
assert not changed
p = tmp.ensure("new.py")
changed = sd.check()
assert changed
p.remove()
# make check()'s visit() call return our just removed
# path as if we were in a race condition
monkeypatch.setattr(tmp, 'visit', lambda *args: [p])
changed = sd.check()
assert changed
def test_pycremoval(self, tmpdir):
tmp = tmpdir
hello = tmp.ensure("hello.py")