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 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 # expectations, and the test will pass if any one of them is matched. | 42 # expectations, and the test will pass if any one of them is matched. |
43 JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS = 'allowed-digests' | 43 JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS = 'allowed-digests' |
44 # If IGNOREFAILURE is set to True, a failure of this test will be reported | 44 # If IGNOREFAILURE is set to True, a failure of this test will be reported |
45 # within the FAILUREIGNORED section (thus NOT causing the buildbots to go red) | 45 # within the FAILUREIGNORED section (thus NOT causing the buildbots to go red) |
46 # rather than the FAILED section (which WOULD cause the buildbots to go red). | 46 # rather than the FAILED section (which WOULD cause the buildbots to go red). |
47 JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE = 'ignore-failure' | 47 JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE = 'ignore-failure' |
48 | 48 |
49 # Allowed hash types for test expectations. | 49 # Allowed hash types for test expectations. |
50 JSONKEY_HASHTYPE_BITMAP_64BITMD5 = 'bitmap-64bitMD5' | 50 JSONKEY_HASHTYPE_BITMAP_64BITMD5 = 'bitmap-64bitMD5' |
51 | 51 |
52 # Pattern used to assemble each image's filename | |
53 IMAGE_FILENAME_PATTERN = '(\S+)_(\S+).png' # matches (testname, config) | |
borenet
2013/07/16 17:42:13
Any reason we can't just make this:
IMAGE_FILENAME
epoger
2013/07/16 18:22:48
I think it's better to keep it as a pattern string
| |
54 | |
55 | |
52 def LoadFromString(file_contents): | 56 def LoadFromString(file_contents): |
53 """Loads the JSON summary written out by the GM tool. | 57 """Loads the JSON summary written out by the GM tool. |
54 Returns a dictionary keyed by the values listed as JSONKEY_ constants | 58 Returns a dictionary keyed by the values listed as JSONKEY_ constants |
55 above.""" | 59 above.""" |
56 # TODO(epoger): we should add a version number to the JSON file to ensure | 60 # TODO(epoger): we should add a version number to the JSON file to ensure |
57 # that the writer and reader agree on the schema (raising an exception | 61 # that the writer and reader agree on the schema (raising an exception |
58 # otherwise). | 62 # otherwise). |
59 json_dict = json.loads(file_contents) | 63 json_dict = json.loads(file_contents) |
60 return json_dict | 64 return json_dict |
61 | 65 |
62 def LoadFromFile(file_path): | 66 def LoadFromFile(file_path): |
63 """Loads the JSON summary written out by the GM tool. | 67 """Loads the JSON summary written out by the GM tool. |
64 Returns a dictionary keyed by the values listed as JSONKEY_ constants | 68 Returns a dictionary keyed by the values listed as JSONKEY_ constants |
65 above.""" | 69 above.""" |
66 file_contents = open(file_path, 'r').read() | 70 file_contents = open(file_path, 'r').read() |
67 return LoadFromString(file_contents) | 71 return LoadFromString(file_contents) |
68 | 72 |
69 def WriteToFile(json_dict, file_path): | 73 def WriteToFile(json_dict, file_path): |
70 """Writes the JSON summary in json_dict out to file_path.""" | 74 """Writes the JSON summary in json_dict out to file_path.""" |
71 with open(file_path, 'w') as outfile: | 75 with open(file_path, 'w') as outfile: |
72 json.dump(json_dict, outfile, sort_keys=True, indent=2) | 76 json.dump(json_dict, outfile, sort_keys=True, indent=2) |
OLD | NEW |