| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Top-level presubmit script for Blink. | 5 """Top-level presubmit script for Blink. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 input_api, None) | 181 input_api, None) |
| 182 errors = [' * %s' % violation for violation in errors] | 182 errors = [' * %s' % violation for violation in errors] |
| 183 if errors: | 183 if errors: |
| 184 return [output_api.PresubmitPromptOrNotify( | 184 return [output_api.PresubmitPromptOrNotify( |
| 185 'printf debugging is best debugging! That said, it might ' | 185 'printf debugging is best debugging! That said, it might ' |
| 186 'be a good idea to drop the following occurances from ' | 186 'be a good idea to drop the following occurances from ' |
| 187 'your patch before uploading:\n%s' % '\n'.join(errors))] | 187 'your patch before uploading:\n%s' % '\n'.join(errors))] |
| 188 return [] | 188 return [] |
| 189 | 189 |
| 190 | 190 |
| 191 def _CheckForJSTest(input_api, output_api): |
| 192 """'js-test.js' is the past, 'testharness.js' is our glorious future""" |
| 193 jstest_re = input_api.re.compile(r'resources/js-test.js') |
| 194 |
| 195 def source_file_filter(path): |
| 196 return input_api.FilterSourceFile(path, |
| 197 white_list=[r'third_party/WebKit/Layou
tTests/.*\.(html|js|php|pl|svg)$']) |
| 198 |
| 199 errors = input_api.canned_checks._FindNewViolationsOfRule( |
| 200 lambda _, x: not jstest_re.search(x), input_api, source_file_filter) |
| 201 errors = [' * %s' % violation for violation in errors] |
| 202 if errors: |
| 203 return [output_api.PresubmitPromptOrNotify( |
| 204 '"resources/js-test.js" is deprecated; please write new layout ' |
| 205 'tests using the assertions in "resources/testharness.js" ' |
| 206 'instead, as these can be more easily upstreamed to Web Platform ' |
| 207 'Tests for cross-vendor compatibility testing. If you\'re not ' |
| 208 'already familiar with this framework, a tutorial is available at ' |
| 209 'https://darobin.github.io/test-harness-tutorial/docs/using-testharn
ess.html.' |
| 210 'with the new framework.\n\n%s' % '\n'.join(errors))] |
| 211 return [] |
| 212 |
| 191 def _CheckForFailInFile(input_api, f): | 213 def _CheckForFailInFile(input_api, f): |
| 192 pattern = input_api.re.compile('^FAIL') | 214 pattern = input_api.re.compile('^FAIL') |
| 193 errors = [] | 215 errors = [] |
| 194 for line_num, line in f.ChangedContents(): | 216 for line_num, line in f.ChangedContents(): |
| 195 if pattern.match(line): | 217 if pattern.match(line): |
| 196 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) | 218 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) |
| 197 return errors | 219 return errors |
| 198 | 220 |
| 199 | 221 |
| 200 def _CheckFilePermissions(input_api, output_api): | 222 def _CheckFilePermissions(input_api, output_api): |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 if errors: | 298 if errors: |
| 277 result += [output_api.PresubmitError('Do not use Chromium class {} i
nside Blink core:\n{}'.format(class_name, '\n'.join(errors)))] | 299 result += [output_api.PresubmitError('Do not use Chromium class {} i
nside Blink core:\n{}'.format(class_name, '\n'.join(errors)))] |
| 278 return result | 300 return result |
| 279 | 301 |
| 280 | 302 |
| 281 def CheckChangeOnUpload(input_api, output_api): | 303 def CheckChangeOnUpload(input_api, output_api): |
| 282 results = [] | 304 results = [] |
| 283 results.extend(_CommonChecks(input_api, output_api)) | 305 results.extend(_CommonChecks(input_api, output_api)) |
| 284 results.extend(_CheckStyle(input_api, output_api)) | 306 results.extend(_CheckStyle(input_api, output_api)) |
| 285 results.extend(_CheckForPrintfDebugging(input_api, output_api)) | 307 results.extend(_CheckForPrintfDebugging(input_api, output_api)) |
| 308 results.extend(_CheckForJSTest(input_api, output_api)) |
| 286 results.extend(_CheckForInvalidPreferenceError(input_api, output_api)) | 309 results.extend(_CheckForInvalidPreferenceError(input_api, output_api)) |
| 287 results.extend(_CheckForForbiddenNamespace(input_api, output_api)) | 310 results.extend(_CheckForForbiddenNamespace(input_api, output_api)) |
| 288 return results | 311 return results |
| 289 | 312 |
| 290 | 313 |
| 291 def CheckChangeOnCommit(input_api, output_api): | 314 def CheckChangeOnCommit(input_api, output_api): |
| 292 results = [] | 315 results = [] |
| 293 results.extend(_CommonChecks(input_api, output_api)) | 316 results.extend(_CommonChecks(input_api, output_api)) |
| 294 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 317 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 295 input_api, output_api, | 318 input_api, output_api, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 317 for master in masters: | 340 for master in masters: |
| 318 try_config.setdefault(master, {}) | 341 try_config.setdefault(master, {}) |
| 319 for builder in masters[master]: | 342 for builder in masters[master]: |
| 320 # Do not trigger presubmit builders, since they're likely to fail | 343 # Do not trigger presubmit builders, since they're likely to fail |
| 321 # (e.g. OWNERS checks before finished code review), and we're | 344 # (e.g. OWNERS checks before finished code review), and we're |
| 322 # running local presubmit anyway. | 345 # running local presubmit anyway. |
| 323 if 'presubmit' not in builder: | 346 if 'presubmit' not in builder: |
| 324 try_config[master][builder] = ['defaulttests'] | 347 try_config[master][builder] = ['defaulttests'] |
| 325 | 348 |
| 326 return try_config | 349 return try_config |
| OLD | NEW |