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 |