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

Side by Side Diff: gm/gm_json.py

Issue 15934018: gm_json.py: add ability to load JSON file from a string, not just a local file (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 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
« no previous file with comments | « gm/display_json_results.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 # 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 def Load(filepath): 26 def LoadFromString(file_contents):
27 """Loads the JSON summary written out by the GM tool. 27 """Loads the JSON summary written out by the GM tool.
28 Returns a dictionary keyed by the values listed as JSONKEY_ constants 28 Returns a dictionary keyed by the values listed as JSONKEY_ constants
29 above.""" 29 above."""
30 # In the future, we should add a version number to the JSON file to ensure 30 # 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 31 # that the writer and reader agree on the schema (raising an exception
32 # otherwise). 32 # otherwise).
33 json_dict = json.load(open(filepath)) 33 json_dict = json.loads(file_contents)
34 return json_dict 34 return json_dict
35
36 def LoadFromFile(file_path):
37 """Loads the JSON summary written out by the GM tool.
38 Returns a dictionary keyed by the values listed as JSONKEY_ constants
39 above."""
40 file_contents = open(file_path, 'r').read()
41 return LoadFromString(file_contents)
OLDNEW
« no previous file with comments | « gm/display_json_results.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698