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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
« 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