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

Side by Side Diff: tools/perf/PRESUBMIT.py

Issue 215443002: Add JSON check in tools/perf presubmit script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | 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 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4
5 """Presubmit script for changes affecting tools/perf/.
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl (and git-cl).
9 """
10
4 import os 11 import os
5 import sys 12 import sys
6 13
7
8 PYLINT_BLACKLIST = [] 14 PYLINT_BLACKLIST = []
9 PYLINT_DISABLED_WARNINGS = ['R0923', 'R0201', 'E1101'] 15 PYLINT_DISABLED_WARNINGS = [
16 'R0923', # Interface not implemented
17 'R0201', # Method could be a function
18 'E1101', # Non-existent member is accessed.
tonyg 2014/03/27 21:09:21 I love how you add comments like this, so useful.
qyearsley 2014/03/27 21:31:58 Thanks :-)
19 ]
10 20
11 21
12 def _CommonChecks(input_api, output_api): 22 def _CommonChecks(input_api, output_api):
23 """Performs common checks, which includes running pylint."""
13 results = [] 24 results = []
14 old_sys_path = sys.path 25 old_sys_path = sys.path
15 try: 26 try:
27 # Modules in tools/perf depend on telemetry.
16 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path 28 sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path
17 results.extend(input_api.canned_checks.RunPylint( 29 results.extend(input_api.canned_checks.RunPylint(
18 input_api, output_api, 30 input_api, output_api,
19 black_list=PYLINT_BLACKLIST, 31 black_list=PYLINT_BLACKLIST,
20 disabled_warnings=PYLINT_DISABLED_WARNINGS)) 32 disabled_warnings=PYLINT_DISABLED_WARNINGS))
33 results.extend(_CheckJson(input_api, output_api))
21 finally: 34 finally:
22 sys.path = old_sys_path 35 sys.path = old_sys_path
23 return results 36 return results
24 37
25 38
39 def _CheckJson(input_api, output_api):
40 """Checks whether JSON files in this change can be parsed."""
41 affected_paths = input_api.change.AbsoluteLocalPaths()
42 json_filenames = [name for name in affected_paths if name.endswith('.json')]
43 for filename in json_filenames:
44 try:
45 input_api.json.load(open(filename))
46 except ValueError:
47 return [output_api.PresubmitError('Error parsing JSON in %s!' % filename)]
tonyg 2014/03/27 21:09:21 I suspect we are swallowing some useful informatio
qyearsley 2014/03/27 21:31:58 I think that the ValueError that's raised when jso
48 return []
49
50
26 def CheckChangeOnUpload(input_api, output_api): 51 def CheckChangeOnUpload(input_api, output_api):
27 report = [] 52 report = []
28 report.extend(_CommonChecks(input_api, output_api)) 53 report.extend(_CommonChecks(input_api, output_api))
29 return report 54 return report
30 55
31 56
32 def CheckChangeOnCommit(input_api, output_api): 57 def CheckChangeOnCommit(input_api, output_api):
33 report = [] 58 report = []
34 report.extend(_CommonChecks(input_api, output_api)) 59 report.extend(_CommonChecks(input_api, output_api))
35 return report 60 return report
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698