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 """Checks that android.test.suitebuilder.annotation.* is no longer used.""" |
| 1726 deprecated_annotation_import_pattern = input_api.re.compile( |
| 1727 r'^import android\.test\.suitebuilder\.annotation\..*;', |
| 1728 input_api.re.MULTILINE) |
| 1729 sources = lambda x: input_api.FilterSourceFile( |
| 1730 x, white_list=(r'.*\.java$',), black_list=None) |
| 1731 errors = [] |
| 1732 for f in input_api.AffectedFiles(sources): |
| 1733 for line_num, line in f.ChangedContents(): |
| 1734 if deprecated_annotation_import_pattern.search(line): |
| 1735 errors.append("%s:%d" % (f.LocalPath(), line_num)) |
| 1736 |
| 1737 results = [] |
| 1738 if errors: |
| 1739 results.append(output_api.PresubmitError( |
| 1740 'Annotations in android.test.suitebuilder.annotation have been' |
| 1741 ' deprecated since API level 24. Please use android.support.test.filters' |
| 1742 ' from //third_party/android_support_test_runner:runner_java instead.' |
| 1743 ' Contact yolandyan@chromium.org if you have any questions.', errors)) |
| 1744 return results |
| 1745 |
| 1746 |
1724 def _CheckAndroidNewMdpiAssetLocation(input_api, output_api): | 1747 def _CheckAndroidNewMdpiAssetLocation(input_api, output_api): |
1725 """Checks if MDPI assets are placed in a correct directory.""" | 1748 """Checks if MDPI assets are placed in a correct directory.""" |
1726 file_filter = lambda f: (f.LocalPath().endswith('.png') and | 1749 file_filter = lambda f: (f.LocalPath().endswith('.png') and |
1727 ('/res/drawable/' in f.LocalPath() or | 1750 ('/res/drawable/' in f.LocalPath() or |
1728 '/res/drawable-ldrtl/' in f.LocalPath())) | 1751 '/res/drawable-ldrtl/' in f.LocalPath())) |
1729 errors = [] | 1752 errors = [] |
1730 for f in input_api.AffectedFiles(include_deletes=False, | 1753 for f in input_api.AffectedFiles(include_deletes=False, |
1731 file_filter=file_filter): | 1754 file_filter=file_filter): |
1732 errors.append(' %s' % f.LocalPath()) | 1755 errors.append(' %s' % f.LocalPath()) |
1733 | 1756 |
(...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 | 2014 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))] | 2015 """ % "\n".join(" %s:%d\n" % line for line in arrow_lines))] |
1993 | 2016 |
1994 | 2017 |
1995 def _AndroidSpecificOnUploadChecks(input_api, output_api): | 2018 def _AndroidSpecificOnUploadChecks(input_api, output_api): |
1996 """Groups checks that target android code.""" | 2019 """Groups checks that target android code.""" |
1997 results = [] | 2020 results = [] |
1998 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) | 2021 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) |
1999 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) | 2022 results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) |
2000 results.extend(_CheckAndroidToastUsage(input_api, output_api)) | 2023 results.extend(_CheckAndroidToastUsage(input_api, output_api)) |
| 2024 results.extend(_CheckAndroidTestAnnotationUsage(input_api, output_api)) |
2001 return results | 2025 return results |
2002 | 2026 |
2003 | 2027 |
2004 def _CommonChecks(input_api, output_api): | 2028 def _CommonChecks(input_api, output_api): |
2005 """Checks common to both upload and commit.""" | 2029 """Checks common to both upload and commit.""" |
2006 results = [] | 2030 results = [] |
2007 results.extend(input_api.canned_checks.PanProjectChecks( | 2031 results.extend(input_api.canned_checks.PanProjectChecks( |
2008 input_api, output_api, | 2032 input_api, output_api, |
2009 excluded_paths=_EXCLUDED_PATHS)) | 2033 excluded_paths=_EXCLUDED_PATHS)) |
2010 results.extend( | 2034 results.extend( |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 results.extend(input_api.canned_checks.CheckTreeIsOpen( | 2322 results.extend(input_api.canned_checks.CheckTreeIsOpen( |
2299 input_api, | 2323 input_api, |
2300 output_api, | 2324 output_api, |
2301 json_url='http://chromium-status.appspot.com/current?format=json')) | 2325 json_url='http://chromium-status.appspot.com/current?format=json')) |
2302 | 2326 |
2303 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2327 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2304 input_api, output_api)) | 2328 input_api, output_api)) |
2305 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2329 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2306 input_api, output_api)) | 2330 input_api, output_api)) |
2307 return results | 2331 return results |
OLD | NEW |