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

Unified Diff: chrome/common/extensions/api/PRESUBMIT.py

Issue 23512007: Prase IDL files in common/extensions/api PRESUBMIT check. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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/common/extensions/api/PRESUBMIT.py
diff --git a/chrome/common/extensions/api/PRESUBMIT.py b/chrome/common/extensions/api/PRESUBMIT.py
index 20d61fa8b06500277977202a5593842e12b8dd97..bdd97bc1268b4e3cf3d0dfd316a0929ee8a3907a 100644
--- a/chrome/common/extensions/api/PRESUBMIT.py
+++ b/chrome/common/extensions/api/PRESUBMIT.py
@@ -19,6 +19,21 @@ def _GetJSONParseError(input_api, contents):
return None
+def _GetIDLParseError(input_api, filename):
+ idl_schema = input_api.os_path.join(
+ input_api.PresubmitLocalPath(),
+ '..', '..', '..', '..', 'tools',
+ 'json_schema_compiler', 'idl_schema.py')
+ process = input_api.subprocess.Popen(
+ [input_api.python_executable, idl_schema, filename],
+ stdout=input_api.subprocess.PIPE,
+ stderr=input_api.subprocess.PIPE)
+ (_, error) = process.communicate()
+ if error:
+ return error
+ return None
+
+
def _GetParseErrors(input_api, output_api):
# Run unit tests.
results = []
@@ -37,7 +52,15 @@ def _GetParseErrors(input_api, output_api):
results.append(output_api.PresubmitError(
'Features file %s could not be parsed: %s' %
(affected_file.LocalPath(), parse_error)))
- # TODO(yoz): Also ensure IDL files are parseable.
+
+ for affected_file in input_api.AffectedFiles(
+ file_filter=lambda f: f.LocalPath().endswith('.idl')):
+ filename = affected_file.AbsoluteLocalPath()
not at google - send to devlin 2013/09/09 16:14:07 too much indent
Haojian Wu 2013/09/10 02:51:04 Done.
+ parse_error = _GetIDLParseError(input_api, filename)
+ if parse_error:
+ results.append(output_api.PresubmitError(
+ 'Features file %s could not be parsed: %s' %
not at google - send to devlin 2013/09/09 16:14:07 s/Features/IDL/
Haojian Wu 2013/09/10 02:51:04 Done.
+ (affected_file.LocalPath(), parse_error)))
not at google - send to devlin 2013/09/09 16:14:07 You could factor this more concisely: actions = {
Haojian Wu 2013/09/10 02:51:04 Done. Thanks for the detailed instructions!
return results
« no previous file with comments | « no previous file | chrome/common/extensions/api/PRESUBMIT_test.py » ('j') | chrome/common/extensions/api/PRESUBMIT_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698