| Index: tools/rebaseline_imagefiles.py
|
| ===================================================================
|
| --- tools/rebaseline_imagefiles.py (revision 9661)
|
| +++ tools/rebaseline_imagefiles.py (working copy)
|
| @@ -1,20 +1,24 @@
|
| #!/usr/bin/python
|
|
|
| '''
|
| -Copyright 2012 Google Inc.
|
| +Copyright 2013 Google Inc.
|
|
|
| Use of this source code is governed by a BSD-style license that can be
|
| found in the LICENSE file.
|
| '''
|
|
|
| '''
|
| -Rebaselines the given GM tests, on all bots and all configurations.
|
| -Must be run from the gm-expected directory. If run from a git or SVN
|
| -checkout, the files will be added to the staging area for commit.
|
| +Rebaselines GM test results as individual image files
|
| +(the "old way", before https://goto.google.com/ChecksumTransitionDetail ).
|
| +
|
| +Once we have switched our expectations to JSON form for all platforms,
|
| +we can delete this file.
|
| +
|
| +There is a lot of code duplicated between here and rebaseline.py, but
|
| +that's fine because we will delete this file soon.
|
| '''
|
|
|
| # System-level imports
|
| -import argparse
|
| import os
|
| import re
|
| import subprocess
|
| @@ -39,46 +43,16 @@
|
| 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 )
|
| -SUBDIR_MAPPING = {
|
| - 'base-shuttle-win7-intel-float':
|
| - 'Test-Win7-ShuttleA-HD2000-x86-Release',
|
| - 'base-shuttle-win7-intel-angle':
|
| - 'Test-Win7-ShuttleA-HD2000-x86-Release-ANGLE',
|
| - 'base-shuttle-win7-intel-directwrite':
|
| - 'Test-Win7-ShuttleA-HD2000-x86-Release-DirectWrite',
|
| - 'base-shuttle_ubuntu12_ati5770':
|
| - 'Test-Ubuntu12-ShuttleA-ATI5770-x86_64-Release',
|
| - 'base-macmini':
|
| - 'Test-Mac10.6-MacMini4.1-GeForce320M-x86-Release',
|
| - 'base-macmini-lion-float':
|
| - 'Test-Mac10.7-MacMini4.1-GeForce320M-x86-Release',
|
| - 'base-android-galaxy-nexus':
|
| - 'Test-Android-GalaxyNexus-SGX540-Arm7-Debug',
|
| - 'base-android-nexus-7':
|
| - 'Test-Android-Nexus7-Tegra3-Arm7-Release',
|
| - 'base-android-nexus-s':
|
| - 'Test-Android-NexusS-SGX540-Arm7-Release',
|
| - 'base-android-xoom':
|
| - 'Test-Android-Xoom-Tegra2-Arm7-Release',
|
| - 'base-android-nexus-10':
|
| - 'Test-Android-Nexus10-MaliT604-Arm7-Release',
|
| -}
|
| -
|
| -
|
| class CommandFailedException(Exception):
|
| pass
|
|
|
| -class Rebaseliner(object):
|
| +class ImageRebaseliner(object):
|
|
|
| # params:
|
| + # expectations_root: root directory of all expectations
|
| # 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 +62,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
|
| - def __init__(self, json_base_url, json_filename,
|
| - subdirs=None, tests=None, configs=None, dry_run=False,
|
| - add_new=False):
|
| + # missing_json_is_fatal: whether to halt execution if we cannot read a
|
| + # JSON actual result summary file
|
| + def __init__(self, expectations_root, json_base_url, json_filename,
|
| + 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._expectations_root = expectations_root
|
| 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')
|
| @@ -332,80 +304,38 @@
|
| print '# ' + expectations_subdir + ':'
|
| for config in configs:
|
| infilename = test + '_' + config + '.png'
|
| - outfilename = os.path.join(expectations_subdir, infilename);
|
| + outfilename = os.path.join(self._expectations_root,
|
| + expectations_subdir, infilename);
|
| self._RebaselineOneFile(expectations_subdir=expectations_subdir,
|
| builder_name=builder_name,
|
| infilename=infilename,
|
| 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)
|
| -
|
| -# main...
|
| -
|
| -parser = argparse.ArgumentParser()
|
| -parser.add_argument('--add-new', action='store_true',
|
| - help='in addition to the standard behavior of ' +
|
| - 'updating expectations for failing tests, add ' +
|
| - 'expectations for tests which don\'t have expectations ' +
|
| - 'yet.')
|
| -parser.add_argument('--configs', metavar='CONFIG', nargs='+',
|
| - help='which configurations to rebaseline, e.g. ' +
|
| - '"--configs 565 8888"; if unspecified, run a default ' +
|
| - 'set of configs. This should ONLY be specified if ' +
|
| - '--tests has also been specified.')
|
| -parser.add_argument('--dry-run', action='store_true',
|
| - help='instead of actually downloading files or adding ' +
|
| - 'files to checkout, display a list of operations that ' +
|
| - 'we would normally perform')
|
| -parser.add_argument('--json-base-url',
|
| - help='base URL from which to read JSON_FILENAME ' +
|
| - 'files; defaults to %(default)s',
|
| - default='http://skia-autogen.googlecode.com/svn/gm-actual')
|
| -parser.add_argument('--json-filename',
|
| - help='filename (under JSON_BASE_URL) to read a summary ' +
|
| - 'of results from; defaults to %(default)s',
|
| - default='actual-results.json')
|
| -parser.add_argument('--subdirs', metavar='SUBDIR', nargs='+',
|
| - help='which platform subdirectories to rebaseline; ' +
|
| - 'if unspecified, rebaseline all subdirs, same as ' +
|
| - '"--subdirs %s"' % ' '.join(sorted(SUBDIR_MAPPING.keys())))
|
| -parser.add_argument('--tests', metavar='TEST', nargs='+',
|
| - help='which tests to rebaseline, e.g. ' +
|
| - '"--tests aaclip bigmatrix"; if unspecified, then all ' +
|
| - '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 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)
|
|
|