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

Unified Diff: PRESUBMIT.py

Issue 2583933003: Replace deprecated Android java test annotations (Closed)
Patch Set: Add presubmit checks Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 5548a58b0d611d8c82d4b9ae7d8dd159d2f793fb..ae2cc35f316d9fcfbe347a9cfe8938970b099cc9 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -1721,6 +1721,34 @@ def _CheckAndroidCrLogUsage(input_api, output_api):
return results
+def _CheckAndroidTestAnnotationUsage(input_api, output_api):
+ """Check that the deprecated test annotations like, "Smoke"
jbudorick 2016/12/20 00:22:19 nit: """Checks that android.test.suitebuilder.ann
+ "android.test.suitebuilder.annotation.SmallTest", should no longer be used
+ """
+ deprecated_annotation_import_pattern = input_api.re.compile(
+ r'^import android\.test\.suitebuilder\.annotation\..*;',
+ input_api.re.MULTILINE)
+ 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.
+ black_list=None)
+ errors = []
+ for f in input_api.AffectedFiles(sources):
+ for line_num, line in f.ChangedContents():
+ if deprecated_annotation_import_pattern.search(line):
+ errors.append("%s:%d" % (f.LocalPath(), line_num))
+
+ results = []
+ if errors:
+ results.append(output_api.PresubmitError(
+ 'Annotations in android.test.suitebuilder.annotation is deprecated since'
jbudorick 2016/12/20 00:22:19 nit: Annotations in android.test.suitebuilder.ann
+ ' level 24, please replace the annotation with'
+ ' classes in android.support.test.filters. Import'
+ ' "//third_party/android_support_test_runner:runner_java" in your BUILD'
+ ' file if neccessary. Contact yolandyan@chromium.org is you have any'
+ ' questions',
+ errors))
+ return results
+
+
def _CheckAndroidNewMdpiAssetLocation(input_api, output_api):
"""Checks if MDPI assets are placed in a correct directory."""
file_filter = lambda f: (f.LocalPath().endswith('.png') and
@@ -1998,6 +2026,7 @@ def _AndroidSpecificOnUploadChecks(input_api, output_api):
results.extend(_CheckAndroidCrLogUsage(input_api, output_api))
results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api))
results.extend(_CheckAndroidToastUsage(input_api, output_api))
+ results.extend(_CheckAndroidTestAnnotationUsage(input_api, output_api))
return results
« no previous file with comments | « no previous file | PRESUBMIT_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698