Chromium Code Reviews| Index: tools/perf/PRESUBMIT.py |
| diff --git a/tools/perf/PRESUBMIT.py b/tools/perf/PRESUBMIT.py |
| index 9bb8eb1a68d2cc19372c7ed20b85a9246416c067..e5ec0ec734fb458c348850ed5722057967353ca6 100644 |
| --- a/tools/perf/PRESUBMIT.py |
| +++ b/tools/perf/PRESUBMIT.py |
| @@ -1,28 +1,53 @@ |
| # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| + |
| +"""Presubmit script for changes affecting tools/perf/. |
| + |
| +See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| +for more details about the presubmit API built into gcl (and git-cl). |
| +""" |
| + |
| import os |
| import sys |
| - |
| PYLINT_BLACKLIST = [] |
| -PYLINT_DISABLED_WARNINGS = ['R0923', 'R0201', 'E1101'] |
| +PYLINT_DISABLED_WARNINGS = [ |
| + 'R0923', # Interface not implemented |
| + 'R0201', # Method could be a function |
| + '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 :-)
|
| +] |
| def _CommonChecks(input_api, output_api): |
| + """Performs common checks, which includes running pylint.""" |
| results = [] |
| old_sys_path = sys.path |
| try: |
| + # Modules in tools/perf depend on telemetry. |
| sys.path = [os.path.join(os.pardir, 'telemetry')] + sys.path |
| results.extend(input_api.canned_checks.RunPylint( |
| input_api, output_api, |
| black_list=PYLINT_BLACKLIST, |
| disabled_warnings=PYLINT_DISABLED_WARNINGS)) |
| + results.extend(_CheckJson(input_api, output_api)) |
| finally: |
| sys.path = old_sys_path |
| return results |
| +def _CheckJson(input_api, output_api): |
| + """Checks whether JSON files in this change can be parsed.""" |
| + affected_paths = input_api.change.AbsoluteLocalPaths() |
| + json_filenames = [name for name in affected_paths if name.endswith('.json')] |
| + for filename in json_filenames: |
| + try: |
| + input_api.json.load(open(filename)) |
| + except ValueError: |
| + 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
|
| + return [] |
| + |
| + |
| def CheckChangeOnUpload(input_api, output_api): |
| report = [] |
| report.extend(_CommonChecks(input_api, output_api)) |