Chromium Code Reviews| Index: tools/rebaseline.py |
| =================================================================== |
| --- tools/rebaseline.py (revision 9661) |
| +++ tools/rebaseline.py (working copy) |
| @@ -77,8 +77,6 @@ |
| # json_base_url: base URL from which to read json_filename |
| # json_filename: filename (under json_base_url) from which to read a |
| # summary of results; typically "actual-results.json" |
| - # subdirs: which platform subdirectories to rebaseline; if not specified, |
| - # rebaseline all platform subdirectories |
| # tests: list of tests to rebaseline, or None if we should rebaseline |
| # whatever files the JSON results summary file tells us to |
| # configs: which configs to run for each test; this should only be |
| @@ -88,24 +86,21 @@ |
| # files to checkout, display a list of operations that |
| # we would normally perform |
| # add_new: if True, add expectations for tests which don't have any yet |
| + # missing_json_is_fatal: whether to halt execution if we cannot read a |
| + # JSON actual result summary file |
| def __init__(self, json_base_url, json_filename, |
| - subdirs=None, tests=None, configs=None, dry_run=False, |
| - add_new=False): |
| + tests=None, configs=None, dry_run=False, |
| + add_new=False, missing_json_is_fatal=False): |
| if configs and not tests: |
| raise ValueError('configs should only be specified if tests ' + |
| 'were specified also') |
| self._tests = tests |
| self._configs = configs |
| - if not subdirs: |
| - self._subdirs = sorted(SUBDIR_MAPPING.keys()) |
| - self._missing_json_is_fatal = False |
| - else: |
| - self._subdirs = subdirs |
| - self._missing_json_is_fatal = True |
| self._json_base_url = json_base_url |
| self._json_filename = json_filename |
| self._dry_run = dry_run |
| self._add_new = add_new |
| + self._missing_json_is_fatal = missing_json_is_fatal |
| self._googlestorage_gm_actuals_root = ( |
| 'http://chromium-skia-gm.commondatastorage.googleapis.com/gm') |
| self._testname_pattern = re.compile('(\S+)_(\S+).png') |
| @@ -339,34 +334,36 @@ |
| outfilename=outfilename, |
| all_results=all_results) |
| - # Rebaseline all platforms/tests/types we specified in the constructor. |
| - def RebaselineAll(self): |
| - for subdir in self._subdirs: |
| - if not subdir in SUBDIR_MAPPING.keys(): |
| - raise Exception(('unrecognized platform subdir "%s"; ' + |
| - 'should be one of %s') % ( |
| - subdir, SUBDIR_MAPPING.keys())) |
| - builder_name = SUBDIR_MAPPING[subdir] |
| - json_url = '/'.join([self._json_base_url, |
| - subdir, builder_name, subdir, |
| - self._json_filename]) |
| - all_results = self._GetActualResults(json_url=json_url) |
| + # Rebaseline all tests/types we specified in the constructor. |
| + # |
| + # params: |
| + # subdir : must be one of SUBDIR_MAPPING.keys() |
| + def RebaselineSubdir(self, subdir): |
| + if not subdir in SUBDIR_MAPPING.keys(): |
| + raise Exception(('unrecognized platform subdir "%s"; ' + |
| + 'should be one of %s') % ( |
| + subdir, SUBDIR_MAPPING.keys())) |
| + builder_name = SUBDIR_MAPPING[subdir] |
| + json_url = '/'.join([self._json_base_url, |
| + subdir, builder_name, subdir, |
| + self._json_filename]) |
| + all_results = self._GetActualResults(json_url=json_url) |
| - if self._tests: |
| - for test in self._tests: |
| - self._RebaselineOneTest(expectations_subdir=subdir, |
| - builder_name=builder_name, |
| - test=test, all_results=all_results) |
| - else: # get the raw list of files that need rebaselining from JSON |
| - filenames = self._GetFilesToRebaseline(json_url=json_url, |
| - add_new=self._add_new) |
| - for filename in filenames: |
| - outfilename = os.path.join(subdir, filename); |
| - self._RebaselineOneFile(expectations_subdir=subdir, |
| - builder_name=builder_name, |
| - infilename=filename, |
| - outfilename=outfilename, |
| - all_results=all_results) |
| + if self._tests: |
| + for test in self._tests: |
| + self._RebaselineOneTest(expectations_subdir=subdir, |
| + builder_name=builder_name, |
| + test=test, all_results=all_results) |
| + else: # get the raw list of files that need rebaselining from JSON |
| + filenames = self._GetFilesToRebaseline(json_url=json_url, |
| + add_new=self._add_new) |
| + for filename in filenames: |
| + outfilename = os.path.join(subdir, filename); |
| + self._RebaselineOneFile(expectations_subdir=subdir, |
| + builder_name=builder_name, |
| + infilename=filename, |
| + outfilename=outfilename, |
| + all_results=all_results) |
| # main... |
| @@ -403,9 +400,24 @@ |
| 'failing tests (according to the actual-results.json ' + |
| 'file) will be rebaselined.') |
| args = parser.parse_args() |
| -rebaseliner = Rebaseliner(tests=args.tests, configs=args.configs, |
| - subdirs=args.subdirs, dry_run=args.dry_run, |
| - json_base_url=args.json_base_url, |
| - json_filename=args.json_filename, |
| - add_new=args.add_new) |
| -rebaseliner.RebaselineAll() |
| +if args.subdirs: |
| + subdirs = args.subdirs |
| + missing_json_is_fatal = True |
| +else: |
| + subdirs = sorted(SUBDIR_MAPPING.keys()) |
| + missing_json_is_fatal = False |
| +for subdir in subdirs: |
| + # Soon, we will be instantiating different Rebaseliner objects depending |
| + # on whether we are rebaselining an expected-results.json file, or |
| + # individual image files. Different gm-expected subdirectories may move |
| + # from individual image files to JSON-format expectations at different |
| + # times, so we need to make this determination per subdirectory. |
| + # |
| + # See https://goto.google.com/ChecksumTransitionDetail |
| + rebaseliner = Rebaseliner(tests=args.tests, configs=args.configs, |
|
epoger
2013/06/18 17:27:40
Patchset 1 moves the subdir loop outside of the Re
|
| + dry_run=args.dry_run, |
| + json_base_url=args.json_base_url, |
| + json_filename=args.json_filename, |
| + add_new=args.add_new, |
| + missing_json_is_fatal=missing_json_is_fatal) |
| + rebaseliner.RebaselineSubdir(subdir=subdir) |