Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (C) 2014 Google Inc. All rights reserved. | 1 # Copyright (C) 2014 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 """DevTools JSDoc validator presubmit script | 28 """DevTools JSDoc validator presubmit script |
| 29 | 29 |
| 30 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 30 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 31 for more details about the presubmit API built into gcl. | 31 for more details about the presubmit API built into gcl. |
| 32 """ | 32 """ |
| 33 | 33 |
| 34 from collections import namedtuple | 34 from collections import namedtuple |
| 35 import sys | 35 import sys |
| 36 | 36 |
| 37 compile_note = "Be sure to run your patch by the compile_frontend.py script prio r to committing!" | 37 compile_note = "Be sure to run your patch by the compile_frontend.py script prio r to committing!" |
|
dgozman
2017/02/17 01:20:18
Seems unnecessary now.
chenwilliam
2017/02/17 02:17:31
Done.
| |
| 38 | 38 |
| 39 CheckOutput = namedtuple('CheckOutput', ['results', 'has_errors']) | 39 CheckOutput = namedtuple('CheckOutput', ['results', 'has_errors']) |
| 40 | 40 |
| 41 | 41 |
| 42 def _CheckNodeAndNPMModules(input_api, output_api): | 42 def _CheckNodeAndNPMModules(input_api, output_api): |
| 43 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s cripts", "install_node_deps.py") | 43 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s cripts", "install_node_deps.py") |
| 44 process = input_api.subprocess.Popen( | 44 process = input_api.subprocess.Popen( |
| 45 [input_api.python_executable, node_script_path], stdout=input_api.subpro cess.PIPE, stderr=input_api.subprocess.STDOUT) | 45 [input_api.python_executable, node_script_path], stdout=input_api.subpro cess.PIPE, stderr=input_api.subprocess.STDOUT) |
| 46 out, _ = process.communicate() | 46 out, _ = process.communicate() |
| 47 if process.returncode != 0: | 47 if process.returncode != 0: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 105 stdout=input_api.subprocess.PIPE, | 105 stdout=input_api.subprocess.PIPE, |
| 106 stderr=input_api.subprocess.STDOUT) | 106 stderr=input_api.subprocess.STDOUT) |
| 107 out, _ = process.communicate() | 107 out, _ = process.communicate() |
| 108 if process.returncode != 0: | 108 if process.returncode != 0: |
| 109 return [output_api.PresubmitError(out)] | 109 return [output_api.PresubmitError(out)] |
| 110 return [output_api.PresubmitNotifyResult(out)] | 110 return [output_api.PresubmitNotifyResult(out)] |
| 111 return [] | 111 return [] |
| 112 | 112 |
| 113 | 113 |
| 114 def _CompileDevtoolsFrontend(input_api, output_api): | 114 def _CompileDevtoolsFrontend(input_api, output_api): |
| 115 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] | 115 compile_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "scrip ts", "compile_frontend.py") |
| 116 | 116 out, _ = input_api.subprocess.Popen( |
| 117 # FIXME: The compilation does not actually run if injected script-related fi les | 117 [input_api.python_executable, compile_path], stdout=input_api.subprocess .PIPE, |
| 118 # have changed, as they reside in core/inspector, which is not affected | 118 stderr=input_api.subprocess.STDOUT).communicate() |
| 119 # by this presubmit. | 119 if "ERROR" in out or "WARNING" in out: |
| 120 # Once this is fixed, injected_script_externs.js | 120 return [output_api.PresubmitError(out)] |
| 121 # should be added to the list of triggers. | 121 if "NOTE" in out: |
| 122 devtools_front_end = input_api.os_path.join("devtools", "front_end") | 122 return [output_api.PresubmitPromptWarning(out + compile_note)] |
| 123 if (any(devtools_front_end in path for path in local_paths) or any("_protoco l.json" in path for path in local_paths) or | |
| 124 any("compile_frontend.py" in path for path in local_paths) or any("I njectedScriptSource.js" in path | |
| 125 fo r path in local_paths) or | |
| 126 any("DebuggerScript.js" in path for path in local_paths)): | |
| 127 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "scri pts", "compile_frontend.py") | |
| 128 out, _ = input_api.subprocess.Popen( | |
| 129 [input_api.python_executable, lint_path], stdout=input_api.subproces s.PIPE, | |
| 130 stderr=input_api.subprocess.STDOUT).communicate() | |
| 131 if "ERROR" in out or "WARNING" in out: | |
| 132 return [output_api.PresubmitError(out)] | |
| 133 if "NOTE" in out: | |
| 134 return [output_api.PresubmitPromptWarning(out + compile_note)] | |
| 135 return [] | 123 return [] |
| 136 | 124 |
| 137 | 125 |
| 138 def _CheckConvertSVGToPNGHashes(input_api, output_api): | 126 def _CheckConvertSVGToPNGHashes(input_api, output_api): |
| 139 if not input_api.platform.startswith('linux'): | 127 if not input_api.platform.startswith('linux'): |
| 140 return [] | 128 return [] |
| 141 | 129 |
| 142 original_sys_path = sys.path | 130 original_sys_path = sys.path |
| 143 try: | 131 try: |
| 144 sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPa th(), 'scripts', 'build')] | 132 sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPa th(), 'scripts', 'build')] |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 devtools_scripts = input_api.os_path.join(devtools_root, "scripts") | 232 devtools_scripts = input_api.os_path.join(devtools_root, "scripts") |
| 245 affected_js_files = [ | 233 affected_js_files = [ |
| 246 file_name for file_name in local_paths | 234 file_name for file_name in local_paths |
| 247 if (devtools_front_end in file_name or devtools_scripts in file_name) an d file_name.endswith(".js") | 235 if (devtools_front_end in file_name or devtools_scripts in file_name) an d file_name.endswith(".js") |
| 248 ] | 236 ] |
| 249 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in affected_js_files] | 237 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in affected_js_files] |
| 250 | 238 |
| 251 | 239 |
| 252 def _inputPopen(input_api, args): | 240 def _inputPopen(input_api, args): |
| 253 return input_api.subprocess.Popen(args, stdout=input_api.subprocess.PIPE, st derr=input_api.subprocess.STDOUT) | 241 return input_api.subprocess.Popen(args, stdout=input_api.subprocess.PIPE, st derr=input_api.subprocess.STDOUT) |
| OLD | NEW |