diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-28 15:25:38 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-28 15:25:38 +0000 |
commit | 9d33154b1362d89454297c21663b2403f1a75de5 (patch) | |
tree | 1b6c5afe6ea97081eec069a0e51aae9271823068 /gm | |
parent | 908aed802566db64212b9ff802a2b5119c7a0be0 (diff) | |
download | skia-9d33154b1362d89454297c21663b2403f1a75de5.tar.gz |
Split GM json schema out of display_json_results.py, for sharing with other tools
R=rmistry@google.com
Review URL: https://codereview.chromium.org/16155002
git-svn-id: http://skia.googlecode.com/svn/trunk@9290 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'gm')
-rw-r--r-- | gm/display_json_results.py | 24 | ||||
-rw-r--r-- | gm/gm_expectations.cpp | 2 | ||||
-rw-r--r-- | gm/gm_json.py | 34 |
3 files changed, 44 insertions, 16 deletions
diff --git a/gm/display_json_results.py b/gm/display_json_results.py index 00c0c0e8d1..4c4605fbc8 100644 --- a/gm/display_json_results.py +++ b/gm/display_json_results.py @@ -18,17 +18,11 @@ TODO(epoger): We may want to add flags to set the following: __author__ = 'Elliot Poger' -import json +# system-level imports import sys - -# These constants must be kept in sync with the kJsonKey_ constants in -# gm_expectations.cpp ! -JSONKEY_ACTUALRESULTS = 'actual-results' -JSONKEY_ACTUALRESULTS_FAILED = 'failed' -JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' -JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' -JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' +# local imports +import gm_json class ResultAccumulator(object): @@ -85,23 +79,23 @@ def Display(filepath): # Map labels within the JSON file to the ResultAccumulator for each label. results_map = { - JSONKEY_ACTUALRESULTS_FAILED: + gm_json.JSONKEY_ACTUALRESULTS_FAILED: ResultAccumulator(name='ExpectationsMismatch', do_list=True, do_fail=True), - JSONKEY_ACTUALRESULTS_FAILUREIGNORED: + gm_json.JSONKEY_ACTUALRESULTS_FAILUREIGNORED: ResultAccumulator(name='IgnoredExpectationsMismatch', do_list=True, do_fail=False), - JSONKEY_ACTUALRESULTS_NOCOMPARISON: + gm_json.JSONKEY_ACTUALRESULTS_NOCOMPARISON: ResultAccumulator(name='MissingExpectations', do_list=False, do_fail=False), - JSONKEY_ACTUALRESULTS_SUCCEEDED: + gm_json.JSONKEY_ACTUALRESULTS_SUCCEEDED: ResultAccumulator(name='Passed', do_list=False, do_fail=False), } success = True - json_dict = json.load(open(filepath)) - actual_results = json_dict[JSONKEY_ACTUALRESULTS] + json_dict = gm_json.Load(filepath) + actual_results = json_dict[gm_json.JSONKEY_ACTUALRESULTS] for label, accumulator in results_map.iteritems(): results = actual_results[label] if results: diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp index 8138af7890..08461bd901 100644 --- a/gm/gm_expectations.cpp +++ b/gm/gm_expectations.cpp @@ -12,7 +12,7 @@ #define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message") // These constants must be kept in sync with the JSONKEY_ constants in -// display_json_results.py ! +// gm_json.py ! const static char kJsonKey_ActualResults[] = "actual-results"; const static char kJsonKey_ActualResults_Failed[] = "failed"; const static char kJsonKey_ActualResults_FailureIgnored[]= "failure-ignored"; diff --git a/gm/gm_json.py b/gm/gm_json.py new file mode 100644 index 0000000000..04c0d6a188 --- /dev/null +++ b/gm/gm_json.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# Copyright (c) 2013 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""Schema of the JSON summary file written out by the GM tool. + +This must be kept in sync with the kJsonKey_ constants in gm_expectations.cpp ! +""" + +__author__ = 'Elliot Poger' + + +# system-level imports +import json + + +# These constants must be kept in sync with the kJsonKey_ constants in +# gm_expectations.cpp ! +JSONKEY_ACTUALRESULTS = 'actual-results' +JSONKEY_ACTUALRESULTS_FAILED = 'failed' +JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' +JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' +JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' + +def Load(filepath): + """Loads the JSON summary written out by the GM tool. + Returns a dictionary keyed by the values listed as JSONKEY_ constants + above.""" + # In the future, we should add a version number to the JSON file to ensure + # that the writer and reader agree on the schema (raising an exception + # otherwise). + json_dict = json.load(open(filepath)) + return json_dict |