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

Side by Side Diff: third_party/WebKit/Source/devtools/PRESUBMIT.py

Issue 2699803005: DevTools: add PRESUBMIT hook for browser_protocol.json in Source/core/inspector (Closed)
Patch Set: address CL feedback Created 3 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/inspector/PRESUBMIT.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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!"
38
39 CheckOutput = namedtuple('CheckOutput', ['results', 'has_errors']) 37 CheckOutput = namedtuple('CheckOutput', ['results', 'has_errors'])
40 38
41 39
42 def _CheckNodeAndNPMModules(input_api, output_api): 40 def _CheckNodeAndNPMModules(input_api, output_api):
43 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s cripts", "install_node_deps.py") 41 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s cripts", "install_node_deps.py")
44 process = input_api.subprocess.Popen( 42 process = input_api.subprocess.Popen(
45 [input_api.python_executable, node_script_path], stdout=input_api.subpro cess.PIPE, stderr=input_api.subprocess.STDOUT) 43 [input_api.python_executable, node_script_path], stdout=input_api.subpro cess.PIPE, stderr=input_api.subprocess.STDOUT)
46 out, _ = process.communicate() 44 out, _ = process.communicate()
47 if process.returncode != 0: 45 if process.returncode != 0:
48 return CheckOutput([output_api.PresubmitError(out)], has_errors=True) 46 return CheckOutput([output_api.PresubmitError(out)], has_errors=True)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 stdout=input_api.subprocess.PIPE, 103 stdout=input_api.subprocess.PIPE,
106 stderr=input_api.subprocess.STDOUT) 104 stderr=input_api.subprocess.STDOUT)
107 out, _ = process.communicate() 105 out, _ = process.communicate()
108 if process.returncode != 0: 106 if process.returncode != 0:
109 return [output_api.PresubmitError(out)] 107 return [output_api.PresubmitError(out)]
110 return [output_api.PresubmitNotifyResult(out)] 108 return [output_api.PresubmitNotifyResult(out)]
111 return [] 109 return []
112 110
113 111
114 def _CompileDevtoolsFrontend(input_api, output_api): 112 def _CompileDevtoolsFrontend(input_api, output_api):
115 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] 113 compile_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "scrip ts", "compile_frontend.py")
116 114 out, _ = input_api.subprocess.Popen(
117 # FIXME: The compilation does not actually run if injected script-related fi les 115 [input_api.python_executable, compile_path], stdout=input_api.subprocess .PIPE,
118 # have changed, as they reside in core/inspector, which is not affected 116 stderr=input_api.subprocess.STDOUT).communicate()
119 # by this presubmit. 117 if "ERROR" in out or "WARNING" in out:
120 # Once this is fixed, injected_script_externs.js 118 return [output_api.PresubmitError(out)]
121 # should be added to the list of triggers. 119 if "NOTE" in out:
122 devtools_front_end = input_api.os_path.join("devtools", "front_end") 120 return [output_api.PresubmitPromptWarning(out)]
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 [] 121 return []
136 122
137 123
138 def _CheckConvertSVGToPNGHashes(input_api, output_api): 124 def _CheckConvertSVGToPNGHashes(input_api, output_api):
139 if not input_api.platform.startswith('linux'): 125 if not input_api.platform.startswith('linux'):
140 return [] 126 return []
141 127
142 original_sys_path = sys.path 128 original_sys_path = sys.path
143 try: 129 try:
144 sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPa th(), 'scripts', 'build')] 130 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
244 devtools_scripts = input_api.os_path.join(devtools_root, "scripts") 230 devtools_scripts = input_api.os_path.join(devtools_root, "scripts")
245 affected_js_files = [ 231 affected_js_files = [
246 file_name for file_name in local_paths 232 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") 233 if (devtools_front_end in file_name or devtools_scripts in file_name) an d file_name.endswith(".js")
248 ] 234 ]
249 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in affected_js_files] 235 return [input_api.os_path.relpath(file_name, devtools_root) for file_name in affected_js_files]
250 236
251 237
252 def _inputPopen(input_api, args): 238 def _inputPopen(input_api, args):
253 return input_api.subprocess.Popen(args, stdout=input_api.subprocess.PIPE, st derr=input_api.subprocess.STDOUT) 239 return input_api.subprocess.Popen(args, stdout=input_api.subprocess.PIPE, st derr=input_api.subprocess.STDOUT)
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/inspector/PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698