senorblanco@chromium.org | 782f3b4 | 2012-10-29 18:06:26 +0000 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | ''' |
| 4 | Copyright 2012 Google Inc. |
| 5 | |
| 6 | Use of this source code is governed by a BSD-style license that can be |
| 7 | found in the LICENSE file. |
| 8 | ''' |
| 9 | |
| 10 | ''' |
senorblanco@chromium.org | 123a0b5 | 2012-11-29 21:50:34 +0000 | [diff] [blame] | 11 | Rebaselines the given GM tests, on all bots and all configurations. |
senorblanco@chromium.org | 782f3b4 | 2012-10-29 18:06:26 +0000 | [diff] [blame] | 12 | ''' |
| 13 | |
epoger@google.com | 99ba65a | 2013-06-05 15:43:37 +0000 | [diff] [blame] | 14 | # System-level imports |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 15 | import argparse |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 16 | import json |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 17 | import os |
epoger@google.com | e78d207 | 2013-06-12 17:44:14 +0000 | [diff] [blame] | 18 | import re |
epoger@google.com | 27e1c00 | 2013-07-24 15:38:39 +0000 | [diff] [blame] | 19 | import subprocess |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 20 | import sys |
epoger@google.com | 99ba65a | 2013-06-05 15:43:37 +0000 | [diff] [blame] | 21 | import urllib2 |
| 22 | |
| 23 | # Imports from within Skia |
| 24 | # |
epoger@google.com | dad5310 | 2013-06-12 14:25:30 +0000 | [diff] [blame] | 25 | # We need to add the 'gm' directory, so that we can import gm_json.py within |
| 26 | # that directory. That script allows us to parse the actual-results.json file |
| 27 | # written out by the GM tool. |
| 28 | # Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end* |
| 29 | # so any dirs that are already in the PYTHONPATH will be preferred. |
| 30 | # |
| 31 | # This assumes that the 'gm' directory has been checked out as a sibling of |
| 32 | # the 'tools' directory containing this script, which will be the case if |
| 33 | # 'trunk' was checked out as a single unit. |
epoger@google.com | 99ba65a | 2013-06-05 15:43:37 +0000 | [diff] [blame] | 34 | GM_DIRECTORY = os.path.realpath( |
| 35 | os.path.join(os.path.dirname(os.path.dirname(__file__)), 'gm')) |
| 36 | if GM_DIRECTORY not in sys.path: |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 37 | sys.path.append(GM_DIRECTORY) |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 38 | import buildbot_globals |
epoger@google.com | 99ba65a | 2013-06-05 15:43:37 +0000 | [diff] [blame] | 39 | import gm_json |
| 40 | |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 41 | MASTER_HOST_URL = 'http://%s:%s' % (buildbot_globals.Get('master_host'), |
| 42 | buildbot_globals.Get('external_port')) |
| 43 | ALL_BUILDERS = list(json.load(urllib2.urlopen( |
| 44 | MASTER_HOST_URL + '/json/builders'))) |
| 45 | TEST_BUILDERS = filter(lambda x: 'Trybot' not in x and 'Test' in x, |
| 46 | ALL_BUILDERS) |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 47 | |
epoger@google.com | 66ba9f9 | 2013-07-11 19:20:30 +0000 | [diff] [blame] | 48 | class _InternalException(Exception): |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 49 | pass |
epoger@google.com | db29a31 | 2013-06-04 14:58:47 +0000 | [diff] [blame] | 50 | |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 51 | # Object that handles exceptions, either raising them immediately or collecting |
| 52 | # them to display later on. |
| 53 | class ExceptionHandler(object): |
| 54 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 55 | # params: |
| 56 | # keep_going_on_failure: if False, report failures and quit right away; |
| 57 | # if True, collect failures until |
| 58 | # ReportAllFailures() is called |
| 59 | def __init__(self, keep_going_on_failure=False): |
| 60 | self._keep_going_on_failure = keep_going_on_failure |
| 61 | self._failures_encountered = [] |
| 62 | self._exiting = False |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 63 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 64 | # Exit the program with the given status value. |
| 65 | def _Exit(self, status=1): |
| 66 | self._exiting = True |
| 67 | sys.exit(status) |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 68 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 69 | # We have encountered an exception; either collect the info and keep going, |
| 70 | # or exit the program right away. |
| 71 | def RaiseExceptionOrContinue(self, e): |
| 72 | # If we are already quitting the program, propagate any exceptions |
| 73 | # so that the proper exit status will be communicated to the shell. |
| 74 | if self._exiting: |
| 75 | raise e |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 76 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 77 | if self._keep_going_on_failure: |
| 78 | print >> sys.stderr, 'WARNING: swallowing exception %s' % e |
| 79 | self._failures_encountered.append(e) |
| 80 | else: |
| 81 | print >> sys.stderr, e |
| 82 | print >> sys.stderr, ( |
| 83 | 'Halting at first exception; to keep going, re-run ' + |
| 84 | 'with the --keep-going-on-failure option set.') |
| 85 | self._Exit() |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 86 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 87 | def ReportAllFailures(self): |
| 88 | if self._failures_encountered: |
| 89 | print >> sys.stderr, ('Encountered %d failures (see above).' % |
| 90 | len(self._failures_encountered)) |
| 91 | self._Exit() |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 92 | |
| 93 | |
epoger@google.com | 99a8ec9 | 2013-06-19 18:56:59 +0000 | [diff] [blame] | 94 | # Object that rebaselines a JSON expectations file (not individual image files). |
epoger@google.com | 99a8ec9 | 2013-06-19 18:56:59 +0000 | [diff] [blame] | 95 | class JsonRebaseliner(object): |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 96 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 97 | # params: |
| 98 | # expectations_root: root directory of all expectations JSON files |
| 99 | # expectations_input_filename: filename (under expectations_root) of JSON |
| 100 | # expectations file to read; typically |
| 101 | # "expected-results.json" |
| 102 | # expectations_output_filename: filename (under expectations_root) to |
| 103 | # which updated expectations should be |
| 104 | # written; typically the same as |
| 105 | # expectations_input_filename, to overwrite |
| 106 | # the old content |
| 107 | # actuals_base_url: base URL from which to read actual-result JSON files |
| 108 | # actuals_filename: filename (under actuals_base_url) from which to read a |
| 109 | # summary of results; typically "actual-results.json" |
| 110 | # exception_handler: reference to rebaseline.ExceptionHandler object |
| 111 | # tests: list of tests to rebaseline, or None if we should rebaseline |
| 112 | # whatever files the JSON results summary file tells us to |
| 113 | # configs: which configs to run for each test, or None if we should |
| 114 | # rebaseline whatever configs the JSON results summary file tells |
| 115 | # us to |
| 116 | # add_new: if True, add expectations for tests which don't have any yet |
| 117 | def __init__(self, expectations_root, expectations_input_filename, |
| 118 | expectations_output_filename, actuals_base_url, |
| 119 | actuals_filename, exception_handler, |
| 120 | tests=None, configs=None, add_new=False): |
| 121 | self._expectations_root = expectations_root |
| 122 | self._expectations_input_filename = expectations_input_filename |
| 123 | self._expectations_output_filename = expectations_output_filename |
| 124 | self._tests = tests |
| 125 | self._configs = configs |
| 126 | self._actuals_base_url = actuals_base_url |
| 127 | self._actuals_filename = actuals_filename |
| 128 | self._exception_handler = exception_handler |
| 129 | self._add_new = add_new |
| 130 | self._image_filename_re = re.compile(gm_json.IMAGE_FILENAME_PATTERN) |
| 131 | self._using_svn = os.path.isdir(os.path.join(expectations_root, '.svn')) |
epoger@google.com | 27e1c00 | 2013-07-24 15:38:39 +0000 | [diff] [blame] | 132 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 133 | # Executes subprocess.call(cmd). |
| 134 | # Raises an Exception if the command fails. |
| 135 | def _Call(self, cmd): |
| 136 | if subprocess.call(cmd) != 0: |
| 137 | raise _InternalException('error running command: ' + ' '.join(cmd)) |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 138 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 139 | # Returns the full contents of filepath, as a single string. |
| 140 | # If filepath looks like a URL, try to read it that way instead of as |
| 141 | # a path on local storage. |
| 142 | # |
| 143 | # Raises _InternalException if there is a problem. |
| 144 | def _GetFileContents(self, filepath): |
| 145 | if filepath.startswith('http:') or filepath.startswith('https:'): |
| 146 | try: |
| 147 | return urllib2.urlopen(filepath).read() |
| 148 | except urllib2.HTTPError as e: |
| 149 | raise _InternalException('unable to read URL %s: %s' % ( |
| 150 | filepath, e)) |
| 151 | else: |
| 152 | return open(filepath, 'r').read() |
epoger@google.com | 99ba65a | 2013-06-05 15:43:37 +0000 | [diff] [blame] | 153 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 154 | # Returns a dictionary of actual results from actual-results.json file. |
| 155 | # |
| 156 | # The dictionary returned has this format: |
| 157 | # { |
| 158 | # u'imageblur_565.png': [u'bitmap-64bitMD5', 3359963596899141322], |
| 159 | # u'imageblur_8888.png': [u'bitmap-64bitMD5', 4217923806027861152], |
| 160 | # u'shadertext3_8888.png': [u'bitmap-64bitMD5', 3713708307125704716] |
| 161 | # } |
| 162 | # |
| 163 | # If the JSON actual result summary file cannot be loaded, logs a warning |
| 164 | # message and returns None. |
| 165 | # If the JSON actual result summary file can be loaded, but we have |
| 166 | # trouble parsing it, raises an Exception. |
| 167 | # |
| 168 | # params: |
| 169 | # json_url: URL pointing to a JSON actual result summary file |
| 170 | # sections: a list of section names to include in the results, e.g. |
| 171 | # [gm_json.JSONKEY_ACTUALRESULTS_FAILED, |
| 172 | # gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON] ; |
| 173 | # if None, then include ALL sections. |
| 174 | def _GetActualResults(self, json_url, sections=None): |
| 175 | try: |
| 176 | json_contents = self._GetFileContents(json_url) |
| 177 | except _InternalException: |
| 178 | print >> sys.stderr, ( |
| 179 | 'could not read json_url %s ; skipping this platform.' % |
| 180 | json_url) |
| 181 | return None |
| 182 | json_dict = gm_json.LoadFromString(json_contents) |
| 183 | results_to_return = {} |
| 184 | actual_results = json_dict[gm_json.JSONKEY_ACTUALRESULTS] |
| 185 | if not sections: |
| 186 | sections = actual_results.keys() |
| 187 | for section in sections: |
| 188 | section_results = actual_results[section] |
| 189 | if section_results: |
| 190 | results_to_return.update(section_results) |
| 191 | return results_to_return |
epoger@google.com | e78d207 | 2013-06-12 17:44:14 +0000 | [diff] [blame] | 192 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 193 | # Rebaseline all tests/types we specified in the constructor, |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 194 | # within this builder's subdirectory in expectations/gm . |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 195 | # |
| 196 | # params: |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 197 | # builder : e.g. 'Test-Win7-ShuttleA-HD2000-x86-Release' |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 198 | def RebaselineSubdir(self, builder): |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 199 | # Read in the actual result summary, and extract all the tests whose |
| 200 | # results we need to update. |
| 201 | actuals_url = '/'.join([self._actuals_base_url, |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 202 | builder, self._actuals_filename]) |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 203 | # In most cases, we won't need to re-record results that are already |
| 204 | # succeeding, but including the SUCCEEDED results will allow us to |
| 205 | # re-record expectations if they somehow get out of sync. |
| 206 | sections = [gm_json.JSONKEY_ACTUALRESULTS_FAILED, |
| 207 | gm_json.JSONKEY_ACTUALRESULTS_SUCCEEDED] |
| 208 | if self._add_new: |
| 209 | sections.append(gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON) |
| 210 | results_to_update = self._GetActualResults(json_url=actuals_url, |
| 211 | sections=sections) |
epoger@google.com | e78d207 | 2013-06-12 17:44:14 +0000 | [diff] [blame] | 212 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 213 | # Read in current expectations. |
| 214 | expectations_input_filepath = os.path.join( |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 215 | self._expectations_root, builder, self._expectations_input_filename) |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 216 | expectations_dict = gm_json.LoadFromFile(expectations_input_filepath) |
| 217 | expected_results = expectations_dict[gm_json.JSONKEY_EXPECTEDRESULTS] |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 218 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 219 | # Update the expectations in memory, skipping any tests/configs that |
| 220 | # the caller asked to exclude. |
| 221 | skipped_images = [] |
| 222 | if results_to_update: |
| 223 | for (image_name, image_results) in results_to_update.iteritems(): |
| 224 | (test, config) = self._image_filename_re.match(image_name).groups() |
| 225 | if self._tests: |
| 226 | if test not in self._tests: |
| 227 | skipped_images.append(image_name) |
| 228 | continue |
| 229 | if self._configs: |
| 230 | if config not in self._configs: |
| 231 | skipped_images.append(image_name) |
| 232 | continue |
| 233 | if not expected_results.get(image_name): |
| 234 | expected_results[image_name] = {} |
| 235 | expected_results[image_name][gm_json.JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS] = \ |
epoger@google.com | 61822a2 | 2013-07-16 18:56:32 +0000 | [diff] [blame] | 236 | [image_results] |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 237 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 238 | # Write out updated expectations. |
| 239 | expectations_output_filepath = os.path.join( |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 240 | self._expectations_root, builder, self._expectations_output_filename) |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 241 | gm_json.WriteToFile(expectations_dict, expectations_output_filepath) |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 242 | |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 243 | # Mark the JSON file as plaintext, so text-style diffs can be applied. |
| 244 | # Fixes https://code.google.com/p/skia/issues/detail?id=1442 |
| 245 | if self._using_svn: |
| 246 | self._Call(['svn', 'propset', '--quiet', 'svn:mime-type', |
| 247 | 'text/x-json', expectations_output_filepath]) |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 248 | |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 249 | # main... |
epoger@google.com | ec3397b | 2013-05-29 17:09:43 +0000 | [diff] [blame] | 250 | |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 251 | parser = argparse.ArgumentParser() |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 252 | parser.add_argument('--actuals-base-url', |
| 253 | help='base URL from which to read files containing JSON ' + |
| 254 | 'summaries of actual GM results; defaults to %(default)s', |
| 255 | default='http://skia-autogen.googlecode.com/svn/gm-actual') |
| 256 | parser.add_argument('--actuals-filename', |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 257 | help='filename (within builder-specific subdirectories ' + |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 258 | 'of ACTUALS_BASE_URL) to read a summary of results from; ' + |
| 259 | 'defaults to %(default)s', |
| 260 | default='actual-results.json') |
| 261 | # TODO(epoger): Add test that exercises --add-new argument. |
epoger@google.com | dad5310 | 2013-06-12 14:25:30 +0000 | [diff] [blame] | 262 | parser.add_argument('--add-new', action='store_true', |
| 263 | help='in addition to the standard behavior of ' + |
| 264 | 'updating expectations for failing tests, add ' + |
| 265 | 'expectations for tests which don\'t have expectations ' + |
| 266 | 'yet.') |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 267 | parser.add_argument('--builders', metavar='BUILDER', nargs='+', |
| 268 | help='which platforms to rebaseline; ' + |
| 269 | 'if unspecified, rebaseline all platforms, same as ' + |
| 270 | '"--builders %s"' % ' '.join(sorted(TEST_BUILDERS))) |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 271 | # TODO(epoger): Add test that exercises --configs argument. |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 272 | parser.add_argument('--configs', metavar='CONFIG', nargs='+', |
| 273 | help='which configurations to rebaseline, e.g. ' + |
epoger@google.com | 9de25e3 | 2013-07-10 15:27:18 +0000 | [diff] [blame] | 274 | '"--configs 565 8888", as a filter over the full set of ' + |
| 275 | 'results in ACTUALS_FILENAME; if unspecified, rebaseline ' + |
| 276 | '*all* configs that are available.') |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 277 | parser.add_argument('--expectations-filename', |
| 278 | help='filename (under EXPECTATIONS_ROOT) to read ' + |
| 279 | 'current expectations from, and to write new ' + |
epoger@google.com | c60e745 | 2013-07-24 19:36:51 +0000 | [diff] [blame] | 280 | 'expectations into (unless a separate ' + |
| 281 | 'EXPECTATIONS_FILENAME_OUTPUT has been specified); ' + |
| 282 | 'defaults to %(default)s', |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 283 | default='expected-results.json') |
epoger@google.com | c60e745 | 2013-07-24 19:36:51 +0000 | [diff] [blame] | 284 | parser.add_argument('--expectations-filename-output', |
| 285 | help='filename (under EXPECTATIONS_ROOT) to write ' + |
| 286 | 'updated expectations into; by default, overwrites the ' + |
| 287 | 'input file (EXPECTATIONS_FILENAME)', |
| 288 | default='') |
epoger@google.com | 99a8ec9 | 2013-06-19 18:56:59 +0000 | [diff] [blame] | 289 | parser.add_argument('--expectations-root', |
| 290 | help='root of expectations directory to update-- should ' + |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 291 | 'contain one or more builder subdirectories. Defaults to ' + |
epoger@google.com | 99a8ec9 | 2013-06-19 18:56:59 +0000 | [diff] [blame] | 292 | '%(default)s', |
epoger@google.com | e94a7d2 | 2013-07-23 19:37:03 +0000 | [diff] [blame] | 293 | default=os.path.join('expectations', 'gm')) |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 294 | parser.add_argument('--keep-going-on-failure', action='store_true', |
| 295 | help='instead of halting at the first error encountered, ' + |
| 296 | 'keep going and rebaseline as many tests as possible, ' + |
| 297 | 'and then report the full set of errors at the end') |
epoger@google.com | a783f2b | 2013-07-08 17:51:58 +0000 | [diff] [blame] | 298 | # TODO(epoger): Add test that exercises --tests argument. |
epoger@google.com | 99ba65a | 2013-06-05 15:43:37 +0000 | [diff] [blame] | 299 | parser.add_argument('--tests', metavar='TEST', nargs='+', |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 300 | help='which tests to rebaseline, e.g. ' + |
epoger@google.com | 9de25e3 | 2013-07-10 15:27:18 +0000 | [diff] [blame] | 301 | '"--tests aaclip bigmatrix", as a filter over the full ' + |
| 302 | 'set of results in ACTUALS_FILENAME; if unspecified, ' + |
| 303 | 'rebaseline *all* tests that are available.') |
epoger@google.com | 9166bf5 | 2013-05-30 15:46:19 +0000 | [diff] [blame] | 304 | args = parser.parse_args() |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 305 | exception_handler = ExceptionHandler( |
| 306 | keep_going_on_failure=args.keep_going_on_failure) |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 307 | if args.builders: |
| 308 | builders = args.builders |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 309 | missing_json_is_fatal = True |
epoger@google.com | 99a8ec9 | 2013-06-19 18:56:59 +0000 | [diff] [blame] | 310 | else: |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 311 | builders = sorted(TEST_BUILDERS) |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 312 | missing_json_is_fatal = False |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 313 | for builder in builders: |
| 314 | if not builder in TEST_BUILDERS: |
| 315 | raise Exception(('unrecognized builder "%s"; ' + |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 316 | 'should be one of %s') % ( |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 317 | builder, TEST_BUILDERS)) |
epoger@google.com | 99a8ec9 | 2013-06-19 18:56:59 +0000 | [diff] [blame] | 318 | |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 319 | expectations_json_file = os.path.join(args.expectations_root, builder, |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 320 | args.expectations_filename) |
| 321 | if os.path.isfile(expectations_json_file): |
| 322 | rebaseliner = JsonRebaseliner( |
| 323 | expectations_root=args.expectations_root, |
| 324 | expectations_input_filename=args.expectations_filename, |
| 325 | expectations_output_filename=(args.expectations_filename_output or |
| 326 | args.expectations_filename), |
| 327 | tests=args.tests, configs=args.configs, |
| 328 | actuals_base_url=args.actuals_base_url, |
| 329 | actuals_filename=args.actuals_filename, |
| 330 | exception_handler=exception_handler, |
| 331 | add_new=args.add_new) |
epoger@google.com | 3e7399f | 2013-07-10 17:23:47 +0000 | [diff] [blame] | 332 | try: |
epoger@google.com | fd04011 | 2013-08-20 16:21:55 +0000 | [diff] [blame^] | 333 | rebaseliner.RebaselineSubdir(builder=builder) |
epoger@google.com | 3e7399f | 2013-07-10 17:23:47 +0000 | [diff] [blame] | 334 | except BaseException as e: |
epoger@google.com | 2a192a8 | 2013-08-02 20:54:46 +0000 | [diff] [blame] | 335 | exception_handler.RaiseExceptionOrContinue(e) |
| 336 | else: |
| 337 | exception_handler.RaiseExceptionOrContinue(_InternalException( |
| 338 | 'expectations_json_file %s not found' % expectations_json_file)) |
epoger@google.com | ffcbdbf | 2013-07-16 17:35:39 +0000 | [diff] [blame] | 339 | |
| 340 | exception_handler.ReportAllFailures() |