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 18 matching lines...) Expand all Loading... | |
| 29 """DevTools JSDoc validator presubmit script | 29 """DevTools JSDoc validator presubmit script |
| 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 | |
| 40 def _CheckDevtoolsStyle(input_api, output_api): | |
| 41 local_paths = [f.LocalPath() for f in input_api.AffectedFiles() if f.Action( ) != "D"] | |
| 42 | |
| 43 devtools_front_end = input_api.os_path.join("devtools", "front_end") | |
| 44 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")] | |
| 45 affected_front_end_files = [input_api.os_path.join("front_end", file_name.sp lit(devtools_front_end).pop()[1:]) for file_name in affected_front_end_files] | |
|
dgozman
2016/05/20 21:12:59
input_api.os_path.relpath
lushnikov
2016/05/20 21:49:26
Done.
| |
| 46 if len(affected_front_end_files) > 0: | |
| 47 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), | |
| 48 "scripts", "lint_javascript.py") | |
| 49 process = input_api.subprocess.Popen( | |
| 50 [input_api.python_executable, lint_path] + affected_front_end_files, | |
| 51 stdout=input_api.subprocess.PIPE, | |
| 52 stderr=input_api.subprocess.STDOUT) | |
| 53 out, _ = process.communicate() | |
| 54 if process.returncode != 0: | |
| 55 return [output_api.PresubmitError(out)] | |
| 56 if "NOTE" in out: | |
| 57 return [output_api.PresubmitPromptWarning(out)] | |
| 58 return [] | |
| 59 | |
| 60 | |
| 39 def _CompileDevtoolsFrontend(input_api, output_api): | 61 def _CompileDevtoolsFrontend(input_api, output_api): |
| 40 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] | 62 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] |
| 41 | 63 |
| 42 # FIXME: The compilation does not actually run if injected script-related fi les | 64 # FIXME: The compilation does not actually run if injected script-related fi les |
| 43 # have changed, as they reside in core/inspector, which is not affected | 65 # have changed, as they reside in core/inspector, which is not affected |
| 44 # by this presubmit. | 66 # by this presubmit. |
| 45 # Once this is fixed, injected_script_externs.js | 67 # Once this is fixed, injected_script_externs.js |
| 46 # should be added to the list of triggers. | 68 # should be added to the list of triggers. |
| 47 devtools_front_end = input_api.os_path.join("devtools", "front_end") | 69 devtools_front_end = input_api.os_path.join("devtools", "front_end") |
| 48 if (any(devtools_front_end in path for path in local_paths) or | 70 if (any(devtools_front_end in path for path in local_paths) or |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 for line_number, line in f.ChangedContents(): | 144 for line_number, line in f.ChangedContents(): |
| 123 if "/deep/" in line: | 145 if "/deep/" in line: |
| 124 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number))) | 146 results.append(output_api.PresubmitError(("%s:%d uses /deep/ sel ector") % (f.LocalPath(), line_number))) |
| 125 if "::shadow" in line: | 147 if "::shadow" in line: |
| 126 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number))) | 148 results.append(output_api.PresubmitError(("%s:%d uses ::shadow s elector") % (f.LocalPath(), line_number))) |
| 127 return results | 149 return results |
| 128 | 150 |
| 129 | 151 |
| 130 def CheckChangeOnUpload(input_api, output_api): | 152 def CheckChangeOnUpload(input_api, output_api): |
| 131 results = [] | 153 results = [] |
| 154 results.extend(_CheckDevtoolsStyle(input_api, output_api)) | |
| 132 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) | 155 results.extend(_CompileDevtoolsFrontend(input_api, output_api)) |
| 133 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) | 156 results.extend(_CheckConvertSVGToPNGHashes(input_api, output_api)) |
| 134 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) | 157 results.extend(_CheckOptimizePNGHashes(input_api, output_api)) |
| 135 results.extend(_CheckCSSViolations(input_api, output_api)) | 158 results.extend(_CheckCSSViolations(input_api, output_api)) |
| 136 return results | 159 return results |
| 137 | 160 |
| 138 | 161 |
| 139 def CheckChangeOnCommit(input_api, output_api): | 162 def CheckChangeOnCommit(input_api, output_api): |
| 140 return [] | 163 return [] |
| OLD | NEW |