| epoger@google.com | 9d33154 | 2013-05-28 15:25:38 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | """Schema of the JSON summary file written out by the GM tool. |
| 7 | |
| 8 | This must be kept in sync with the kJsonKey_ constants in gm_expectations.cpp ! |
| 9 | """ |
| 10 | |
| 11 | __author__ = 'Elliot Poger' |
| 12 | |
| 13 | |
| 14 | # system-level imports |
| 15 | import json |
| 16 | |
| 17 | |
| 18 | # These constants must be kept in sync with the kJsonKey_ constants in |
| 19 | # gm_expectations.cpp ! |
| 20 | JSONKEY_ACTUALRESULTS = 'actual-results' |
| 21 | JSONKEY_ACTUALRESULTS_FAILED = 'failed' |
| 22 | JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' |
| 23 | JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' |
| 24 | JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' |
| 25 | |
| 26 | def Load(filepath): |
| 27 | """Loads the JSON summary written out by the GM tool. |
| 28 | Returns a dictionary keyed by the values listed as JSONKEY_ constants |
| 29 | above.""" |
| 30 | # In the future, we should add a version number to the JSON file to ensure |
| 31 | # that the writer and reader agree on the schema (raising an exception |
| 32 | # otherwise). |
| 33 | json_dict = json.load(open(filepath)) |
| 34 | return json_dict |