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

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: sync_to_r9118 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') | no next file with comments »
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
27
28 def Assert(filepath):
29 """Raises an exception if the JSON summary at filepath contains any failed
30 tests, or if we were unable to read the JSON summary."""
31 failed_tests = GetFailedTests(filepath)
32 if failed_tests:
33 raise Exception('JSON file %s contained these test failures...\n%s' % (
34 filepath, json.dumps(failed_tests, indent=JSON_INDENTLEVEL)))
35
36
37 def GetFailedTests(filepath):
38 """Returns the dictionary of failed tests from the JSON file at filepath."""
39 json_dict = json.load(open(filepath))
40 actual_results = json_dict[JSONKEY_ACTUALRESULTS]
41 return actual_results[JSONKEY_ACTUALRESULTS_FAILED]
42
43
44 if '__main__' == __name__:
45 if len(sys.argv) != 2:
46 raise Exception('usage: %s <input-json-filepath>' % sys.argv[0])
47 Assert(sys.argv[1])
OLDNEW
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698