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

Unified Diff: chrome/app/policy/PRESUBMIT.py

Issue 6299001: Syntax checker for policy_templates.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/app/policy
Patch Set: fix nits; update PRESUBMIT.py Created 9 years, 11 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 | chrome/app/policy/policy_templates.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/policy/PRESUBMIT.py
diff --git a/chrome/app/policy/PRESUBMIT.py b/chrome/app/policy/PRESUBMIT.py
new file mode 100644
index 0000000000000000000000000000000000000000..99a2a29113b40cd4b86d5fe645a1e9f0dbf7ef9b
--- /dev/null
+++ b/chrome/app/policy/PRESUBMIT.py
@@ -0,0 +1,35 @@
+# Copyright (c) 2011 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.
+
+# If this presubmit check fails or misbehaves, please complain to
+# gfeher@chromium.org or jkummerow@chromium.org.
+
+import os
+import sys
+import traceback
+
+
+def _CommonChecks(input_api, output_api):
+ filename = 'policy_templates.json'
+ results = []
+ for f in input_api.AffectedFiles():
+ if f.AbsoluteLocalPath() == os.path.join(input_api.PresubmitLocalPath(),
M-A Ruel 2011/01/18 13:52:03 input_api.os_path.join(...
Jakob Kummerow 2011/01/18 15:02:36 Done.
+ filename):
+ sys.path.append(input_api.PresubmitLocalPath())
M-A Ruel 2011/01/18 13:52:03 Don't do that, it affects all following presubmit
Jakob Kummerow 2011/01/18 15:02:36 Done.
+ # Optimization: only load this when it's needed.
+ import syntax_check_policy_template_json
+ checker = syntax_check_policy_template_json.PolicyTemplateChecker()
+ result = checker.Run([], f.AbsoluteLocalPath())
+ if result > 0:
+ results.append(output_api.PresubmitError(
+ 'Syntax error(s) in file:', [f]))
+ return results
+
+
+def CheckChangeOnUpload(input_api, output_api):
+ return _CommonChecks(input_api, output_api)
+
+
+def CheckChangeOnCommit(input_api, output_api):
+ return _CommonChecks(input_api, output_api)
« no previous file with comments | « no previous file | chrome/app/policy/policy_templates.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698