diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-23 14:27:46 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-23 14:27:46 +0000 |
commit | de4f7d2273c0605bef5d58c838cebc974a0f57bb (patch) | |
tree | 274964cc2ab8f8f25e8a8d9fc9f8570ba2b79013 /PRESUBMIT.py | |
parent | 5f4ae9c1f8f2b9263cbc68a2e451ff6c13f8296c (diff) | |
download | chromium_src-de4f7d2273c0605bef5d58c838cebc974a0f57bb.zip chromium_src-de4f7d2273c0605bef5d58c838cebc974a0f57bb.tar.gz chromium_src-de4f7d2273c0605bef5d58c838cebc974a0f57bb.tar.bz2 |
Ignore hardcoded URLs and ForTest(ing)/for_test(ing) in comments.
This addresses a couple of bug reports I've received on these
presubmit checks. I also fixed how reviewers_plus_owner is created in
_CheckAddedDepsHaveTargetApprovals based on comments on a previous
patch.
BUG=None
Review URL: https://chromiumcodereview.appspot.com/15755002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201792 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT.py')
-rw-r--r-- | PRESUBMIT.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 1253c4a0..cb12d34c 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -231,6 +231,7 @@ def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): base_function_pattern = r'ForTest(ing)?|for_test(ing)?' inclusion_pattern = input_api.re.compile(r'(%s)\s*\(' % base_function_pattern) + comment_pattern = input_api.re.compile(r'//.*%s' % base_function_pattern) exclusion_pattern = input_api.re.compile( r'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % ( base_function_pattern, base_function_pattern)) @@ -251,6 +252,7 @@ def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): line_number = 0 for line in lines: if (inclusion_pattern.search(line) and + not comment_pattern.search(line) and not exclusion_pattern.search(line)): problems.append( '%s:%d\n %s' % (local_path, line_number, line.strip())) @@ -688,11 +690,13 @@ def _CheckHardcodedGoogleHostsInLowerLayers(input_api, output_api): _TEST_CODE_EXCLUDED_PATHS + input_api.DEFAULT_BLACK_LIST)) - pattern = input_api.re.compile('"[^"]*google\.com[^"]*"') + base_pattern = '"[^"]*google\.com[^"]*"' + comment_pattern = input_api.re.compile('//.*%s' % base_pattern) + pattern = input_api.re.compile(base_pattern) problems = [] # items are (filename, line_number, line) for f in input_api.AffectedSourceFiles(FilterFile): for line_num, line in f.ChangedContents(): - if pattern.search(line): + if not comment_pattern.search(line) and pattern.search(line): problems.append((f.LocalPath(), line_num, line)) if problems: @@ -774,9 +778,9 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api): owner_email = owner_email or input_api.change.author_email - reviewers_plus_owner = reviewers + reviewers_plus_owner = set(reviewers) if owner_email: - reviewers_plus_owner = set([owner_email]).union(reviewers) + reviewers_plus_owner.add(owner_email) missing_files = owners_db.files_not_covered_by(virtual_depended_on_files, reviewers_plus_owner) unapproved_dependencies = ["'+%s'," % path[:-len('/DEPS')] |