Mercurial > public > mercurial-scm > hg
diff tests/run-tests.py @ 40989:e10adebf8176
merge with stable
author | Augie Fackler <augie@google.com> |
---|---|
date | Tue, 18 Dec 2018 10:21:25 -0500 |
parents | 08f5482a6755 bb5d74a35477 |
children | 8ddc5d8bea25 |
line wrap: on
line diff
--- a/tests/run-tests.py Mon Dec 17 15:05:52 2018 +0100 +++ b/tests/run-tests.py Tue Dec 18 10:21:25 2018 -0500 @@ -587,6 +587,17 @@ shutil.copy(src, dst) os.remove(src) +def makecleanable(path): + """Try to fix directory permission recursively so that the entire tree + can be deleted""" + for dirpath, dirnames, _filenames in os.walk(path, topdown=True): + for d in dirnames: + p = os.path.join(dirpath, d) + try: + os.chmod(p, os.stat(p).st_mode & 0o777 | 0o700) # chmod u+rwx + except OSError: + pass + _unified_diff = difflib.unified_diff if PYTHON3: import functools @@ -953,7 +964,13 @@ (self._testtmp.decode('utf-8'), self._threadtmp.decode('utf-8'))) else: - shutil.rmtree(self._testtmp, True) + try: + shutil.rmtree(self._testtmp) + except OSError: + # unreadable directory may be left in $TESTTMP; fix permission + # and try again + makecleanable(self._testtmp) + shutil.rmtree(self._testtmp, True) shutil.rmtree(self._threadtmp, True) if self._usechg: