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

Unified Diff: tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py

Issue 1000793002: [Android] Incorporate findbugs into android builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address cjhopman's comment + rebase Created 5 years, 9 months 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 | « tools/android/findbugs_plugin/lib/chromiumPlugin.jar ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py
diff --git a/tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py b/tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py
index a570cdb6045446a32e6836247dc231d27cb22d6b..e36fe8e55c1e0a50e4349c413f8222dfe51edab7 100755
--- a/tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py
+++ b/tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py
@@ -14,7 +14,7 @@
# remove the expected result of exsting tests.
-import optparse
+import argparse
import os
import sys
@@ -26,28 +26,79 @@ from pylib import constants
from pylib.utils import findbugs
+_EXPECTED_WARNINGS = set([
+ findbugs.FindBugsWarning(
+ bug_type='CHROMIUM_SYNCHRONIZED_THIS',
+ start_line=15,
+ end_line=15,
+ file_name='SimpleSynchronizedThis.java',
+ message=(
+ "Shouldn't use synchronized(this)",
+ 'In class org.chromium.tools.findbugs.plugin.'
+ + 'SimpleSynchronizedThis',
+ 'In method org.chromium.tools.findbugs.plugin.'
+ + 'SimpleSynchronizedThis.synchronizedThis()',
+ 'At SimpleSynchronizedThis.java:[line 15]',
+ )),
+ findbugs.FindBugsWarning(
+ bug_type='CHROMIUM_SYNCHRONIZED_METHOD',
+ start_line=14,
+ end_line=14,
+ file_name='SimpleSynchronizedStaticMethod.java',
+ message=(
+ "Shouldn't use synchronized method",
+ 'In class org.chromium.tools.findbugs.plugin.'
+ + 'SimpleSynchronizedStaticMethod',
+ 'In method org.chromium.tools.findbugs.plugin.'
+ + 'SimpleSynchronizedStaticMethod.synchronizedStaticMethod()',
+ 'At SimpleSynchronizedStaticMethod.java:[line 14]',
+ )),
+ findbugs.FindBugsWarning(
+ bug_type='CHROMIUM_SYNCHRONIZED_METHOD',
+ start_line=15,
+ end_line=15,
+ file_name='SimpleSynchronizedMethod.java',
+ message=(
+ "Shouldn't use synchronized method",
+ 'In class org.chromium.tools.findbugs.plugin.'
+ + 'SimpleSynchronizedMethod',
+ 'In method org.chromium.tools.findbugs.plugin.'
+ + 'SimpleSynchronizedMethod.synchronizedMethod()',
+ 'At SimpleSynchronizedMethod.java:[line 15]',
+ )),
+])
+
+
def main(argv):
- parser = findbugs.GetCommonParser()
- options, _ = parser.parse_args()
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ '-l', '--release-build', action='store_true', dest='release',
+ help='Run the release build of the findbugs plugin test.')
+ args = parser.parse_args()
+
+ test_jar_path = os.path.join(
+ constants.GetOutDirectory(
+ 'Release' if args.release else 'Debug'),
+ 'lib.java', 'findbugs_plugin_test.jar')
- if not options.known_bugs:
- options.known_bugs = os.path.join(constants.DIR_SOURCE_ROOT, 'tools',
- 'android', 'findbugs_plugin', 'test',
- 'expected_result.txt')
+ findbugs_command, findbugs_warnings = findbugs.Run(
+ None, 'org.chromium.tools.findbugs.plugin.*', None, None, None,
+ [test_jar_path])
- if not options.only_analyze:
- options.only_analyze = 'org.chromium.tools.findbugs.plugin.*'
+ missing_warnings = _EXPECTED_WARNINGS.difference(findbugs_warnings)
+ if missing_warnings:
+ print 'Missing warnings:'
+ for w in missing_warnings:
+ print '%s' % str(w)
- # crbug.com/449101
- # Temporary workaround to have the Android Clang Builder (dbg) bot
- # pass the findbugs_tests step.
- if not options.exclude:
- options.exclude = os.path.join(constants.DIR_SOURCE_ROOT, 'build',
- 'android', 'findbugs_filter',
- 'findbugs_exclude.xml')
+ unexpected_warnings = findbugs_warnings.difference(_EXPECTED_WARNINGS)
+ if unexpected_warnings:
+ print 'Unexpected warnings:'
+ for w in unexpected_warnings:
+ print '%s' % str(w)
- return findbugs.Run(options)
+ return len(unexpected_warnings) + len(missing_warnings)
if __name__ == '__main__':
sys.exit(main(sys.argv))
« no previous file with comments | « tools/android/findbugs_plugin/lib/chromiumPlugin.jar ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698