forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android: Remove support for junit3 tests
We moved to junit4 long ago. Bug: 40693265 Change-Id: I3be7bd0681fdb55bc95d63dafebedfcd7e646d33 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5288616 Reviewed-by: Haiyang Pan <[email protected]> Commit-Queue: Andrew Grieve <[email protected]> Owners-Override: Andrew Grieve <[email protected]> Cr-Commit-Position: refs/heads/main@{#1260024}
- Loading branch information
Showing
13 changed files
with
48 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4373,60 +4373,6 @@ def _CheckAndroidCrLogUsage(input_api, output_api): | |
return results | ||
|
||
|
||
def _CheckAndroidTestJUnitFrameworkImport(input_api, output_api): | ||
"""Checks that junit.framework.* is no longer used.""" | ||
deprecated_junit_framework_pattern = input_api.re.compile( | ||
r'^import junit\.framework\..*;', input_api.re.MULTILINE) | ||
sources = lambda x: input_api.FilterSourceFile( | ||
x, files_to_check=[r'.*\.java$'], files_to_skip=None) | ||
errors = [] | ||
for f in input_api.AffectedFiles(file_filter=sources): | ||
for line_num, line in f.ChangedContents(): | ||
if deprecated_junit_framework_pattern.search(line): | ||
errors.append("%s:%d" % (f.LocalPath(), line_num)) | ||
|
||
results = [] | ||
if errors: | ||
results.append( | ||
output_api.PresubmitError( | ||
'APIs from junit.framework.* are deprecated, please use JUnit4 framework' | ||
'(org.junit.*) from //third_party/junit. Contact [email protected]' | ||
' if you have any question.', errors)) | ||
return results | ||
|
||
|
||
def _CheckAndroidTestJUnitInheritance(input_api, output_api): | ||
"""Checks that if new Java test classes have inheritance. | ||
Either the new test class is JUnit3 test or it is a JUnit4 test class | ||
with a base class, either case is undesirable. | ||
""" | ||
class_declaration_pattern = input_api.re.compile(r'^public class \w*Test ') | ||
|
||
sources = lambda x: input_api.FilterSourceFile( | ||
x, files_to_check=[r'.*Test\.java$'], files_to_skip=None) | ||
errors = [] | ||
for f in input_api.AffectedFiles(file_filter=sources): | ||
if not f.OldContents(): | ||
class_declaration_start_flag = False | ||
for line_num, line in f.ChangedContents(): | ||
if class_declaration_pattern.search(line): | ||
class_declaration_start_flag = True | ||
if class_declaration_start_flag and ' extends ' in line: | ||
errors.append('%s:%d' % (f.LocalPath(), line_num)) | ||
if '{' in line: | ||
class_declaration_start_flag = False | ||
|
||
results = [] | ||
if errors: | ||
results.append( | ||
output_api.PresubmitPromptWarning( | ||
'The newly created files include Test classes that inherits from base' | ||
' class. Please do not use inheritance in JUnit4 tests or add new' | ||
' JUnit3 tests. Contact [email protected] if you have any' | ||
' questions.', errors)) | ||
return results | ||
|
||
|
||
def _CheckAndroidTestAnnotationUsage(input_api, output_api): | ||
"""Checks that android.test.suitebuilder.annotation.* is no longer used.""" | ||
deprecated_annotation_import_pattern = input_api.re.compile( | ||
|
@@ -5326,9 +5272,6 @@ def ChecksAndroidSpecificOnUpload(input_api, output_api): | |
results.extend(_CheckAndroidDebuggableBuild(input_api, output_api)) | ||
results.extend(_CheckAndroidNewMdpiAssetLocation(input_api, output_api)) | ||
results.extend(_CheckAndroidToastUsage(input_api, output_api)) | ||
results.extend(_CheckAndroidTestJUnitInheritance(input_api, output_api)) | ||
results.extend(_CheckAndroidTestJUnitFrameworkImport( | ||
input_api, output_api)) | ||
results.extend(_CheckAndroidTestAnnotationUsage(input_api, output_api)) | ||
results.extend(_CheckAndroidWebkitImports(input_api, output_api)) | ||
results.extend(_CheckAndroidXmlStyle(input_api, output_api, True)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.