131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org#!/usr/bin/python
231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org"""
431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgCopyright 2014 Google Inc.
531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgUse of this source code is governed by a BSD-style license that can be
731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgfound in the LICENSE file.
831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgCompare GM results for two configs, across all builders.
1031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org"""
1131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
1231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org# System-level imports
1331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport argparse
1431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport fnmatch
1531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport json
1631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport logging
1731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport re
1831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport time
1931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
2031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org# Imports from within Skia
21b144271179aaf82cb1151e9dfd8e866747402594epogerimport fix_pythonpath  # must do this first
22b144271179aaf82cb1151e9dfd8e866747402594epogerfrom pyutils import url_utils
2331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport gm_json
2431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport imagediffdb
2531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport imagepair
2631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport imagepairset
2731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgimport results
2831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
2931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
3031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgclass ConfigComparisons(results.BaseComparisons):
3131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  """Loads results from two different configurations into an ImagePairSet.
3231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
3331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  Loads actual and expected results from all builders, except for those skipped
34defe6fdbc8edb2df0887c007450a8d8cc446f420commit-bot@chromium.org  by _ignore_builder().
3531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  """
3631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
3731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  def __init__(self, configs, actuals_root=results.DEFAULT_ACTUALS_DIR,
3831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org               generated_images_root=results.DEFAULT_GENERATED_IMAGES_ROOT,
39defe6fdbc8edb2df0887c007450a8d8cc446f420commit-bot@chromium.org               diff_base_url=None, builder_regex_list=None):
4031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    """
4131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    Args:
4231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      configs: (string, string) tuple; pair of configs to compare
4331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      actuals_root: root directory containing all actual-results.json files
4431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      generated_images_root: directory within which to create all pixel diffs;
4531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          if this directory does not yet exist, it will be created
4631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      diff_base_url: base URL within which the client should look for diff
4731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          images; if not specified, defaults to a "file:///" URL representation
4831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          of generated_images_root
49defe6fdbc8edb2df0887c007450a8d8cc446f420commit-bot@chromium.org      builder_regex_list: List of regular expressions specifying which builders
50defe6fdbc8edb2df0887c007450a8d8cc446f420commit-bot@chromium.org          we will process. If None, process all builders.
5131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    """
5231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    time_start = int(time.time())
53defe6fdbc8edb2df0887c007450a8d8cc446f420commit-bot@chromium.org    if builder_regex_list != None:
54defe6fdbc8edb2df0887c007450a8d8cc446f420commit-bot@chromium.org      self.set_match_builders_pattern_list(builder_regex_list)
5531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    self._image_diff_db = imagediffdb.ImageDiffDB(generated_images_root)
5631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    self._diff_base_url = (
5731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        diff_base_url or
58b144271179aaf82cb1151e9dfd8e866747402594epoger        url_utils.create_filepath_url(generated_images_root))
5931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    self._actuals_root = actuals_root
6031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    self._load_config_pairs(configs)
6131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    self._timestamp = int(time.time())
6231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    logging.info('Results complete; took %d seconds.' %
6331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                 (self._timestamp - time_start))
6431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
6531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  def _load_config_pairs(self, configs):
6631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    """Loads the results of all tests, across all builders (based on the
6731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    files within self._actuals_root), compares them across two configs,
6831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    and stores the summary in self._results.
6931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
7031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    Args:
7131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      configs: tuple of strings; pair of configs to compare
7231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    """
7331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    logging.info('Reading actual-results JSON files from %s...' %
7431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                 self._actuals_root)
757418bd8cad3576294b48dd8e5015301e184c6af1commit-bot@chromium.org    actual_builder_dicts = self._read_builder_dicts_from_root(
767418bd8cad3576294b48dd8e5015301e184c6af1commit-bot@chromium.org        self._actuals_root)
7731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    configA, configB = configs
7831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    logging.info('Comparing configs %s and %s...' % (configA, configB))
7931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
8031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    all_image_pairs = imagepairset.ImagePairSet(
8131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        descriptions=configs,
8231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        diff_base_url=self._diff_base_url)
8331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    failing_image_pairs = imagepairset.ImagePairSet(
8431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        descriptions=configs,
8531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        diff_base_url=self._diff_base_url)
8631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
8731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    all_image_pairs.ensure_extra_column_values_in_summary(
8868a3815401f461976f76891d0477cb1440fa0abacommit-bot@chromium.org        column_id=results.KEY__EXTRACOLUMNS__RESULT_TYPE, values=[
8931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            results.KEY__RESULT_TYPE__FAILED,
9031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            results.KEY__RESULT_TYPE__NOCOMPARISON,
9131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            results.KEY__RESULT_TYPE__SUCCEEDED,
9231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        ])
9331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    failing_image_pairs.ensure_extra_column_values_in_summary(
9468a3815401f461976f76891d0477cb1440fa0abacommit-bot@chromium.org        column_id=results.KEY__EXTRACOLUMNS__RESULT_TYPE, values=[
9531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            results.KEY__RESULT_TYPE__FAILED,
9631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            results.KEY__RESULT_TYPE__NOCOMPARISON,
9731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        ])
9831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
9931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    builders = sorted(actual_builder_dicts.keys())
10031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    num_builders = len(builders)
10131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    builder_num = 0
10231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    for builder in builders:
10331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      builder_num += 1
10431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      logging.info('Generating pixel diffs for builder #%d of %d, "%s"...' %
10531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                   (builder_num, num_builders, builder))
10631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      actual_results_for_this_builder = (
10731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          actual_builder_dicts[builder][gm_json.JSONKEY_ACTUALRESULTS])
10831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      for result_type in sorted(actual_results_for_this_builder.keys()):
10931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        results_of_this_type = actual_results_for_this_builder[result_type]
11031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        if not results_of_this_type:
11131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          continue
11231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
11331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        tests_found = set()
11431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        for image_name in sorted(results_of_this_type.keys()):
11531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          (test, config) = results.IMAGE_FILENAME_RE.match(image_name).groups()
11631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          tests_found.add(test)
11731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
11831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org        for test in tests_found:
11931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          # Get image_relative_url (or None) for each of configA, configB
12031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          image_name_A = results.IMAGE_FILENAME_FORMATTER % (test, configA)
12131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          configA_image_relative_url = ConfigComparisons._create_relative_url(
12231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              hashtype_and_digest=results_of_this_type.get(image_name_A),
12331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              test_name=test)
12431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          image_name_B = results.IMAGE_FILENAME_FORMATTER % (test, configB)
12531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          configB_image_relative_url = ConfigComparisons._create_relative_url(
12631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              hashtype_and_digest=results_of_this_type.get(image_name_B),
12731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              test_name=test)
12831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
12931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          # If we have images for at least one of these two configs,
13031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          # add them to our list.
13131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org          if configA_image_relative_url or configB_image_relative_url:
13231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            if configA_image_relative_url == configB_image_relative_url:
13331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              result_type = results.KEY__RESULT_TYPE__SUCCEEDED
13431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            elif not configA_image_relative_url:
13531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              result_type = results.KEY__RESULT_TYPE__NOCOMPARISON
13631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            elif not configB_image_relative_url:
13731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              result_type = results.KEY__RESULT_TYPE__NOCOMPARISON
13831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            else:
13931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              result_type = results.KEY__RESULT_TYPE__FAILED
14031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
14131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            extra_columns_dict = {
14268a3815401f461976f76891d0477cb1440fa0abacommit-bot@chromium.org                results.KEY__EXTRACOLUMNS__RESULT_TYPE: result_type,
14368a3815401f461976f76891d0477cb1440fa0abacommit-bot@chromium.org                results.KEY__EXTRACOLUMNS__BUILDER: builder,
14468a3815401f461976f76891d0477cb1440fa0abacommit-bot@chromium.org                results.KEY__EXTRACOLUMNS__TEST: test,
14531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                # TODO(epoger): Right now, the client UI crashes if it receives
14631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                # results that do not include a 'config' column.
14731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                # Until we fix that, keep the client happy.
14868a3815401f461976f76891d0477cb1440fa0abacommit-bot@chromium.org                results.KEY__EXTRACOLUMNS__CONFIG: 'TODO',
14931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            }
15031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
15131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            try:
15231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              image_pair = imagepair.ImagePair(
15331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                  image_diff_db=self._image_diff_db,
15431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                  base_url=gm_json.GM_ACTUALS_ROOT_HTTP_URL,
15531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                  imageA_relative_url=configA_image_relative_url,
15631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                  imageB_relative_url=configB_image_relative_url,
15731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                  extra_columns=extra_columns_dict)
15831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              all_image_pairs.add_image_pair(image_pair)
15931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              if result_type != results.KEY__RESULT_TYPE__SUCCEEDED:
16031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                failing_image_pairs.add_image_pair(image_pair)
16131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org            except (KeyError, TypeError):
16231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org              logging.exception(
16331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                  'got exception while creating ImagePair for image_name '
16431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                  '"%s", builder "%s"' % (image_name, builder))
16531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
16631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    self._results = {
16731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      results.KEY__HEADER__RESULTS_ALL: all_image_pairs.as_dict(),
16831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      results.KEY__HEADER__RESULTS_FAILURES: failing_image_pairs.as_dict(),
16931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org    }
17031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
17131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
17231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgdef main():
17331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
17431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                      datefmt='%m/%d/%Y %H:%M:%S',
17531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                      level=logging.INFO)
17631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  parser = argparse.ArgumentParser()
17731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  parser.add_argument(
17831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      '--actuals', default=results.DEFAULT_ACTUALS_DIR,
17931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      help='Directory containing all actual-result JSON files; defaults to '
18031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      '\'%(default)s\' .')
18131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  parser.add_argument(
18231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      'config', nargs=2,
18331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      help='Two configurations to compare (8888, gpu, etc.).')
18431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  parser.add_argument(
18531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      '--outfile', required=True,
18631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      help='File to write result summary into, in JSON format.')
18731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  parser.add_argument(
18831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      '--results', default=results.KEY__HEADER__RESULTS_FAILURES,
18931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      help='Which result types to include. Defaults to \'%(default)s\'; '
19031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      'must be one of ' +
19131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      str([results.KEY__HEADER__RESULTS_FAILURES,
19231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org           results.KEY__HEADER__RESULTS_ALL]))
19331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  parser.add_argument(
19431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      '--workdir', default=results.DEFAULT_GENERATED_IMAGES_ROOT,
19531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      help='Directory within which to download images and generate diffs; '
19631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      'defaults to \'%(default)s\' .')
19731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  args = parser.parse_args()
19831d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  results_obj = ConfigComparisons(configs=args.config,
19931d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                                  actuals_root=args.actuals,
20031d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org                                  generated_images_root=args.workdir)
20131d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  gm_json.WriteToFile(
20231d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      results_obj.get_packaged_results_of_type(results_type=args.results),
20331d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org      args.outfile)
20431d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
20531d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org
20631d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.orgif __name__ == '__main__':
20731d0b3d806a1aa86b7edaa442b3821f5d548e184commit-bot@chromium.org  main()
208