OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
epoger
2013/06/11 16:15:33
Apologies for the "TBR" commit, but I have a numbe
| |
2 | 2 |
3 ''' | 3 ''' |
epoger
2013/06/11 16:15:33
Before this change:
$ python tools/rebaseline.py
| |
4 Copyright 2012 Google Inc. | 4 Copyright 2012 Google Inc. |
5 | 5 |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 ''' | 8 ''' |
9 | 9 |
10 ''' | 10 ''' |
11 Rebaselines the given GM tests, on all bots and all configurations. | 11 Rebaselines the given GM tests, on all bots and all configurations. |
12 Must be run from the gm-expected directory. If run from a git or SVN | 12 Must be run from the gm-expected directory. If run from a git or SVN |
13 checkout, the files will be added to the staging area for commit. | 13 checkout, the files will be added to the staging area for commit. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 # we would normally perform | 81 # we would normally perform |
82 def __init__(self, json_base_url, json_filename, | 82 def __init__(self, json_base_url, json_filename, |
83 subdirs=None, tests=None, configs=None, dry_run=False): | 83 subdirs=None, tests=None, configs=None, dry_run=False): |
84 if configs and not tests: | 84 if configs and not tests: |
85 raise ValueError('configs should only be specified if tests ' + | 85 raise ValueError('configs should only be specified if tests ' + |
86 'were specified also') | 86 'were specified also') |
87 self._tests = tests | 87 self._tests = tests |
88 self._configs = configs | 88 self._configs = configs |
89 if not subdirs: | 89 if not subdirs: |
90 self._subdirs = sorted(SUBDIR_MAPPING.keys()) | 90 self._subdirs = sorted(SUBDIR_MAPPING.keys()) |
91 self._missing_json_is_fatal = False | |
91 else: | 92 else: |
92 self._subdirs = subdirs | 93 self._subdirs = subdirs |
94 self._missing_json_is_fatal = True | |
epoger
2013/06/11 16:15:33
After this change, you still get an exception if t
| |
93 self._json_base_url = json_base_url | 95 self._json_base_url = json_base_url |
94 self._json_filename = json_filename | 96 self._json_filename = json_filename |
95 self._dry_run = dry_run | 97 self._dry_run = dry_run |
96 self._is_svn_checkout = ( | 98 self._is_svn_checkout = ( |
97 os.path.exists('.svn') or | 99 os.path.exists('.svn') or |
98 os.path.exists(os.path.join(os.pardir, '.svn'))) | 100 os.path.exists(os.path.join(os.pardir, '.svn'))) |
99 self._is_git_checkout = ( | 101 self._is_git_checkout = ( |
100 os.path.exists('.git') or | 102 os.path.exists('.git') or |
101 os.path.exists(os.path.join(os.pardir, '.git'))) | 103 os.path.exists(os.path.join(os.pardir, '.git'))) |
102 | 104 |
(...skipping 25 matching lines...) Expand all Loading... | |
128 # | 130 # |
129 # Unlike standard URL handling, we allow relative "file:" URLs; | 131 # Unlike standard URL handling, we allow relative "file:" URLs; |
130 # for example, "file:one/two" resolves to the file ./one/two | 132 # for example, "file:one/two" resolves to the file ./one/two |
131 # (relative to current working dir) | 133 # (relative to current working dir) |
132 def _GetContentsOfUrl(self, url): | 134 def _GetContentsOfUrl(self, url): |
133 file_prefix = 'file:' | 135 file_prefix = 'file:' |
134 if url.startswith(file_prefix): | 136 if url.startswith(file_prefix): |
135 filename = url[len(file_prefix):] | 137 filename = url[len(file_prefix):] |
136 return open(filename, 'r').read() | 138 return open(filename, 'r').read() |
137 else: | 139 else: |
138 return urllib2.urlopen(url).read() | 140 return urllib2.urlopen(url).read() |
Stephen White
2013/06/11 16:40:47
Oooh, I missed the change where we switched to pyt
| |
139 | 141 |
140 # Returns a list of files that require rebaselining. | 142 # Returns a list of files that require rebaselining. |
141 # | 143 # |
142 # Note that this returns a list of FILES, like this: | 144 # Note that this returns a list of FILES, like this: |
143 # ['imageblur_565.png', 'xfermodes_pdf.png'] | 145 # ['imageblur_565.png', 'xfermodes_pdf.png'] |
144 # rather than a list of TESTS, like this: | 146 # rather than a list of TESTS, like this: |
145 # ['imageblur', 'xfermodes'] | 147 # ['imageblur', 'xfermodes'] |
146 # | 148 # |
149 # If the JSON actual result summary file cannot be loaded, the behavior | |
150 # depends on self._missing_json_is_fatal: | |
151 # - if true: execution will halt with an exception | |
152 # - if false: we will log an error message but return an empty list so we | |
153 # go on to the next platform | |
154 # | |
147 # params: | 155 # params: |
148 # json_url: URL pointing to a JSON actual result summary file | 156 # json_url: URL pointing to a JSON actual result summary file |
149 # | 157 # |
150 # TODO(epoger): add a parameter indicating whether "no-comparison" | 158 # TODO(epoger): add a parameter indicating whether "no-comparison" |
151 # results (those for which we don't have any expectations yet) | 159 # results (those for which we don't have any expectations yet) |
152 # should be rebaselined. For now, we only return failed expectations. | 160 # should be rebaselined. For now, we only return failed expectations. |
153 def _GetFilesToRebaseline(self, json_url): | 161 def _GetFilesToRebaseline(self, json_url): |
154 print ('# Getting files to rebaseline from JSON summary URL %s ...' | 162 print ('# Getting files to rebaseline from JSON summary URL %s ...' |
155 % json_url) | 163 % json_url) |
156 json_contents = self._GetContentsOfUrl(json_url) | 164 try: |
165 json_contents = self._GetContentsOfUrl(json_url) | |
166 except urllib2.HTTPError: | |
167 message = 'unable to load JSON summary URL %s' % json_url | |
168 if self._missing_json_is_fatal: | |
169 raise ValueError(message) | |
170 else: | |
171 print '# %s' % message | |
172 return [] | |
173 | |
157 json_dict = gm_json.LoadFromString(json_contents) | 174 json_dict = gm_json.LoadFromString(json_contents) |
158 actual_results = json_dict[gm_json.JSONKEY_ACTUALRESULTS] | 175 actual_results = json_dict[gm_json.JSONKEY_ACTUALRESULTS] |
159 | 176 |
160 files_to_rebaseline = [] | 177 files_to_rebaseline = [] |
161 failed_results = actual_results[gm_json.JSONKEY_ACTUALRESULTS_FAILED] | 178 failed_results = actual_results[gm_json.JSONKEY_ACTUALRESULTS_FAILED] |
162 if failed_results: | 179 if failed_results: |
163 files_to_rebaseline.extend(failed_results.keys()) | 180 files_to_rebaseline.extend(failed_results.keys()) |
164 | 181 |
165 print '# ... found files_to_rebaseline %s' % files_to_rebaseline | 182 print '# ... found files_to_rebaseline %s' % files_to_rebaseline |
166 return files_to_rebaseline | 183 return files_to_rebaseline |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 help='which tests to rebaseline, e.g. ' + | 296 help='which tests to rebaseline, e.g. ' + |
280 '"--tests aaclip bigmatrix"; if unspecified, then all ' + | 297 '"--tests aaclip bigmatrix"; if unspecified, then all ' + |
281 'failing tests (according to the actual-results.json ' + | 298 'failing tests (according to the actual-results.json ' + |
282 'file) will be rebaselined.') | 299 'file) will be rebaselined.') |
283 args = parser.parse_args() | 300 args = parser.parse_args() |
284 rebaseliner = Rebaseliner(tests=args.tests, configs=args.configs, | 301 rebaseliner = Rebaseliner(tests=args.tests, configs=args.configs, |
285 subdirs=args.subdirs, dry_run=args.dry_run, | 302 subdirs=args.subdirs, dry_run=args.dry_run, |
286 json_base_url=args.json_base_url, | 303 json_base_url=args.json_base_url, |
287 json_filename=args.json_filename) | 304 json_filename=args.json_filename) |
288 rebaseliner.RebaselineAll() | 305 rebaseliner.RebaselineAll() |
OLD | NEW |