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 # Key strings used in GM results JSON files (both expected-results.json and | 18 # Key strings used in GM results JSON files (both expected-results.json and |
19 # actual-results.json). | 19 # actual-results.json). |
20 # | 20 # |
21 # These constants must be kept in sync with the kJsonKey_ constants in | 21 # These constants must be kept in sync with the kJsonKey_ constants in |
22 # gm_expectations.cpp ! | 22 # gm_expectations.cpp ! |
23 | 23 |
| 24 |
24 JSONKEY_ACTUALRESULTS = 'actual-results' | 25 JSONKEY_ACTUALRESULTS = 'actual-results' |
| 26 |
25 # Tests whose results failed to match expectations. | 27 # Tests whose results failed to match expectations. |
26 JSONKEY_ACTUALRESULTS_FAILED = 'failed' | 28 JSONKEY_ACTUALRESULTS_FAILED = 'failed' |
| 29 |
27 # Tests whose results failed to match expectations, but IGNOREFAILURE causes | 30 # Tests whose results failed to match expectations, but IGNOREFAILURE causes |
28 # us to take them less seriously. | 31 # us to take them less seriously. |
29 JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' | 32 JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' |
| 33 |
30 # Tests for which we do not have any expectations. They may be new tests that | 34 # Tests for which we do not have any expectations. They may be new tests that |
31 # we haven't had a chance to check in expectations for yet, or we may have | 35 # we haven't had a chance to check in expectations for yet, or we may have |
32 # consciously decided to leave them without expectations because we are unhappy | 36 # consciously decided to leave them without expectations because we are unhappy |
33 # with the results (although we should try to move away from that, and instead | 37 # with the results (although we should try to move away from that, and instead |
34 # check in expectations with the IGNOREFAILURE flag set). | 38 # check in expectations with the IGNOREFAILURE flag set). |
35 JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' | 39 JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' |
| 40 |
36 # Tests whose results matched their expectations. | 41 # Tests whose results matched their expectations. |
37 JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' | 42 JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' |
38 | 43 |
| 44 |
39 JSONKEY_EXPECTEDRESULTS = 'expected-results' | 45 JSONKEY_EXPECTEDRESULTS = 'expected-results' |
| 46 |
40 # One or more [HashType/DigestValue] pairs representing valid results for this | 47 # One or more [HashType/DigestValue] pairs representing valid results for this |
41 # test. Typically, there will just be one pair, but we allow for multiple | 48 # test. Typically, there will just be one pair, but we allow for multiple |
42 # expectations, and the test will pass if any one of them is matched. | 49 # expectations, and the test will pass if any one of them is matched. |
43 JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS = 'allowed-digests' | 50 JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS = 'allowed-digests' |
| 51 |
| 52 # Optional: one or more integers listing Skia bugs (under |
| 53 # https://code.google.com/p/skia/issues/list ) that pertain to this expectation. |
| 54 JSONKEY_EXPECTEDRESULTS_BUGS = 'bugs' |
| 55 |
44 # If IGNOREFAILURE is set to True, a failure of this test will be reported | 56 # 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) | 57 # 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). | 58 # rather than the FAILED section (which WOULD cause the buildbots to go red). |
47 JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE = 'ignore-failure' | 59 JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE = 'ignore-failure' |
48 | 60 |
| 61 # Optional: a free-form text string with human-readable information about |
| 62 # this expectation. |
| 63 JSONKEY_EXPECTEDRESULTS_NOTES = 'notes' |
| 64 |
| 65 # Optional: boolean indicating whether this expectation was reviewed/approved |
| 66 # by a human being. |
| 67 # If True: a human looked at this image and approved it. |
| 68 # If False: this expectation was committed blind. (In such a case, please |
| 69 # add notes indicating why!) |
| 70 # If absent: this expectation was committed by a tool that didn't enforce human |
| 71 # review of expectations. |
| 72 JSONKEY_EXPECTEDRESULTS_REVIEWED = 'reviewed-by-human' |
| 73 |
| 74 |
49 # Allowed hash types for test expectations. | 75 # Allowed hash types for test expectations. |
50 JSONKEY_HASHTYPE_BITMAP_64BITMD5 = 'bitmap-64bitMD5' | 76 JSONKEY_HASHTYPE_BITMAP_64BITMD5 = 'bitmap-64bitMD5' |
51 | 77 |
52 # Root directory where the buildbots store their actually-generated images... | 78 # Root directory where the buildbots store their actually-generated images... |
53 # as a publicly readable HTTP URL: | 79 # as a publicly readable HTTP URL: |
54 GM_ACTUALS_ROOT_HTTP_URL = ( | 80 GM_ACTUALS_ROOT_HTTP_URL = ( |
55 'http://chromium-skia-gm.commondatastorage.googleapis.com/gm') | 81 'http://chromium-skia-gm.commondatastorage.googleapis.com/gm') |
56 # as a GS URL that allows credential-protected write access: | 82 # as a GS URL that allows credential-protected write access: |
57 GM_ACTUALS_ROOT_GS_URL = 'gs://chromium-skia-gm/gm' | 83 GM_ACTUALS_ROOT_GS_URL = 'gs://chromium-skia-gm/gm' |
58 | 84 |
(...skipping 28 matching lines...) Expand all Loading... |
87 """Loads the JSON summary written out by the GM tool. | 113 """Loads the JSON summary written out by the GM tool. |
88 Returns a dictionary keyed by the values listed as JSONKEY_ constants | 114 Returns a dictionary keyed by the values listed as JSONKEY_ constants |
89 above.""" | 115 above.""" |
90 file_contents = open(file_path, 'r').read() | 116 file_contents = open(file_path, 'r').read() |
91 return LoadFromString(file_contents) | 117 return LoadFromString(file_contents) |
92 | 118 |
93 def WriteToFile(json_dict, file_path): | 119 def WriteToFile(json_dict, file_path): |
94 """Writes the JSON summary in json_dict out to file_path.""" | 120 """Writes the JSON summary in json_dict out to file_path.""" |
95 with open(file_path, 'w') as outfile: | 121 with open(file_path, 'w') as outfile: |
96 json.dump(json_dict, outfile, sort_keys=True, indent=2) | 122 json.dump(json_dict, outfile, sort_keys=True, indent=2) |
OLD | NEW |