comparison 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
comparison
equal deleted inserted replaced
40985:4277e20cfec4 40989:e10adebf8176
585 for existing destination support. 585 for existing destination support.
586 """ 586 """
587 shutil.copy(src, dst) 587 shutil.copy(src, dst)
588 os.remove(src) 588 os.remove(src)
589 589
590 def makecleanable(path):
591 """Try to fix directory permission recursively so that the entire tree
592 can be deleted"""
593 for dirpath, dirnames, _filenames in os.walk(path, topdown=True):
594 for d in dirnames:
595 p = os.path.join(dirpath, d)
596 try:
597 os.chmod(p, os.stat(p).st_mode & 0o777 | 0o700) # chmod u+rwx
598 except OSError:
599 pass
600
590 _unified_diff = difflib.unified_diff 601 _unified_diff = difflib.unified_diff
591 if PYTHON3: 602 if PYTHON3:
592 import functools 603 import functools
593 _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) 604 _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff)
594 605
951 if self._keeptmpdir: 962 if self._keeptmpdir:
952 log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' % 963 log('\nKeeping testtmp dir: %s\nKeeping threadtmp dir: %s' %
953 (self._testtmp.decode('utf-8'), 964 (self._testtmp.decode('utf-8'),
954 self._threadtmp.decode('utf-8'))) 965 self._threadtmp.decode('utf-8')))
955 else: 966 else:
956 shutil.rmtree(self._testtmp, True) 967 try:
968 shutil.rmtree(self._testtmp)
969 except OSError:
970 # unreadable directory may be left in $TESTTMP; fix permission
971 # and try again
972 makecleanable(self._testtmp)
973 shutil.rmtree(self._testtmp, True)
957 shutil.rmtree(self._threadtmp, True) 974 shutil.rmtree(self._threadtmp, True)
958 975
959 if self._usechg: 976 if self._usechg:
960 # chgservers will stop automatically after they find the socket 977 # chgservers will stop automatically after they find the socket
961 # files are deleted 978 # files are deleted