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

Side by Side Diff: scripts/slave/chromium/archive_layout_test_results.py

Issue 2429573002: Also archive diff files in layout-test-results.zip. (Closed)
Patch Set: Rebase Created 4 years, 2 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 | scripts/slave/chromium/archive_layout_test_results_unittest.py » ('j') | 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """A tool to archive layout test results. 6 """A tool to archive layout test results.
7 7
8 To archive files on Google Storage, pass a GS bucket name via --gs-bucket. 8 To archive files on Google Storage, pass a GS bucket name via --gs-bucket.
9 To control access to archives, pass a value for --gs-acl (e.g. 'public-read', 9 To control access to archives, pass a value for --gs-acl (e.g. 'public-read',
10 see https://developers.google.com/storage/docs/accesscontrol#extension 10 see https://developers.google.com/storage/docs/accesscontrol#extension
(...skipping 17 matching lines...) Expand all
28 from common import archive_utils 28 from common import archive_utils
29 from common import chromium_utils 29 from common import chromium_utils
30 from slave import build_directory 30 from slave import build_directory
31 from slave import slave_utils 31 from slave import slave_utils
32 32
33 # Directory name, above the build directory, in which test results can be 33 # Directory name, above the build directory, in which test results can be
34 # found if no --results-dir option is given. 34 # found if no --results-dir option is given.
35 RESULT_DIR = 'layout-test-results' 35 RESULT_DIR = 'layout-test-results'
36 36
37 37
38 def _CollectArchiveFiles(output_dir): 38 def _CollectZipArchiveFiles(output_dir):
39 """Returns a list of actual layout test result files to archive.""" 39 """Returns a list of layout test result files to archive in a zip file."""
40 actual_file_list = [] 40 file_list = []
41 41
42 for path, _, files in os.walk(output_dir): 42 for path, _, files in os.walk(output_dir):
43 rel_path = path[len(output_dir + '\\'):] 43 rel_path = path[len(output_dir + '\\'):]
44 for name in files: 44 for name in files:
45 if _IsActualResultFile(name): 45 if _IsActualResultFile(name):
46 actual_file_list.append(os.path.join(rel_path, name)) 46 file_list.append(os.path.join(rel_path, name))
47 if _IsDiffFile(name):
48 diff_file_list.append(os.path.join(rel_path, name))
Dirk Pranke 2016/10/18 20:00:51 diff_file_list isn't declared or returned? Did you
qyearsley 2016/10/18 20:50:33 Right, that's what I meant -- now merged them and
47 elif name.endswith('.json'): 49 elif name.endswith('.json'):
48 actual_file_list.append(os.path.join(rel_path, name)) 50 file_list.append(os.path.join(rel_path, name))
49 51
50 if os.path.exists(os.path.join(output_dir, 'results.html')): 52 if os.path.exists(os.path.join(output_dir, 'results.html')):
51 actual_file_list.append('results.html') 53 file_list.append('results.html')
52 54
53 if sys.platform == 'win32': 55 if sys.platform == 'win32':
54 if os.path.exists(os.path.join(output_dir, 'access_log.txt')): 56 if os.path.exists(os.path.join(output_dir, 'access_log.txt')):
55 actual_file_list.append('access_log.txt') 57 file_list.append('access_log.txt')
56 if os.path.exists(os.path.join(output_dir, 'error_log.txt')): 58 if os.path.exists(os.path.join(output_dir, 'error_log.txt')):
57 actual_file_list.append('error_log.txt') 59 file_list.append('error_log.txt')
58 60
59 return actual_file_list 61 return file_list
60 62
61 63
62 def _IsActualResultFile(name): 64 def _IsActualResultFile(name):
63 if '-stack.' in name or '-crash-log.' in name: 65 if '-stack.' in name or '-crash-log.' in name:
64 return True 66 return True
65 extension = os.path.splitext(name)[1] 67 extension = os.path.splitext(name)[1]
66 return ('-actual.' in name and extension in 68 return ('-actual.' in name and extension in
67 ('.txt', '.png', '.checksum', '.wav')) 69 ('.txt', '.png', '.checksum', '.wav'))
68 70
69 71
72 def _IsDiffFile(name):
73 return ('-wdiff.' in name or
74 '-expected.' in name or
75 name.endswith('-diff.txt') or
76 name.endswith('-diff.png'))
77
78
70 def archive_layout(options): 79 def archive_layout(options):
71 chrome_dir = os.path.abspath(options.build_dir) 80 chrome_dir = os.path.abspath(options.build_dir)
72 results_dir_basename = os.path.basename(options.results_dir) 81 results_dir_basename = os.path.basename(options.results_dir)
73 if options.results_dir is not None: 82 if options.results_dir is not None:
74 options.results_dir = os.path.abspath(os.path.join(options.build_dir, 83 options.results_dir = os.path.abspath(os.path.join(options.build_dir,
75 options.results_dir)) 84 options.results_dir))
76 else: 85 else:
77 options.results_dir = chromium_utils.FindUpward(chrome_dir, RESULT_DIR) 86 options.results_dir = chromium_utils.FindUpward(chrome_dir, RESULT_DIR)
78 print 'Archiving results from %s' % options.results_dir 87 print 'Archiving results from %s' % options.results_dir
79 staging_dir = options.staging_dir or slave_utils.GetStagingDir(chrome_dir) 88 staging_dir = options.staging_dir or slave_utils.GetStagingDir(chrome_dir)
80 print 'Staging in %s' % staging_dir 89 print 'Staging in %s' % staging_dir
81 if not os.path.exists(staging_dir): 90 if not os.path.exists(staging_dir):
82 os.makedirs(staging_dir) 91 os.makedirs(staging_dir)
83 92
84 actual_file_list = _CollectArchiveFiles(options.results_dir) 93 file_list = _CollectZipArchiveFiles(options.results_dir)
85 zip_file = chromium_utils.MakeZip(staging_dir, 94 zip_file = chromium_utils.MakeZip(staging_dir,
86 results_dir_basename, 95 results_dir_basename,
87 actual_file_list, 96 file_list,
88 options.results_dir)[1] 97 options.results_dir)[1]
89 98
90 # Extract the build name of this slave (e.g., 'chrome-release') from its 99 # Extract the build name of this slave (e.g., 'chrome-release') from its
91 # configuration file if not provided as a param. 100 # configuration file if not provided as a param.
92 build_name = options.builder_name or slave_utils.SlaveBuildName(chrome_dir) 101 build_name = options.builder_name or slave_utils.SlaveBuildName(chrome_dir)
93 build_name = re.sub('[ .()]', '_', build_name) 102 build_name = re.sub('[ .()]', '_', build_name)
94 103
95 wc_dir = os.path.dirname(chrome_dir) 104 wc_dir = os.path.dirname(chrome_dir)
96 last_change = slave_utils.GetHashOrRevision(wc_dir) 105 last_change = slave_utils.GetHashOrRevision(wc_dir)
97 106
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 options = _ParseOptions() 187 options = _ParseOptions()
179 logging.basicConfig(level=logging.INFO, 188 logging.basicConfig(level=logging.INFO,
180 format='%(asctime)s %(filename)s:%(lineno)-3d' 189 format='%(asctime)s %(filename)s:%(lineno)-3d'
181 ' %(levelname)s %(message)s', 190 ' %(levelname)s %(message)s',
182 datefmt='%y%m%d %H:%M:%S') 191 datefmt='%y%m%d %H:%M:%S')
183 return archive_layout(options) 192 return archive_layout(options)
184 193
185 194
186 if '__main__' == __name__: 195 if '__main__' == __name__:
187 sys.exit(main()) 196 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/chromium/archive_layout_test_results_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698