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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 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
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
new file mode 100755
index 0000000000000000000000000000000000000000..e36fe8e55c1e0a50e4349c413f8222dfe51edab7
--- /dev/null
+++ b/tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This is used to test the findbugs plugin, it calls
+# build/android/pylib/utils/findbugs.py to analyze the classes in
+# org.chromium.tools.findbugs.plugin package, and expects to get the same
+# issue with those in expected_result.txt.
+#
+# Useful command line:
+# --rebaseline to generate the expected_result.txt, please make sure don't
+# remove the expected result of exsting tests.
+
+
+import argparse
+import os
+import sys
+
+sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
+ '..', '..', '..', '..',
+ 'build', 'android')))
+
+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 = 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')
+
+ findbugs_command, findbugs_warnings = findbugs.Run(
+ None, 'org.chromium.tools.findbugs.plugin.*', None, None, None,
+ [test_jar_path])
+
+ missing_warnings = _EXPECTED_WARNINGS.difference(findbugs_warnings)
+ if missing_warnings:
+ print 'Missing warnings:'
+ for w in missing_warnings:
+ print '%s' % str(w)
+
+ unexpected_warnings = findbugs_warnings.difference(_EXPECTED_WARNINGS)
+ if unexpected_warnings:
+ print 'Unexpected warnings:'
+ for w in unexpected_warnings:
+ print '%s' % str(w)
+
+ return len(unexpected_warnings) + len(missing_warnings)
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))

Powered by Google App Engine
This is Rietveld 408576698