Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: gm/gm_json.py

Issue 18348018: rebaseline.py: if expectations dir contains JSON format results, update those instead of image files (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: tweaks Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
19 # actual-results.json).
20 #
18 # 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
19 # gm_expectations.cpp ! 22 # gm_expectations.cpp !
23
20 JSONKEY_ACTUALRESULTS = 'actual-results' 24 JSONKEY_ACTUALRESULTS = 'actual-results'
25 # Tests whose results failed to match expectations.
21 JSONKEY_ACTUALRESULTS_FAILED = 'failed' 26 JSONKEY_ACTUALRESULTS_FAILED = 'failed'
27 # Tests whose results failed to match expectations, but IGNOREFAILURE causes
28 # us to take them less seriously.
22 JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored' 29 JSONKEY_ACTUALRESULTS_FAILUREIGNORED = 'failure-ignored'
30 # 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
32 # 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
34 # check in expectations with the IGNOREFAILURE flag set).
23 JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison' 35 JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison'
36 # Tests whose results matched their expectations.
24 JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded' 37 JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded'
25 38
26 JSONKEY_EXPECTEDRESULTS = 'expected-results' 39 JSONKEY_EXPECTEDRESULTS = 'expected-results'
40 # 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
42 # expectations, and the test will pass if any one of them is matched.
27 JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS = 'allowed-digests' 43 JSONKEY_EXPECTEDRESULTS_ALLOWEDDIGESTS = 'allowed-digests'
44 # If the results of this test don't match expectations, should it be reported
45 # in the FAILED section or the FAILUREIGNORED section?
Stephen White 2013/07/08 17:15:20 Just to be braindead-clear, perhaps this should sa
epoger 2013/07/08 17:52:29 Good idea. Done.
28 JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE = 'ignore-failure' 46 JSONKEY_EXPECTEDRESULTS_IGNOREFAILURE = 'ignore-failure'
29 47
48 # Allowed hash types for test expectations.
30 JSONKEY_HASHTYPE_BITMAP_64BITMD5 = 'bitmap-64bitMD5' 49 JSONKEY_HASHTYPE_BITMAP_64BITMD5 = 'bitmap-64bitMD5'
31 50
32 def LoadFromString(file_contents): 51 def LoadFromString(file_contents):
33 """Loads the JSON summary written out by the GM tool. 52 """Loads the JSON summary written out by the GM tool.
34 Returns a dictionary keyed by the values listed as JSONKEY_ constants 53 Returns a dictionary keyed by the values listed as JSONKEY_ constants
35 above.""" 54 above."""
36 # TODO(epoger): we should add a version number to the JSON file to ensure 55 # TODO(epoger): we should add a version number to the JSON file to ensure
37 # that the writer and reader agree on the schema (raising an exception 56 # that the writer and reader agree on the schema (raising an exception
38 # otherwise). 57 # otherwise).
39 json_dict = json.loads(file_contents) 58 json_dict = json.loads(file_contents)
40 return json_dict 59 return json_dict
41 60
42 def LoadFromFile(file_path): 61 def LoadFromFile(file_path):
43 """Loads the JSON summary written out by the GM tool. 62 """Loads the JSON summary written out by the GM tool.
44 Returns a dictionary keyed by the values listed as JSONKEY_ constants 63 Returns a dictionary keyed by the values listed as JSONKEY_ constants
45 above.""" 64 above."""
46 file_contents = open(file_path, 'r').read() 65 file_contents = open(file_path, 'r').read()
47 return LoadFromString(file_contents) 66 return LoadFromString(file_contents)
67
68 def WriteToFile(json_dict, file_path):
69 """Writes the JSON summary in json_dict out to file_path."""
70 with open(file_path, 'w') as outfile:
71 json.dump(json_dict, outfile, sort_keys=True, indent=2)
OLDNEW
« gm/gm_expectations.cpp ('K') | « gm/gm_expectations.cpp ('k') | tools/rebaseline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698