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

Side by Side Diff: gm/confirm_no_failures_in_json.py

Issue 15100003: Add gm/confirm_no_failures_in_json.py (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 7 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 | « no previous file | gm/gm_expectations.cpp » ('j') | gm/tests/run.sh » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
5
6 """Utility to confirm that a JSON summary written by GM contains no failures.
7
8 Usage:
9 python confirm_no_failures_in_json.py <filename>
10 """
11
12 __author__ = 'Elliot Poger'
13
14
15 import json
16 import sys
17
18
19 # These constants must be kept in sync with the kJsonKey_ constants in
20 # gm_expectations.cpp !
21 JSONKEY_ACTUALRESULTS = 'actual-results'
22 JSONKEY_ACTUALRESULTS_FAILED = 'failed'
23
24 # This is the same indent level as used by jsoncpp, just for consistency.
25 JSON_INDENTLEVEL = 3
26
rmistry 2013/05/13 12:25:39 Nit: Please add one more new line here.
epoger 2013/05/14 15:03:00 Done.
27 def Assert(filepath):
rmistry 2013/05/13 12:25:39 Should this function (and the one below) be privat
epoger 2013/05/14 15:03:00 I actually do envision them being used by other mo
rmistry 2013/05/14 18:36:44 Yes.
28 """Raises an exception if the JSON summary at filepath contains any failed
29 tests, or if we were unable to read the JSON summary."""
30 failed_tests = GetFailedTests(filepath)
31 if failed_tests:
32 raise Exception('JSON file %s contained these test failures...\n%s' % (
33 filepath, json.dumps(failed_tests, indent=JSON_INDENTLEVEL)))
34
35
36 def GetFailedTests(filepath):
37 """Returns the dictionary of failed tests from the JSON file at filepath."""
38 json_dict = json.load(open(filepath))
39 actual_results = json_dict.get(JSONKEY_ACTUALRESULTS)
rmistry 2013/05/13 12:25:39 If the json_dict does not have an 'actual-results'
epoger 2013/05/14 15:03:00 That's much better, thanks! It also signals an er
rmistry 2013/05/14 18:36:44 The failed key will always be present? or are we a
epoger 2013/05/14 18:56:08 The "failed" key should always be present... if th
40 return actual_results.get(JSONKEY_ACTUALRESULTS_FAILED)
41
42
43 if '__main__' == __name__:
44 if len(sys.argv) != 2:
45 raise Exception('usage: %s <input-json-filepath>' % sys.argv[0])
46 Assert(sys.argv[1])
OLDNEW
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | gm/tests/run.sh » ('J')

Powered by Google App Engine
This is Rietveld 408576698