Chromium Code Reviews| OLD | NEW | 
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 Chromium. | 5 """Top-level presubmit script for Chromium. | 
| 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 | 11 | 
| 12 import re | 12 import re | 
| 
 
M-A Ruel
2014/01/29 21:28:19
Remove
 
adamk
2014/01/29 21:39:54
This and the other re comments below seem like the
 
 | |
| 13 import subprocess | 13 import subprocess | 
| 
 
M-A Ruel
2014/01/29 21:28:19
Remove
 
adamk
2014/01/29 21:39:54
See below, I don't think check_output does what I
 
 | |
| 14 import sys | 14 import sys | 
| 15 | 15 | 
| 16 | 16 | 
| 17 _EXCLUDED_PATHS = ( | 17 _EXCLUDED_PATHS = ( | 
| 18 r"^breakpad[\\\/].*", | 18 r"^breakpad[\\\/].*", | 
| 19 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py", | 19 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py", | 
| 20 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py", | 20 r"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py", | 
| 21 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk", | 21 r"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk", | 
| 22 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*", | 22 r"^net[\\\/]tools[\\\/]spdyshark[\\\/].*", | 
| 23 r"^skia[\\\/].*", | 23 r"^skia[\\\/].*", | 
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 519 warning_descriptions)) | 519 warning_descriptions)) | 
| 520 return results | 520 return results | 
| 521 | 521 | 
| 522 | 522 | 
| 523 def _CheckFilePermissions(input_api, output_api): | 523 def _CheckFilePermissions(input_api, output_api): | 
| 524 """Check that all files have their permissions properly set.""" | 524 """Check that all files have their permissions properly set.""" | 
| 525 args = [sys.executable, 'tools/checkperms/checkperms.py', '--root', | 525 args = [sys.executable, 'tools/checkperms/checkperms.py', '--root', | 
| 526 input_api.change.RepositoryRoot()] | 526 input_api.change.RepositoryRoot()] | 
| 527 for f in input_api.AffectedFiles(): | 527 for f in input_api.AffectedFiles(): | 
| 528 args += ['--file', f.LocalPath()] | 528 args += ['--file', f.LocalPath()] | 
| 529 errors = [] | 529 checkperms = subprocess.Popen(args, stdout=subprocess.PIPE) | 
| 
 
M-A Ruel
2014/01/29 21:28:19
What you want is
errors = input_api.subprocess.che
 
adamk
2014/01/29 21:39:54
Not sure what you mean by "normally", but it retur
 
M-A Ruel
2014/01/29 21:47:05
Normally would be in absence of catastrophic failu
 
adamk
2014/01/29 21:52:54
Ok, will do, but note that I didn't add this refer
 
 | |
| 530 (errors, stderrdata) = subprocess.Popen(args).communicate() | 530 errors = checkperms.communicate()[0].strip() | 
| 531 | |
| 532 results = [] | |
| 533 if errors: | 531 if errors: | 
| 534 results.append(output_api.PresubmitError('checkperms.py failed.', | 532 return [output_api.PresubmitError('checkperms.py failed.', | 
| 535 errors)) | 533 errors.splitlines())] | 
| 536 return results | 534 return [] | 
| 537 | 535 | 
| 538 | 536 | 
| 539 def _CheckNoAuraWindowPropertyHInHeaders(input_api, output_api): | 537 def _CheckNoAuraWindowPropertyHInHeaders(input_api, output_api): | 
| 540 """Makes sure we don't include ui/aura/window_property.h | 538 """Makes sure we don't include ui/aura/window_property.h | 
| 541 in header files. | 539 in header files. | 
| 542 """ | 540 """ | 
| 543 pattern = input_api.re.compile(r'^#include\s*"ui/aura/window_property.h"') | 541 pattern = input_api.re.compile(r'^#include\s*"ui/aura/window_property.h"') | 
| 544 errors = [] | 542 errors = [] | 
| 545 for f in input_api.AffectedFiles(): | 543 for f in input_api.AffectedFiles(): | 
| 546 if not f.LocalPath().endswith('.h'): | 544 if not f.LocalPath().endswith('.h'): | 
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 788 a specific filename by adding /DEPS. This is chosen as a file that | 786 a specific filename by adding /DEPS. This is chosen as a file that | 
| 789 will seldom or never be subject to per-file include_rules. | 787 will seldom or never be subject to per-file include_rules. | 
| 790 """ | 788 """ | 
| 791 # We ignore deps entries on auto-generated directories. | 789 # We ignore deps entries on auto-generated directories. | 
| 792 AUTO_GENERATED_DIRS = ['grit', 'jni'] | 790 AUTO_GENERATED_DIRS = ['grit', 'jni'] | 
| 793 | 791 | 
| 794 # This pattern grabs the path without basename in the first | 792 # This pattern grabs the path without basename in the first | 
| 795 # parentheses, and the basename (if present) in the second. It | 793 # parentheses, and the basename (if present) in the second. It | 
| 796 # relies on the simple heuristic that if there is a basename it will | 794 # relies on the simple heuristic that if there is a basename it will | 
| 797 # be a header file ending in ".h". | 795 # be a header file ending in ".h". | 
| 798 pattern = re.compile( | 796 pattern = re.compile( | 
| 
 
M-A Ruel
2014/01/29 21:28:19
Replwith with: input_api.re.compile(
 
 | |
| 799 r"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""") | 797 r"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""") | 
| 800 results = set() | 798 results = set() | 
| 801 for changed_line in changed_lines: | 799 for changed_line in changed_lines: | 
| 802 m = pattern.match(changed_line) | 800 m = pattern.match(changed_line) | 
| 803 if m: | 801 if m: | 
| 804 path = m.group(1) | 802 path = m.group(1) | 
| 805 if path.split('/')[0] not in AUTO_GENERATED_DIRS: | 803 if path.split('/')[0] not in AUTO_GENERATED_DIRS: | 
| 806 if m.group(2): | 804 if m.group(2): | 
| 807 results.add('%s%s' % (path, m.group(2))) | 805 results.add('%s%s' % (path, m.group(2))) | 
| 808 else: | 806 else: | 
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 906 r"bitmaptools.cc$", | 904 r"bitmaptools.cc$", | 
| 907 r"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",)) | 905 r"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",)) | 
| 908 source_file_filter = lambda x: input_api.FilterSourceFile( | 906 source_file_filter = lambda x: input_api.FilterSourceFile( | 
| 909 x, white_list=(file_inclusion_pattern,), black_list=black_list) | 907 x, white_list=(file_inclusion_pattern,), black_list=black_list) | 
| 910 | 908 | 
| 911 log_info = [] | 909 log_info = [] | 
| 912 printf = [] | 910 printf = [] | 
| 913 | 911 | 
| 914 for f in input_api.AffectedSourceFiles(source_file_filter): | 912 for f in input_api.AffectedSourceFiles(source_file_filter): | 
| 915 contents = input_api.ReadFile(f, 'rb') | 913 contents = input_api.ReadFile(f, 'rb') | 
| 916 if re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", contents): | 914 if re.search(r"\bD?LOG\s*\(\s*INFO\s*\)", contents): | 
| 
 
