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 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 31 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 32 for more details about the presubmit API built into gcl. | 32 for more details about the presubmit API built into gcl. |
| 33 """ | 33 """ |
| 34 | 34 |
| 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!" |
| 38 | 38 |
| 39 | 39 |
| 40 def _CheckNodeAndNPMModules(input_api, output_api): | |
|
lushnikov
2016/10/05 16:22:49
do we really need this presubmit check?
looks lik
chenwilliam
2016/10/05 17:59:19
This is necessary to run "npm install", which is h
lushnikov
2016/10/07 17:05:43
Shell we pursue the hermetic build for the github
chenwilliam
2016/10/10 19:36:17
I'm currently going through the compliance review
| |
| 41 node_script_path = input_api.os_path.join(input_api.PresubmitLocalPath(), "s cripts", "install_node_deps.py") | |
| 42 process = input_api.subprocess.Popen( | |
| 43 [input_api.python_executable, node_script_path], | |
| 44 stdout=input_api.subprocess.PIPE, | |
| 45 stderr=input_api.subprocess.STDOUT) | |
| 46 out, _ = process.communicate() | |
| 47 if process.returncode != 0: | |
| 48 return [output_api.PresubmitError(out)] | |
| 49 return [output_api.PresubmitNotifyResult(out)] | |
| 50 | |
| 51 | |
| 40 def _CheckDevtoolsStyle(input_api, output_api): | 52 def _CheckDevtoolsStyle(input_api, output_api): |
| 41 local_paths = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f .Action() != "D"] | 53 local_paths = [f.AbsoluteLocalPath() for f in input_api.AffectedFiles() if f .Action() != "D"] |
| 42 | 54 |
| 43 devtools_root = input_api.PresubmitLocalPath() | 55 devtools_root = input_api.PresubmitLocalPath() |
| 44 devtools_front_end = input_api.os_path.join(devtools_root, "front_end") | 56 devtools_front_end = input_api.os_path.join(devtools_root, "front_end") |
| 45 affected_front_end_files = [file_name for file_name in local_paths if devtoo ls_front_end in file_name and file_name.endswith(".js")] | 57 affected_front_end_files = [file_name for file_name in local_paths if devtoo ls_front_end in file_name and file_name.endswith(".js")] |
| 46 affected_front_end_files = [input_api.os_path.relpath(file_name, devtools_ro ot) for file_name in affected_front_end_files] | 58 affected_front_end_files = [input_api.os_path.relpath(file_name, devtools_ro ot) for file_name in affected_front_end_files] |
| 47 if len(affected_front_end_files) > 0: | 59 if len(affected_front_end_files) > 0: |
| 48 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), | 60 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 49 "scripts", "lint_javascript.py") | 61 "scripts", "lint_javascript.py") |
| 50 process = input_api.subprocess.Popen( | 62 process = input_api.subprocess.Popen( |
| 51 [input_api.python_executable, lint_path] + affected_front_end_files, | 63 [input_api.python_executable, lint_path] + affected_front_end_files, |
| 52 stdout=input_api.subprocess.PIPE, | 64 stdout=input_api.subprocess.PIPE, |
| 53 stderr=input_api.subprocess.STDOUT) | 65 stderr=input_api.subprocess.STDOUT) |
| 54 out, _ = process.communicate() | 66 out, _ = process.communicate() |
| 55 if process.returncode != 0: | 67 if process.returncode != 0: |
| 56 return [output_api.PresubmitError(out)] | 68 return [output_api.PresubmitError(out)] |
| 57 if "NOTE" in out: | 69 return [output_api.PresubmitNotifyResult(out)] |
| 58 return [output_api.PresubmitNotifyResult(out)] | |
| 59 return [] | 70 return [] |
| 60 | 71 |
| 61 | 72 |
| 62 def _CompileDevtoolsFrontend(input_api, output_api): | 73 def _CompileDevtoolsFrontend(input_api, output_api): |
| 63 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] | 74 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] |
| 64 | 75 |
| 65 # FIXME: The compilation does not actually run if injected script-related fi les | 76 # FIXME: The compilation does not actually run if injected script-related fi les |
| 66 # have changed, as they reside in core/inspector, which is not affected | 77 # have changed, as they reside in core/inspector, which is not affected |
| 67 # by this presubmit. | 78 # by this presubmit. |
| 68 # Once this is fixed, injected_script_externs.js | 79 # Once this is fixed, injected_script_externs.js |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 for line_number, line in f.ChangedContents(): | 157 for line_number, line in f.ChangedContents(): |
| 147 if "/deep/" in line: | 158 if "/deep/" in line: |
| 148 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number))) | 159 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number))) |
| 149 if "::shadow" in line: | 160 if "::shadow" in line: |
| 150 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number))) | 161 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number))) |
| 151 return results | 162 return results |
| 152 | 163 |
| 153 | 164 |
| 154 def CheckChangeOnUpload(input_api, output_api): | 165 def CheckChangeOnUpload(input_api, output_api): |
| 155 results = [] | 166 results = [] |
| 167 results.extend(_CheckNodeAndNPMModules(input_api, output_api)) | |
| 156 results.extend(_CheckDevtoolsStyle(input_api, output_api)) | 168 results.extend(_CheckDevtoolsStyle(input_api, output_api)) |
| 157 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) | 169 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) |
| 158 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) | 170 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) |
| 159 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) | 171 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) |
| 160 results.extend(_CheckCSSViolations(input_api, output_api)) | 172 results.extend(_CheckCSSViolations(input_api, output_api)) |
| 161 return results | 173 return results |
| 162 | 174 |
| 163 | 175 |
| 164 def CheckChangeOnCommit(input_api, output_api): | 176 def CheckChangeOnCommit(input_api, output_api): |
| 165 return [] | 177 return [] |
| OLD | NEW |