| Index: tools/rebaseline.py
|
| ===================================================================
|
| --- tools/rebaseline.py (revision 9661)
|
| +++ tools/rebaseline.py (working copy)
|
| @@ -21,6 +21,9 @@
|
| import sys
|
| import urllib2
|
|
|
| +# Imports from local directory
|
| +import rebaseline_imagefiles
|
| +
|
| # Imports from within Skia
|
| #
|
| # We need to add the 'gm' directory, so that we can import gm_json.py within
|
| @@ -38,7 +41,6 @@
|
| sys.path.append(GM_DIRECTORY)
|
| import gm_json
|
|
|
| -
|
| # Mapping of gm-expectations subdir (under
|
| # https://skia.googlecode.com/svn/gm-expected/ )
|
| # to builder name (see list at http://108.170.217.252:10117/builders )
|
| @@ -71,14 +73,18 @@
|
| class CommandFailedException(Exception):
|
| pass
|
|
|
| -class Rebaseliner(object):
|
| +# Object that rebaselines a JSON expectations file (not individual image files).
|
| +#
|
| +# TODO(epoger): Most of this is just the code from the old ImageRebaseliner...
|
| +# some of it will need to be updated in order to properly rebaseline JSON files.
|
| +# There is a lot of code duplicated between here and ImageRebaseliner, but
|
| +# that's fine because we will delete ImageRebaseliner soon.
|
| +class JsonRebaseliner(object):
|
|
|
| # params:
|
| # 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 +94,22 @@
|
| # 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):
|
| + raise ValueError('JsonRebaseliner not yet implemented') # TODO(epoger)
|
| 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 +343,33 @@
|
| 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,
|
| + # within this gm-expectations subdir.
|
| + #
|
| + # params:
|
| + # subdir : e.g. 'base-shuttle-win7-intel-float'
|
| + # builder : e.g. 'Test-Win7-ShuttleA-HD2000-x86-Release'
|
| + def RebaselineSubdir(self, subdir, builder):
|
| + json_url = '/'.join([self._json_base_url,
|
| + subdir, builder, 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,
|
| + 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,
|
| + infilename=filename,
|
| + outfilename=outfilename,
|
| + all_results=all_results)
|
|
|
| # main...
|
|
|
| @@ -403,9 +406,31 @@
|
| '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:
|
| + if not subdir in SUBDIR_MAPPING.keys():
|
| + raise Exception(('unrecognized platform subdir "%s"; ' +
|
| + 'should be one of %s') % (
|
| + subdir, SUBDIR_MAPPING.keys()))
|
| + builder = SUBDIR_MAPPING[subdir]
|
| +
|
| + # 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 = rebaseline_imagefiles.ImageRebaseliner(
|
| + tests=args.tests, configs=args.configs,
|
| + 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, builder=builder)
|
|
|