Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: third_party/WebKit/Tools/Scripts/merge-layout-test-results

Issue 2862173002: webkitpy: Merge script fix windows directory removing. (Closed)
Patch Set: Output remaining contents. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2017 The Chromium Authors. All rights reserved. 3 # Copyright 2017 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 import argparse 7 import argparse
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
11 import shutil 11 import shutil
12 import sys 12 import sys
13 import tempfile 13 import tempfile
14 import time
14 15
15 from webkitpy.common.system.log_utils import configure_logging 16 from webkitpy.common.system.log_utils import configure_logging
16 from webkitpy.layout_tests import merge_results 17 from webkitpy.layout_tests import merge_results
17 18
18 # ------------------------------------------------------------------------ 19 # ------------------------------------------------------------------------
19 20
21 def rmtree(dirname):
22 # Attempt to remove a directory tree. We try multiple times as on Windows a
23 # process which is currently closing could still have a file open in the
24 # directory.
25 logging.info('Removing %s', dirname)
26 errors = []
27 def onerror(func, path, exc_info):
28 errors.append(path)
29 logging.exception('Failed at %s %s: %r', func, path, exc_info)
30
31 attempts = 0
32 while attempts < 5:
33 del errors[:]
34 shutil.rmtree(dirname, onerror=onerror)
35 if not errors:
36 break
37 attempts += 1
38 time.sleep(1)
39
40 # Check the path is gone.
41 if not os.path.exists(dirname):
42 return
43
44 logging.warning('Unable to remove %s', dirname)
45 for dirpath, dirnames, filenames in os.walk(dirname, onerror=onerror, topdow n=False):
46 for fname in filenames:
47 logging.warning('File %s still in output dir.', os.path.join(dirpath , fname))
48 for dname in dirnames:
49 logging.warning('Dir %s still in output dir.', os.path.join(dirpath, dname))
50
20 51
21 def main(argv): 52 def main(argv):
22 53
23 parser = argparse.ArgumentParser() 54 parser = argparse.ArgumentParser()
24 parser.description = """\ 55 parser.description = """\
25 Merges sharded layout test results into a single output directory. 56 Merges sharded layout test results into a single output directory.
26 """ 57 """
27 parser.epilog = """\ 58 parser.epilog = """\
28 59
29 If a post merge script is given, it will be run on the resulting merged output 60 If a post merge script is given, it will be run on the resulting merged output
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 except NameError: 182 except NameError:
152 results_json_value_overrides[k] = v 183 results_json_value_overrides[k] = v
153 logging.debug('results_json_value_overrides: %r', results_json_value_overrid es) 184 logging.debug('results_json_value_overrides: %r', results_json_value_overrid es)
154 185
155 merger = merge_results.LayoutTestDirMerger( 186 merger = merge_results.LayoutTestDirMerger(
156 results_json_value_overrides=results_json_value_overrides, 187 results_json_value_overrides=results_json_value_overrides,
157 results_json_allow_unknown_if_matching=args.results_json_allow_unknown_i f_matching) 188 results_json_allow_unknown_if_matching=args.results_json_allow_unknown_i f_matching)
158 if os.path.exists(args.output_directory): 189 if os.path.exists(args.output_directory):
159 logging.warning('Output directory exists %r', args.output_directory) 190 logging.warning('Output directory exists %r', args.output_directory)
160 if args.remove_existing_output_directory: 191 if args.remove_existing_output_directory:
161 shutil.rmtree(args.output_directory) 192 rmtree(args.output_directory)
162 elif not args.allow_existing_output_directory: 193 elif not args.allow_existing_output_directory:
163 raise IOError( 194 raise IOError(
164 ('Output directory %s exists!\n' 195 ('Output directory %s exists!\n'
165 'Use --allow-existing-output-directory to continue') % args.out put_directory) 196 'Use --allow-existing-output-directory to continue') % args.out put_directory)
166 197
167 merger.merge(args.output_directory, args.input_directories) 198 merger.merge(args.output_directory, args.input_directories)
168 199
169 merged_output_json = os.path.join(args.output_directory, 'output.json') 200 merged_output_json = os.path.join(args.output_directory, 'output.json')
170 if os.path.exists(merged_output_json) and args.output_json: 201 if os.path.exists(merged_output_json) and args.output_json:
171 logging.debug( 202 logging.debug(
172 'Copying output.json from %s to %s', merged_output_json, args.output _json) 203 'Copying output.json from %s to %s', merged_output_json, args.output _json)
173 shutil.copyfile(merged_output_json, args.output_json) 204 shutil.copyfile(merged_output_json, args.output_json)
174 205
175 if args.post_merge_script: 206 if args.post_merge_script:
176 logging.debug('Changing directory to %s', args.output_directory) 207 logging.debug('Changing directory to %s', args.output_directory)
177 os.chdir(args.output_directory) 208 os.chdir(args.output_directory)
178 209
179 post_script = list(args.post_merge_script) 210 post_script = list(args.post_merge_script)
180 post_script.append('--result-dir', args.output_directory) 211 post_script.append('--result-dir', args.output_directory)
181 212
182 logging.info('Running post merge script %r', post_script) 213 logging.info('Running post merge script %r', post_script)
183 os.execlp(post_script) 214 os.execlp(post_script)
184 215
185 main(sys.argv[1:]) 216 main(sys.argv[1:])
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698