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

Unified Diff: chrome/browser/resources/PRESUBMIT.py

Issue 9323016: [WebUI] Add some presubmit checks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 years, 10 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
Index: chrome/browser/resources/PRESUBMIT.py
diff --git a/chrome/browser/resources/PRESUBMIT.py b/chrome/browser/resources/PRESUBMIT.py
new file mode 100644
index 0000000000000000000000000000000000000000..bd3ff0ef5972327cb5361e1026cd5b564d2a18a9
--- /dev/null
+++ b/chrome/browser/resources/PRESUBMIT.py
@@ -0,0 +1,46 @@
+# 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 Chromium WebUI resources.
+
+See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
+for more details about the presubmit API built into gcl/git cl, and see
+http://www.chromium.org/developers/web-development-style-guide for the rules
+we're checking against here.
+"""
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ return _CommonChecks(input_api, output_api)
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ return _CommonChecks(input_api, output_api)
+
+
+def _CommonChecks(input_api, output_api):
+ """Checks common to both upload and commit."""
+ results = []
+ resources = input_api.PresubmitLocalPath()
+
+ path = input_api.os_path
+ presubmit = path.join(resources, 'PRESUBMIT.py')
+ if presubmit in (f.AbsoluteLocalPath() for f in input_api.AffectedFiles()):
Dan Beam 2012/02/14 17:48:46 it's a tuple here
Dan Beam 2012/02/14 17:49:30 or a generator or something, whatever you told me
M-A Ruel 2012/02/14 18:03:36 Read the rationale of http://www.python.org/dev/pe
+ tests = [path.join(resources, 'test_presubmit.py')]
+ results.extend(
+ input_api.canned_checks.RunUnitTests(input_api, output_api, tests))
+
+ import sys
+ sys.path.insert(0, resources)
M-A Ruel 2012/02/14 18:03:36 you need to use a try/finally here.
Dan Beam 2012/02/14 21:29:12 You told me to remove for simplicity (http://goo.g
+ from web_dev_style import css_checker
+
+ # TODO(dbeam): Remove this filter eventually when ready.
+ def file_filter(affected_file):
+ dirs = (path.join(resources, 'ntp4'), path.join(resources, 'options2'))
+ f = affected_file.AbsoluteLocalPath()
+ return (f.startswith(dirs) and f.endswith('.css'))
+
+ results.extend(css_checker.CSSChecker(input_api, output_api,
+ file_filter=file_filter).RunChecks())
+ return results
« no previous file with comments | « no previous file | chrome/browser/resources/test_presubmit.py » ('j') | chrome/browser/resources/web_dev_style/css_checker.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698