| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Schema of the JSON summary file written out by the GM tool. | 6 """Schema of the JSON summary file written out by the GM tool. |
| 7 | 7 |
| 8 This must be kept in sync with the kJsonKey_ constants in gm_expectations.cpp ! | 8 This must be kept in sync with the kJsonKey_ constants in gm_expectations.cpp ! |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 __author__ = 'Elliot Poger' | 11 __author__ = 'Elliot Poger' |
| 12 | 12 |
| 13 | 13 |
| 14 # system-level imports | 14 # system-level imports |
| 15 import json | 15 import json |
| 16 | 16 |
| 17 | 17 |
| 18 # These constants must be kept in sync with the kJsonKey_ constants in | 18 # These constants must be kept in sync with the kJsonKey_ constants in |
| 19 # gm_expectations.cpp ! | 19 # gm_expectations.cpp ! |
| 20 JSONKEY_ACTUALRESULTS = 'actual-results' | 20 JSONKEY_ACTUALRESULTS = 'actual-results' |
| 21 JSONKEY_ACTUALRESULTS_FAILED = 'failed' | 21 JSONKEY_ACTUALRESULTS_FAILED = 'failed' |
| 22 JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' | 22 JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' |
| 23 JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' | 23 JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' |
| 24 JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' | 24 JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' |
| 25 | 25 |
| 26 JSONKEY_EXPECTEDRESULTS = 'expected-results' |
| 27 JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS = 'allowed-digests' |
| 28 JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE = 'ignore-failure' |
| 29 |
| 30 JSONKEY_HASHTYPE_BITMAP_64BITMD5 = 'bitmap-64bitMD5' |
| 31 |
| 26 def LoadFromString(file_contents): | 32 def LoadFromString(file_contents): |
| 27 """Loads the JSON summary written out by the GM tool. | 33 """Loads the JSON summary written out by the GM tool. |
| 28 Returns a dictionary keyed by the values listed as JSONKEY_ constants | 34 Returns a dictionary keyed by the values listed as JSONKEY_ constants |
| 29 above.""" | 35 above.""" |
| 30 # TODO(epoger): we should add a version number to the JSON file to ensure | 36 # TODO(epoger): 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 | 37 # that the writer and reader agree on the schema (raising an exception |
| 32 # otherwise). | 38 # otherwise). |
| 33 json_dict = json.loads(file_contents) | 39 json_dict = json.loads(file_contents) |
| 34 return json_dict | 40 return json_dict |
| 35 | 41 |
| 36 def LoadFromFile(file_path): | 42 def LoadFromFile(file_path): |
| 37 """Loads the JSON summary written out by the GM tool. | 43 """Loads the JSON summary written out by the GM tool. |
| 38 Returns a dictionary keyed by the values listed as JSONKEY_ constants | 44 Returns a dictionary keyed by the values listed as JSONKEY_ constants |
| 39 above.""" | 45 above.""" |
| 40 file_contents = open(file_path, 'r').read() | 46 file_contents = open(file_path, 'r').read() |
| 41 return LoadFromString(file_contents) | 47 return LoadFromString(file_contents) |
| OLD | NEW |