M-A Ruel
2014/01/29 21:28:19
Here too, and up to line 922.
 
 | |
| 917 log_info.append(f.LocalPath()) | 915 log_info.append(f.LocalPath()) | 
| 918 elif re.search(r"\bD?LOG_IF\s*\(\s*INFO\s*,", contents): | 916 elif re.search(r"\bD?LOG_IF\s*\(\s*INFO\s*,", contents): | 
| 919 log_info.append(f.LocalPath()) | 917 log_info.append(f.LocalPath()) | 
| 920 | 918 | 
| 921 if re.search(r"\bprintf\(", contents): | 919 if re.search(r"\bprintf\(", contents): | 
| 922 printf.append(f.LocalPath()) | 920 printf.append(f.LocalPath()) | 
| 923 elif re.search(r"\bfprintf\((stdout|stderr)", contents): | 921 elif re.search(r"\bfprintf\((stdout|stderr)", contents): | 
| 924 printf.append(f.LocalPath()) | 922 printf.append(f.LocalPath()) | 
| 925 | 923 | 
| 926 if log_info: | 924 if log_info: | 
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1457 trybots.extend(GetDefaultTryConfigs(['cros_x86'])) | 1455 trybots.extend(GetDefaultTryConfigs(['cros_x86'])) | 
| 1458 | 1456 | 
| 1459 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 1457 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it | 
| 1460 # unless they're .gyp(i) files as changes to those files can break the gyp | 1458 # unless they're .gyp(i) files as changes to those files can break the gyp | 
| 1461 # step on that bot. | 1459 # step on that bot. | 
| 1462 if (not all(re.search('^chrome', f) for f in files) or | 1460 if (not all(re.search('^chrome', f) for f in files) or | 
| 1463 any(re.search('\.gypi?$', f) for f in files)): | 1461 any(re.search('\.gypi?$', f) for f in files)): | 
| 1464 trybots.extend(GetDefaultTryConfigs(['android_aosp'])) | 1462 trybots.extend(GetDefaultTryConfigs(['android_aosp'])) | 
| 1465 | 1463 | 
| 1466 return trybots | 1464 return trybots | 
| OLD | NEW |