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 sys | 12 import sys |
12 | 13 |
13 | 14 |
14 _EXCLUDED_PATHS = () | 15 _EXCLUDED_PATHS = () |
15 | 16 |
16 | 17 |
17 def _CheckForVersionControlConflictsInFile(input_api, f): | 18 def _CheckForVersionControlConflictsInFile(input_api, f): |
18 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') | 19 pattern = input_api.re.compile('^(?:<<<<<<<|>>>>>>>) |^=======$') |
19 errors = [] | 20 errors = [] |
20 for line_num, line in f.ChangedContents(): | 21 for line_num, line in f.ChangedContents(): |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if not errs: | 107 if not errs: |
107 return [output_api.PresubmitError( | 108 return [output_api.PresubmitError( |
108 "lint-test-expectations failed " | 109 "lint-test-expectations failed " |
109 "to produce output; check by hand. ")] | 110 "to produce output; check by hand. ")] |
110 if errs.strip() != 'Lint succeeded.': | 111 if errs.strip() != 'Lint succeeded.': |
111 return [output_api.PresubmitError(errs)] | 112 return [output_api.PresubmitError(errs)] |
112 return [] | 113 return [] |
113 | 114 |
114 | 115 |
115 def _CheckStyle(input_api, output_api): | 116 def _CheckStyle(input_api, output_api): |
| 117 # Files that follow Chromium's coding style do not include capital letters. |
| 118 re_chromium_style_file = re.compile(r'\b[a-z_]+\.(cc|h)$') |
116 style_checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), | 119 style_checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), |
117 'Tools', 'Scripts', 'check-webkit-style') | 120 'Tools', 'Scripts', 'check-webkit-style') |
118 args = ([input_api.python_executable, style_checker_path, '--diff-files'] | 121 args = ([input_api.python_executable, style_checker_path, '--diff-files'] |
119 + [input_api.os_path.join('..', '..', f.LocalPath()) | 122 + [input_api.os_path.join('..', '..', f.LocalPath()) |
120 for f in input_api.AffectedFiles()]) | 123 for f in input_api.AffectedFiles() |
| 124 # Filter out files that follow Chromium's coding style. |
| 125 if not re_chromium_style_file.search(f.LocalPath())]) |
121 results = [] | 126 results = [] |
122 | 127 |
123 try: | 128 try: |
124 child = input_api.subprocess.Popen(args, | 129 child = input_api.subprocess.Popen(args, |
125 stderr=input_api.subprocess.PIPE) | 130 stderr=input_api.subprocess.PIPE) |
126 _, stderrdata = child.communicate() | 131 _, stderrdata = child.communicate() |
127 if child.returncode != 0: | 132 if child.returncode != 0: |
128 results.append(output_api.PresubmitError( | 133 results.append(output_api.PresubmitError( |
129 'check-webkit-style failed', [stderrdata])) | 134 'check-webkit-style failed', [stderrdata])) |
130 except Exception as e: | 135 except Exception as e: |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 for master in masters: | 301 for master in masters: |
297 try_config.setdefault(master, {}) | 302 try_config.setdefault(master, {}) |
298 for builder in masters[master]: | 303 for builder in masters[master]: |
299 # Do not trigger presubmit builders, since they're likely to fail | 304 # Do not trigger presubmit builders, since they're likely to fail |
300 # (e.g. OWNERS checks before finished code review), and we're | 305 # (e.g. OWNERS checks before finished code review), and we're |
301 # running local presubmit anyway. | 306 # running local presubmit anyway. |
302 if 'presubmit' not in builder: | 307 if 'presubmit' not in builder: |
303 try_config[master][builder] = ['defaulttests'] | 308 try_config[master][builder] = ['defaulttests'] |
304 | 309 |
305 return try_config | 310 return try_config |
OLD | NEW |