Chromium Code Reviews| 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 21 matching lines...) Expand all Loading... | |
| 32 errors.append(' %s:%d %s' % ( | 32 errors.append(' %s:%d %s' % ( |
| 33 f.LocalPath(), line_num, line)) | 33 f.LocalPath(), line_num, line)) |
| 34 | 34 |
| 35 results = [] | 35 results = [] |
| 36 if errors: | 36 if errors: |
| 37 results.append(output_api.PresubmitError( | 37 results.append(output_api.PresubmitError( |
| 38 'Files that include non-Blink variant mojoms found:', errors)) | 38 'Files that include non-Blink variant mojoms found:', errors)) |
| 39 return results | 39 return results |
| 40 | 40 |
| 41 | 41 |
| 42 def _CheckForVersionControlConflictsInFile(input_api, f): | |
| 43 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') | |
| 44 errors = [] | |
| 45 for line_num, line in f.ChangedContents(): | |
| 46 if pattern.match(line): | |
| 47 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) | |
| 48 return errors | |
| 49 | |
| 50 | |
| 51 def _CheckForVersionControlConflicts(input_api, output_api): | |
| 52 """Usually this is not intentional and will cause a compile failure.""" | |
| 53 errors = [] | |
| 54 for f in input_api.AffectedFiles(): | |
| 55 errors.extend(_CheckForVersionControlConflictsInFile(input_api, f)) | |
| 56 | |
| 57 results = [] | |
| 58 if errors: | |
| 59 results.append(output_api.PresubmitError( | |
| 60 'Version control conflict markers found, please resolve.', errors)) | |
| 61 return results | |
| 62 | |
| 63 | |
| 64 def _CheckWatchlist(input_api, output_api): | 42 def _CheckWatchlist(input_api, output_api): |
| 65 """Check that the WATCHLIST file parses correctly.""" | 43 """Check that the WATCHLIST file parses correctly.""" |
| 66 errors = [] | 44 errors = [] |
| 67 for f in input_api.AffectedFiles(): | 45 for f in input_api.AffectedFiles(): |
| 68 if f.LocalPath() != 'WATCHLISTS': | 46 if f.LocalPath() != 'WATCHLISTS': |
| 69 continue | 47 continue |
| 70 import StringIO | 48 import StringIO |
| 71 import logging | 49 import logging |
| 72 import watchlists | 50 import watchlists |
| 73 | 51 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 94 def _CommonChecks(input_api, output_api): | 72 def _CommonChecks(input_api, output_api): |
| 95 """Checks common to both upload and commit.""" | 73 """Checks common to both upload and commit.""" |
| 96 # We should figure out what license checks we actually want to use. | 74 # We should figure out what license checks we actually want to use. |
| 97 license_header = r'.*' | 75 license_header = r'.*' |
| 98 | 76 |
| 99 results = [] | 77 results = [] |
| 100 results.extend(input_api.canned_checks.PanProjectChecks( | 78 results.extend(input_api.canned_checks.PanProjectChecks( |
| 101 input_api, output_api, excluded_paths=_EXCLUDED_PATHS, | 79 input_api, output_api, excluded_paths=_EXCLUDED_PATHS, |
| 102 maxlen=800, license_header=license_header)) | 80 maxlen=800, license_header=license_header)) |
| 103 results.extend(_CheckForNonBlinkVariantMojomIncludes(input_api, output_api)) | 81 results.extend(_CheckForNonBlinkVariantMojomIncludes(input_api, output_api)) |
| 104 results.extend(_CheckForVersionControlConflicts(input_api, output_api)) | |
| 105 results.extend(_CheckPatchFiles(input_api, output_api)) | |
| 106 results.extend(_CheckTestExpectations(input_api, output_api)) | 82 results.extend(_CheckTestExpectations(input_api, output_api)) |
| 107 results.extend(_CheckChromiumPlatformMacros(input_api, output_api)) | 83 results.extend(_CheckChromiumPlatformMacros(input_api, output_api)) |
| 108 results.extend(_CheckWatchlist(input_api, output_api)) | 84 results.extend(_CheckWatchlist(input_api, output_api)) |
| 109 results.extend(_CheckFilePermissions(input_api, output_api)) | |
| 110 return results | 85 return results |
| 111 | 86 |
| 112 | 87 |
| 113 def _CheckPatchFiles(input_api, output_api): | |
| 114 problems = [f.LocalPath() for f in input_api.AffectedFiles() | |
| 115 if f.LocalPath().endswith(('.orig', '.rej'))] | |
| 116 if problems: | |
| 117 return [output_api.PresubmitError( | |
| 118 "Don't commit .rej and .orig files.", problems)] | |
|
Nico
2017/03/23 12:55:58
This feels like a remnant from svn days anyhow – w
| |
| 119 else: | |
| 120 return [] | |
| 121 | |
| 122 | |
| 123 def _CheckTestExpectations(input_api, output_api): | 88 def _CheckTestExpectations(input_api, output_api): |
| 124 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] | 89 local_paths = [f.LocalPath() for f in input_api.AffectedFiles()] |
| 125 if any('LayoutTests' in path for path in local_paths): | 90 if any('LayoutTests' in path for path in local_paths): |
| 126 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), | 91 lint_path = input_api.os_path.join(input_api.PresubmitLocalPath(), |
| 127 'Tools', 'Scripts', 'lint-test-expectations') | 92 'Tools', 'Scripts', 'lint-test-expectations') |
| 128 _, errs = input_api.subprocess.Popen( | 93 _, errs = input_api.subprocess.Popen( |
| 129 [input_api.python_executable, lint_path], | 94 [input_api.python_executable, lint_path], |
| 130 stdout=input_api.subprocess.PIPE, | 95 stdout=input_api.subprocess.PIPE, |
| 131 stderr=input_api.subprocess.PIPE).communicate() | 96 stderr=input_api.subprocess.PIPE).communicate() |
| 132 if not errs: | 97 if not errs: |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 | 189 |
| 225 def _CheckForFailInFile(input_api, f): | 190 def _CheckForFailInFile(input_api, f): |
| 226 pattern = input_api.re.compile('^FAIL') | 191 pattern = input_api.re.compile('^FAIL') |
| 227 errors = [] | 192 errors = [] |
| 228 for line_num, line in f.ChangedContents(): | 193 for line_num, line in f.ChangedContents(): |
| 229 if pattern.match(line): | 194 if pattern.match(line): |
| 230 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) | 195 errors.append(' %s:%d %s' % (f.LocalPath(), line_num, line)) |
| 231 return errors | 196 return errors |
| 232 | 197 |
| 233 | 198 |
| 234 def _CheckFilePermissions(input_api, output_api): | |
| 235 """Check that all files have their permissions properly set.""" | |
| 236 if input_api.platform == 'win32': | |
| 237 return [] | |
| 238 args = [input_api.python_executable, | |
| 239 input_api.os_path.join( | |
| 240 input_api.change.RepositoryRoot(), | |
| 241 'tools/checkperms/checkperms.py'), | |
| 242 '--root', input_api.change.RepositoryRoot()] | |
| 243 for f in input_api.AffectedFiles(): | |
| 244 args += ['--file', f.LocalPath()] | |
| 245 try: | |
| 246 input_api.subprocess.check_output(args) | |
| 247 return [] | |
| 248 except input_api.subprocess.CalledProcessError as error: | |
| 249 return [output_api.PresubmitError( | |
| 250 'checkperms.py failed:', | |
| 251 long_text=error.output)] | |
| 252 | |
| 253 | |
| 254 def _CheckForInvalidPreferenceError(input_api, output_api): | 199 def _CheckForInvalidPreferenceError(input_api, output_api): |
| 255 pattern = input_api.re.compile('Invalid name for preference: (.+)') | 200 pattern = input_api.re.compile('Invalid name for preference: (.+)') |
| 256 results = [] | 201 results = [] |
| 257 | 202 |
| 258 for f in input_api.AffectedFiles(): | 203 for f in input_api.AffectedFiles(): |
| 259 if not f.LocalPath().endswith('-expected.txt'): | 204 if not f.LocalPath().endswith('-expected.txt'): |
| 260 continue | 205 continue |
| 261 for line_num, line in f.ChangedContents(): | 206 for line_num, line in f.ChangedContents(): |
| 262 error = pattern.search(line) | 207 error = pattern.search(line) |
| 263 if error: | 208 if error: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 more information about slimming-paint-v2 tests see https://crbug.com/601275. | 306 more information about slimming-paint-v2 tests see https://crbug.com/601275. |
| 362 """ | 307 """ |
| 363 if not _ArePaintOrCompositingDirectoriesModified(change): | 308 if not _ArePaintOrCompositingDirectoriesModified(change): |
| 364 return [] | 309 return [] |
| 365 return output_api.EnsureCQIncludeTrybotsAreAdded( | 310 return output_api.EnsureCQIncludeTrybotsAreAdded( |
| 366 cl, | 311 cl, |
| 367 ['master.tryserver.chromium.linux:' | 312 ['master.tryserver.chromium.linux:' |
| 368 'linux_layout_tests_slimming_paint_v2'], | 313 'linux_layout_tests_slimming_paint_v2'], |
| 369 'Automatically added slimming-paint-v2 tests to run on CQ due to ' | 314 'Automatically added slimming-paint-v2 tests to run on CQ due to ' |
| 370 'changes in paint or compositing directories.') | 315 'changes in paint or compositing directories.') |
| OLD | NEW |