| 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 |
| 11 import re | 11 import re |
| 12 import sys | 12 import sys |
| 13 | 13 |
| 14 | 14 |
| 15 _EXCLUDED_PATHS = () | 15 _EXCLUDED_PATHS = () |
| 16 | 16 |
| 17 | 17 |
| 18 def _CheckForNonBlinkVariantMojomIncludes(input_api, output_api): |
| 19 pattern = input_api.re.compile(r'#include\s+.+\.mojom(.*)\.h[>"]') |
| 20 errors = [] |
| 21 for f in input_api.AffectedFiles(): |
| 22 for line_num, line in f.ChangedContents(): |
| 23 m = pattern.match(line) |
| 24 if m and m.group(1) != '-blink': |
| 25 errors.append(' %s:%d %s' % ( |
| 26 f.LocalPath(), line_num, line)) |
| 27 |
| 28 results = [] |
| 29 if errors: |
| 30 results.append(output_api.PresubmitError( |
| 31 'Files that include non-Blink variant mojoms found:', errors)) |
| 32 return results |
| 33 |
| 34 |
| 18 def _CheckForVersionControlConflictsInFile(input_api, f): | 35 def _CheckForVersionControlConflictsInFile(input_api, f): |
| 19 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') | 36 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') |
| 20 errors = [] | 37 errors = [] |
| 21 for line_num, line in f.ChangedContents(): | 38 for line_num, line in f.ChangedContents(): |
| 22 if pattern.match(line): | 39 if pattern.match(line): |
| 23 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) | 40 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) |
| 24 return errors | 41 return errors |
| 25 | 42 |
| 26 | 43 |
| 27 def _CheckForVersionControlConflicts(input_api, output_api): | 44 def _CheckForVersionControlConflicts(input_api, output_api): |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 86 |
| 70 def _CommonChecks(input_api, output_api): | 87 def _CommonChecks(input_api, output_api): |
| 71 """Checks common to both upload and commit.""" | 88 """Checks common to both upload and commit.""" |
| 72 # We should figure out what license checks we actually want to use. | 89 # We should figure out what license checks we actually want to use. |
| 73 license_header = r'.*' | 90 license_header = r'.*' |
| 74 | 91 |
| 75 results = [] | 92 results = [] |
| 76 results.extend(input_api.canned_checks.PanProjectChecks( | 93 results.extend(input_api.canned_checks.PanProjectChecks( |
| 77 input_api, output_api, excluded_paths=_EXCLUDED_PATHS, | 94 input_api, output_api, excluded_paths=_EXCLUDED_PATHS, |
| 78 maxlen=800, license_header=license_header)) | 95 maxlen=800, license_header=license_header)) |
| 96 results.extend(_CheckForNonBlinkVariantMojomIncludes(input_api, output_api)) |
| 79 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) | 97 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) |
| 80 results.extend(_CheckPatchFiles(input_api, output_api)) | 98 results.extend(_CheckPatchFiles(input_api, output_api)) |
| 81 results.extend(_CheckTestExpectations(input_api, output_api)) | 99 results.extend(_CheckTestExpectations(input_api, output_api)) |
| 82 results.extend(_CheckChromiumPlatformMacros(input_api, output_api)) | 100 results.extend(_CheckChromiumPlatformMacros(input_api, output_api)) |
| 83 results.extend(_CheckWatchlist(input_api, output_api)) | 101 results.extend(_CheckWatchlist(input_api, output_api)) |
| 84 results.extend(_CheckFilePermissions(input_api, output_api)) | 102 results.extend(_CheckFilePermissions(input_api, output_api)) |
| 85 return results | 103 return results |
| 86 | 104 |
| 87 | 105 |
| 88 def _CheckPatchFiles(input_api, output_api): | 106 def _CheckPatchFiles(input_api, output_api): |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 for master in masters: | 300 for master in masters: |
| 283 try_config.setdefault(master, {}) | 301 try_config.setdefault(master, {}) |
| 284 for builder in masters[master]: | 302 for builder in masters[master]: |
| 285 # Do not trigger presubmit builders, since they're likely to fail | 303 # Do not trigger presubmit builders, since they're likely to fail |
| 286 # (e.g. OWNERS checks before finished code review), and we're | 304 # (e.g. OWNERS checks before finished code review), and we're |
| 287 # running local presubmit anyway. | 305 # running local presubmit anyway. |
| 288 if 'presubmit' not in builder: | 306 if 'presubmit' not in builder: |
| 289 try_config[master][builder] = ['defaulttests'] | 307 try_config[master][builder] = ['defaulttests'] |
| 290 | 308 |
| 291 return try_config | 309 return try_config |
| OLD | NEW |