From 1610a685e0333c62646d0ee17e4371aedaecc64d Mon Sep 17 00:00:00 2001 From: "epoger@google.com" Date: Thu, 12 Apr 2012 18:02:25 +0000 Subject: Make download_baselines.py download *all* platforms, if none are specified. Simplifies the Skia rebaselining process... updated the --help pages in both scripts, too. BUG=http://code.google.com/p/skia/issues/detail?id=486 Review URL: https://codereview.appspot.com/6016045 git-svn-id: http://skia.googlecode.com/svn/trunk@3664 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/compare_baselines.py | 35 ++++++++++++++------ tools/download_baselines.py | 81 ++++++++++++++++++++++++++++++--------------- 2 files changed, 78 insertions(+), 38 deletions(-) (limited to 'tools') diff --git a/tools/compare_baselines.py b/tools/compare_baselines.py index 19614ce1ff..b16031fbde 100644 --- a/tools/compare_baselines.py +++ b/tools/compare_baselines.py @@ -21,20 +21,33 @@ import tempfile # modules declared within this same directory import svn -USAGE_STRING = '''usage: %s [options] +USAGE_STRING = 'Usage: %s [options]' +HOWTO_STRING = ''' +To update the checked-in baselines across all platforms, follow these steps: + +cd .../trunk +svn update +svn stat # and make sure there are no files awaiting svn commit +make tools BUILDTYPE=Release +python tools/download_baselines.py +python tools/compare_baselines.py +# view compare_baselines output in a browser and make sure it's reasonable +# upload CL for review +# validate that the diffs look right in the review tool +# commit CL + +Note that the above instructions will only *update* already-checked-in +baseline images; if you want to check in new baseline images (ones that the +bots have been generating but we don't have a golden master for yet), you need +to use download_baselines.py's --add-new-files option. +''' +HELP_STRING = ''' Compares the gm results within the local checkout against those already committed to the Skia repository. Relies on skdiff to do the low-level comparison. -for example: - -cd .../trunk -# modify local gm images, maybe by running download-baselines.py -make tools -python tools/compare-baselines.py -# validate that the image diffs look right -''' +''' + HOWTO_STRING TRUNK_PATH = os.path.join(os.path.dirname(__file__), os.pardir) @@ -162,7 +175,7 @@ def CompareBaselines(gm_basedir, path_to_skdiff, svn_gm_url): # allow user to specify a different directory to write into? def RaiseUsageException(): - raise Exception('%s\n\nRun with --help for more detail.' % ( + raise Exception('%s\nRun with --help for more detail.' % ( USAGE_STRING % __file__)) def Main(options, args): @@ -176,7 +189,7 @@ def Main(options, args): svn_gm_url=options.svn_gm_url) if __name__ == '__main__': - parser = optparse.OptionParser(USAGE_STRING % '%prog') + parser = optparse.OptionParser(USAGE_STRING % '%prog' + HELP_STRING) parser.add_option(OPTION_GM_BASEDIR, action='store', type='string', default=DEFAULT_GM_BASEDIR, help='path to root of locally stored baseline images ' diff --git a/tools/download_baselines.py b/tools/download_baselines.py index da67743a4c..59069e9322 100644 --- a/tools/download_baselines.py +++ b/tools/download_baselines.py @@ -2,19 +2,7 @@ Downloads the actual gm results most recently generated by the Skia buildbots, and adds any new ones to SVN control. -This tool makes it much easier to check in new baselines, via the following -steps: - -cd .../trunk -svn update -# make sure there are no files awaiting svn commit -python tools/download-baselines.py gm/base-macmini-lion-fixed # or other gm/ subdir -# validate that the new images look right (maybe using compare-baselines.py) -# upload CL for review -# validate that the new images look right in the review tool -# commit CL - -Launch with --help to see more options. +Launch with --help to see more information. Copyright 2011 Google Inc. @@ -33,12 +21,23 @@ import sys import tempfile # modules declared within this same directory +import compare_baselines import svn +USAGE_STRING = 'Usage: %s [options] [baseline_subdir]...' +HELP_STRING = ''' + +Downloads the actual gm results most recently generated by the Skia buildbots, +and adds any new ones to SVN control. + +If no baseline_subdir is given, then this tool will download the most-recently +generated actual gm results for ALL platforms. + +''' + compare_baselines.HOWTO_STRING + # Base URL of SVN repository where buildbots store actual gm image results. SVN_BASE_URL = 'http://skia-autogen.googlecode.com/svn/gm-actual' -USAGE_STRING = 'usage: %s [options] ' OPTION_IGNORE_LOCAL_MODS = '--ignore-local-mods' OPTION_ADD_NEW_FILES = '--add-new-files' @@ -76,21 +75,13 @@ def CopyMatchingFiles(source_dir, dest_dir, filename_pattern, continue shutil.copyfile(source_path, dest_path) -def Main(options, args): - """Download most recently generated baseline images for a given platform, +def DownloadBaselinesForOnePlatform(baseline_subdir): + """Download most recently generated baseline images for a single platform, and add any new ones to SVN control. - @param options - @param args + @param baseline_subdir """ - num_args = len(args) - if num_args != 1: - RaiseUsageException() - # Create repo_to_modify to handle the SVN repository we will add files to. - baseline_subdir = args[0].rstrip(os.sep); - if not os.path.isdir(baseline_subdir): - raise Exception('could not find baseline_subdir "%s"' % baseline_subdir) repo_to_modify = svn.Svn(baseline_subdir) # If there are any locally modified files in that directory, exit @@ -130,10 +121,46 @@ def Main(options, args): '*.pdf', svn.PROPERTY_MIMETYPE, 'application/pdf') def RaiseUsageException(): - raise Exception(USAGE_STRING % __file__) + raise Exception('%s\nRun with --help for more detail.' % ( + USAGE_STRING % __file__)) + +def Main(options, args): + """Allow other scripts to call this script with fake command-line args. + """ + # If no platforms are specified, do 'em all. + num_args = len(args) + if num_args == 0: + # TODO(epoger): automate the default set of platforms. We want to ensure + # that the user gets all of the platforms that the bots are running, + # not just whatever subdirectories he happens to have checked out... + args = [ + 'gm/base-linux', + 'gm/base-linux-fixed', + 'gm/base-macmini', + 'gm/base-macmini-fixed', + 'gm/base-macmini-lion-fixed', + 'gm/base-macmini-lion-float', + 'gm/base-win', + 'gm/base-win-fixed', + ] + + # Trim all subdir names. + baseline_subdirs = [] + for arg in args: + baseline_subdirs.append(arg.rstrip(os.sep)) + + # Make sure all those subdirectories exist. + for baseline_subdir in baseline_subdirs: + if not os.path.isdir(baseline_subdir): + raise Exception('could not find baseline_subdir "%s"' % + baseline_subdir) + + # Process the subdirs, one at a time. + for baseline_subdir in baseline_subdirs: + DownloadBaselinesForOnePlatform(baseline_subdir=baseline_subdir) if __name__ == '__main__': - parser = optparse.OptionParser(USAGE_STRING % '%prog') + parser = optparse.OptionParser(USAGE_STRING % '%prog' + HELP_STRING) parser.add_option(OPTION_IGNORE_LOCAL_MODS, action='store_true', default=False, help='allow tool to run even if there are already ' -- cgit v1.2.3