Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: PRESUBMIT.py

Issue 2741733003: Reland of PyLint fixes for tools-webrtc and webrtc/tools (Closed)
Patch Set: Rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cleanup_links.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 1 # Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
2 # 2 #
3 # Use of this source code is governed by a BSD-style license 3 # Use of this source code is governed by a BSD-style license
4 # that can be found in the LICENSE file in the root of the source 4 # that can be found in the LICENSE file in the root of the source
5 # tree. An additional intellectual property rights grant can be found 5 # tree. An additional intellectual property rights grant can be found
6 # in the file PATENTS. All contributing project authors may 6 # in the file PATENTS. All contributing project authors may
7 # be found in the AUTHORS file in the root of the source tree. 7 # be found in the AUTHORS file in the root of the source tree.
8 8
9 import json 9 import json
10 import os 10 import os
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 if not os.path.isdir(path): 119 if not os.path.isdir(path):
120 non_existing_paths.append(path) 120 non_existing_paths.append(path)
121 if non_existing_paths: 121 if non_existing_paths:
122 return [output_api.PresubmitError( 122 return [output_api.PresubmitError(
123 'Directories to native API headers have changed which has made the ' 123 'Directories to native API headers have changed which has made the '
124 'list in PRESUBMIT.py outdated.\nPlease update it to the current ' 124 'list in PRESUBMIT.py outdated.\nPlease update it to the current '
125 'location of our native APIs.', 125 'location of our native APIs.',
126 non_existing_paths)] 126 non_existing_paths)]
127 return [] 127 return []
128 128
129 api_change_msg = """ 129 API_CHANGE_MSG = """
130 You seem to be changing native API header files. Please make sure that you: 130 You seem to be changing native API header files. Please make sure that you:
131 1. Make compatible changes that don't break existing clients. Usually 131 1. Make compatible changes that don't break existing clients. Usually
132 this is done by keeping the existing method signatures unchanged. 132 this is done by keeping the existing method signatures unchanged.
133 2. Mark the old stuff as deprecated (see RTC_DEPRECATED macro). 133 2. Mark the old stuff as deprecated (see RTC_DEPRECATED macro).
134 3. Create a timeline and plan for when the deprecated stuff will be 134 3. Create a timeline and plan for when the deprecated stuff will be
135 removed. (The amount of time we give users to change their code 135 removed. (The amount of time we give users to change their code
136 should be informed by how much work it is for them. If they just 136 should be informed by how much work it is for them. If they just
137 need to replace one name with another or something equally 137 need to replace one name with another or something equally
138 simple, 1-2 weeks might be good; if they need to do serious work, 138 simple, 1-2 weeks might be good; if they need to do serious work,
139 up to 3 months may be called for.) 139 up to 3 months may be called for.)
140 4. Update/inform existing downstream code owners to stop using the 140 4. Update/inform existing downstream code owners to stop using the
141 deprecated stuff. (Send announcements to 141 deprecated stuff. (Send announcements to
142 discuss-webrtc@googlegroups.com and webrtc-users@google.com.) 142 discuss-webrtc@googlegroups.com and webrtc-users@google.com.)
143 5. Remove the deprecated stuff, once the agreed-upon amount of time 143 5. Remove the deprecated stuff, once the agreed-upon amount of time
144 has passed. 144 has passed.
145 Related files: 145 Related files:
146 """ 146 """
147 147
148 def _CheckNativeApiHeaderChanges(input_api, output_api): 148 def _CheckNativeApiHeaderChanges(input_api, output_api):
149 """Checks to remind proper changing of native APIs.""" 149 """Checks to remind proper changing of native APIs."""
150 files = [] 150 files = []
151 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 151 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
152 if f.LocalPath().endswith('.h'): 152 if f.LocalPath().endswith('.h'):
153 for path in API_DIRS: 153 for path in API_DIRS:
154 if os.path.dirname(f.LocalPath()) == path: 154 if os.path.dirname(f.LocalPath()) == path:
155 files.append(f) 155 files.append(f)
156 156
157 if files: 157 if files:
158 return [output_api.PresubmitNotifyResult(api_change_msg, files)] 158 return [output_api.PresubmitNotifyResult(API_CHANGE_MSG, files)]
159 return [] 159 return []
160 160
161 161
162 def _CheckNoIOStreamInHeaders(input_api, output_api): 162 def _CheckNoIOStreamInHeaders(input_api, output_api):
163 """Checks to make sure no .h files include <iostream>.""" 163 """Checks to make sure no .h files include <iostream>."""
164 files = [] 164 files = []
165 pattern = input_api.re.compile(r'^#include\s*<iostream>', 165 pattern = input_api.re.compile(r'^#include\s*<iostream>',
166 input_api.re.MULTILINE) 166 input_api.re.MULTILINE)
167 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile): 167 for f in input_api.AffectedSourceFiles(input_api.FilterSourceFile):
168 if not f.LocalPath().endswith('.h'): 168 if not f.LocalPath().endswith('.h'):
(...skipping 24 matching lines...) Expand all
193 files.append(f) 193 files.append(f)
194 194
195 if files: 195 if files:
196 return [output_api.PresubmitError( 196 return [output_api.PresubmitError(
197 'Do not use #pragma once in header files.\n' 197 'Do not use #pragma once in header files.\n'
198 'See http://www.chromium.org/developers/coding-style#TOC-File-headers', 198 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
199 files)] 199 files)]
200 return [] 200 return []
201 201
202 202
203 def _CheckNoFRIEND_TEST(input_api, output_api): 203 def _CheckNoFRIEND_TEST(input_api, output_api): # pylint: disable=invalid-name
204 """Make sure that gtest's FRIEND_TEST() macro is not used, the 204 """Make sure that gtest's FRIEND_TEST() macro is not used, the
205 FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be 205 FRIEND_TEST_ALL_PREFIXES() macro from testsupport/gtest_prod_util.h should be
206 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes.""" 206 used instead since that allows for FLAKY_, FAILS_ and DISABLED_ prefixes."""
207 problems = [] 207 problems = []
208 208
209 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h')) 209 file_filter = lambda f: f.LocalPath().endswith(('.cc', '.h'))
210 for f in input_api.AffectedFiles(file_filter=file_filter): 210 for f in input_api.AffectedFiles(file_filter=file_filter):
211 for line_num, line in f.ChangedContents(): 211 for line_num, line in f.ChangedContents():
212 if 'FRIEND_TEST(' in line: 212 if 'FRIEND_TEST(' in line:
213 problems.append(' %s:%d' % (f.LocalPath(), line_num)) 213 problems.append(' %s:%d' % (f.LocalPath(), line_num))
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 file_filter=FilterFile, include_deletes=False): 459 file_filter=FilterFile, include_deletes=False):
460 parse_error = GetJSONParseError(input_api, 460 parse_error = GetJSONParseError(input_api,
461 affected_file.AbsoluteLocalPath()) 461 affected_file.AbsoluteLocalPath())
462 if parse_error: 462 if parse_error:
463 results.append(output_api.PresubmitError('%s could not be parsed: %s' % 463 results.append(output_api.PresubmitError('%s could not be parsed: %s' %
464 (affected_file.LocalPath(), parse_error))) 464 (affected_file.LocalPath(), parse_error)))
465 return results 465 return results
466 466
467 467
468 def _RunPythonTests(input_api, output_api): 468 def _RunPythonTests(input_api, output_api):
469 def join(*args): 469 def Join(*args):
470 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) 470 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
471 471
472 test_directories = [ 472 test_directories = [
473 join('webrtc', 'tools', 'py_event_log_analyzer') 473 Join('webrtc', 'tools', 'py_event_log_analyzer')
474 ] + [ 474 ] + [
475 root for root, _, files in os.walk(join('tools-webrtc')) 475 root for root, _, files in os.walk(Join('tools-webrtc'))
476 if any(f.endswith('_test.py') for f in files) 476 if any(f.endswith('_test.py') for f in files)
477 ] 477 ]
478 478
479 tests = [] 479 tests = []
480 for directory in test_directories: 480 for directory in test_directories:
481 tests.extend( 481 tests.extend(
482 input_api.canned_checks.GetUnitTestsInDirectory( 482 input_api.canned_checks.GetUnitTestsInDirectory(
483 input_api, 483 input_api,
484 output_api, 484 output_api,
485 directory, 485 directory,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 input_api, output_api)) 575 input_api, output_api))
576 results.extend(input_api.canned_checks.CheckChangeHasDescription( 576 results.extend(input_api.canned_checks.CheckChangeHasDescription(
577 input_api, output_api)) 577 input_api, output_api))
578 results.extend(_CheckChangeHasBugField(input_api, output_api)) 578 results.extend(_CheckChangeHasBugField(input_api, output_api))
579 results.extend(input_api.canned_checks.CheckChangeHasTestField( 579 results.extend(input_api.canned_checks.CheckChangeHasTestField(
580 input_api, output_api)) 580 input_api, output_api))
581 results.extend(input_api.canned_checks.CheckTreeIsOpen( 581 results.extend(input_api.canned_checks.CheckTreeIsOpen(
582 input_api, output_api, 582 input_api, output_api,
583 json_url='http://webrtc-status.appspot.com/current?format=json')) 583 json_url='http://webrtc-status.appspot.com/current?format=json'))
584 return results 584 return results
OLDNEW
« no previous file with comments | « no previous file | cleanup_links.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698