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 depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 1703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1714 util_log_errors)) | 1714 util_log_errors)) |
| 1715 | 1715 |
| 1716 if tag_with_dot_errors: | 1716 if tag_with_dot_errors: |
| 1717 results.append(output_api.PresubmitPromptWarning( | 1717 results.append(output_api.PresubmitPromptWarning( |
| 1718 'Dot in log tags cause them to be elided in crash reports.\n' + REF_MSG, | 1718 'Dot in log tags cause them to be elided in crash reports.\n' + REF_MSG, |
| 1719 tag_with_dot_errors)) | 1719 tag_with_dot_errors)) |
| 1720 | 1720 |
| 1721 return results | 1721 return results |
| 1722 | 1722 |
| 1723 | 1723 |
| 1724 def _CheckAndroidTestAnnotationUsage(input_api, output_api): | |
| 1725 """Check that the deprecated test annotations like, "Smoke" | |
|
jbudorick
2016/12/20 00:22:19
nit:
"""Checks that android.test.suitebuilder.ann
| |
| 1726 "android.test.suitebuilder.annotation.SmallTest", should no longer be used | |
| 1727 """ | |
| 1728 deprecated_annotation_import_pattern = input_api.re.compile( | |
| 1729 r'^import android\.test\.suitebuilder\.annotation\..*;', | |
| 1730 input_api.re.MULTILINE) | |
| 1731 sources = lambda x: input_api.FilterSourceFile(x, white_list=(r'.*\.java$',), | |
|
jbudorick
2016/12/20 00:22:19
nit: drop all params onto the following line.
| |
| 1732 black_list=None) | |
| 1733 errors = [] | |
| 1734 for f in input_api.AffectedFiles(sources): | |
| 1735 for line_num, line in f.ChangedContents(): | |
| 1736 if deprecated_annotation_import_pattern.search(line): | |
| 1737 errors.append("%s:%d" % (f.LocalPath(), line_num)) | |
| 1738 | |
| 1739 results = [] | |
| 1740 if errors: | |
| 1741 results.append(output_api.PresubmitError( | |
| 1742 'Annotations in android.test.suitebuilder.annotation is deprecated since' | |
|
jbudorick
2016/12/20 00:22:19
nit:
Annotations in android.test.suitebuilder.ann
| |
| 1743 ' level 24, please replace the annotation with' | |
| 1744 ' classes in android.support.test.filters. Import' | |
| 1745 ' "//third_party/android_support_test_runner:runner_java" in your BUILD' | |
| 1746 ' file if neccessary. Contact yolandyan@chromium.org is you have any' | |
| 1747 ' questions', | |
| 1748 errors)) | |
| 1749 return results | |
| 1750 | |
| 1751 | |
| 1724 def _CheckAndroidNewMdpiAssetLocation(input_api, output_api): | 1752 def _CheckAndroidNewMdpiAssetLocation(input_api, output_api): |
| 1725 """Checks if MDPI assets are placed in a correct directory.""" | 1753 """Checks if MDPI assets are placed in a correct directory.""" |
| 1726 file_filter = lambda f: (f.LocalPath().endswith('.png') and | 1754 file_filter = lambda f: (f.LocalPath().endswith('.png') and |
| 1727 ('/res/drawable/' in f.LocalPath() or | 1755 ('/res/drawable/' in f.LocalPath() or |
| 1728 '/res/drawable-ldrtl/' in f.LocalPath())) | 1756 '/res/drawable-ldrtl/' in f.LocalPath())) |
| 1729 errors = [] | 1757 errors = [] |
| 1730 for f in input_api.AffectedFiles(include_deletes=False, | 1758 for f in input_api.AffectedFiles(include_deletes=False, |
| 1731 file_filter=file_filter): | 1759 file_filter=file_filter): |
| 1732 errors.append(' %s' % f.LocalPath()) | 1760 errors.append(' %s' % f.LocalPath()) |
| 1733 | 1761 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1991 https://chromium.googlesource.com/chromium/src/+/master/docs/es6_chromium.md#Arr ow-Functions | 2019 https://chromium.googlesource.com/chromium/src/+/master/docs/es6_chromium.md#Arr ow-Functions |
| 1992 """ % "\n".join(" %s:%d\n" % line for line in arrow_lines))] | 2020 """ % "\n".join(" %s:%d\n" % line for line in arrow_lines))] |
| 1993 | 2021 |
| 1994 | 2022 |
| 1995 def _AndroidSpecificOnUploadChecks(input_api, output_api): | 2023 def _AndroidSpecificOnUploadChecks(input_api, output_api): |
| 1996 """Groups checks that target android code.""" | 2024 """Groups checks that target android code.""" |
| 1997 results = [] | 2025 results = [] |
| 1998 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) | 2026 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) |
| 1999 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) | 2027 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) |
| 2000 results.extend(_CheckAndroidToastUsage(input_api, output_api)) | 2028 results.extend(_CheckAndroidToastUsage(input_api, output_api)) |
| 2029 results.extend(_CheckAndroidTestAnnotationUsage(input_api, output_api)) | |
| 2001 return results | 2030 return results |
| 2002 | 2031 |
| 2003 | 2032 |
| 2004 def _CommonChecks(input_api, output_api): | 2033 def _CommonChecks(input_api, output_api): |
| 2005 """Checks common to both upload and commit.""" | 2034 """Checks common to both upload and commit.""" |
| 2006 results = [] | 2035 results = [] |
| 2007 results.extend(input_api.canned_checks.PanProjectChecks( | 2036 results.extend(input_api.canned_checks.PanProjectChecks( |
| 2008 input_api, output_api, | 2037 input_api, output_api, |
| 2009 excluded_paths=_EXCLUDED_PATHS)) | 2038 excluded_paths=_EXCLUDED_PATHS)) |
| 2010 results.extend( | 2039 results.extend( |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2298 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2327 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
| 2299 input_api, | 2328 input_api, |
| 2300 output_api, | 2329 output_api, |
| 2301 json_url='http://chromium-status.appspot.com/current?format=json')) | 2330 json_url='http://chromium-status.appspot.com/current?format=json')) |
| 2302 | 2331 |
| 2303 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2332 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
| 2304 input_api, output_api)) | 2333 input_api, output_api)) |
| 2305 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2334 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
| 2306 input_api, output_api)) | 2335 input_api, output_api)) |
| 2307 return results | 2336 return results |
| OLD | NEW |