| Index: third_party/WebKit/Tools/Scripts/merge-layout-test-results
|
| diff --git a/third_party/WebKit/Tools/Scripts/merge-layout-test-results b/third_party/WebKit/Tools/Scripts/merge-layout-test-results
|
| index e9e82238bfade48e7a64349aab3a5239e3f97e69..80a2d416930763cbdbb8cd7d8f6e312b872109c5 100755
|
| --- a/third_party/WebKit/Tools/Scripts/merge-layout-test-results
|
| +++ b/third_party/WebKit/Tools/Scripts/merge-layout-test-results
|
| @@ -11,12 +11,43 @@ import os
|
| import shutil
|
| import sys
|
| import tempfile
|
| +import time
|
|
|
| from webkitpy.common.system.log_utils import configure_logging
|
| from webkitpy.layout_tests import merge_results
|
|
|
| # ------------------------------------------------------------------------
|
|
|
| +def rmtree(dirname):
|
| + # Attempt to remove a directory tree. We try multiple times as on Windows a
|
| + # process which is currently closing could still have a file open in the
|
| + # directory.
|
| + logging.info('Removing %s', dirname)
|
| + errors = []
|
| + def onerror(func, path, exc_info):
|
| + errors.append(path)
|
| + logging.exception('Failed at %s %s: %r', func, path, exc_info)
|
| +
|
| + attempts = 0
|
| + while attempts < 5:
|
| + del errors[:]
|
| + shutil.rmtree(dirname, onerror=onerror)
|
| + if not errors:
|
| + break
|
| + attempts += 1
|
| + time.sleep(1)
|
| +
|
| + # Check the path is gone.
|
| + if not os.path.exists(dirname):
|
| + return
|
| +
|
| + logging.warning('Unable to remove %s', dirname)
|
| + for dirpath, dirnames, filenames in os.walk(dirname, onerror=onerror, topdown=False):
|
| + for fname in filenames:
|
| + logging.warning('File %s still in output dir.', os.path.join(dirpath, fname))
|
| + for dname in dirnames:
|
| + logging.warning('Dir %s still in output dir.', os.path.join(dirpath, dname))
|
| +
|
|
|
| def main(argv):
|
|
|
| @@ -158,7 +189,7 @@ directory. The script will be given the arguments plus
|
| if os.path.exists(args.output_directory):
|
| logging.warning('Output directory exists %r', args.output_directory)
|
| if args.remove_existing_output_directory:
|
| - shutil.rmtree(args.output_directory)
|
| + rmtree(args.output_directory)
|
| elif not args.allow_existing_output_directory:
|
| raise IOError(
|
| ('Output directory %s exists!\n'
|
|
|