[Android WebViewShell] Add inclusion test for webview exposed stable interfaces.
[chromium-blink-merge.git] / tools / android / findbugs_plugin / test / run_findbugs_plugin_tests.py
blobe36fe8e55c1e0a50e4349c413f8222dfe51edab7
1 #!/usr/bin/env python
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # This is used to test the findbugs plugin, it calls
8 # build/android/pylib/utils/findbugs.py to analyze the classes in
9 # org.chromium.tools.findbugs.plugin package, and expects to get the same
10 # issue with those in expected_result.txt.
12 # Useful command line:
13 # --rebaseline to generate the expected_result.txt, please make sure don't
14 # remove the expected result of exsting tests.
17 import argparse
18 import os
19 import sys
21 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
22 '..', '..', '..', '..',
23 'build', 'android')))
25 from pylib import constants
26 from pylib.utils import findbugs
29 _EXPECTED_WARNINGS = set([
30 findbugs.FindBugsWarning(
31 bug_type='CHROMIUM_SYNCHRONIZED_THIS',
32 start_line=15,
33 end_line=15,
34 file_name='SimpleSynchronizedThis.java',
35 message=(
36 "Shouldn't use synchronized(this)",
37 'In class org.chromium.tools.findbugs.plugin.'
38 + 'SimpleSynchronizedThis',
39 'In method org.chromium.tools.findbugs.plugin.'
40 + 'SimpleSynchronizedThis.synchronizedThis()',
41 'At SimpleSynchronizedThis.java:[line 15]',
42 )),
43 findbugs.FindBugsWarning(
44 bug_type='CHROMIUM_SYNCHRONIZED_METHOD',
45 start_line=14,
46 end_line=14,
47 file_name='SimpleSynchronizedStaticMethod.java',
48 message=(
49 "Shouldn't use synchronized method",
50 'In class org.chromium.tools.findbugs.plugin.'
51 + 'SimpleSynchronizedStaticMethod',
52 'In method org.chromium.tools.findbugs.plugin.'
53 + 'SimpleSynchronizedStaticMethod.synchronizedStaticMethod()',
54 'At SimpleSynchronizedStaticMethod.java:[line 14]',
55 )),
56 findbugs.FindBugsWarning(
57 bug_type='CHROMIUM_SYNCHRONIZED_METHOD',
58 start_line=15,
59 end_line=15,
60 file_name='SimpleSynchronizedMethod.java',
61 message=(
62 "Shouldn't use synchronized method",
63 'In class org.chromium.tools.findbugs.plugin.'
64 + 'SimpleSynchronizedMethod',
65 'In method org.chromium.tools.findbugs.plugin.'
66 + 'SimpleSynchronizedMethod.synchronizedMethod()',
67 'At SimpleSynchronizedMethod.java:[line 15]',
68 )),
72 def main(argv):
74 parser = argparse.ArgumentParser()
75 parser.add_argument(
76 '-l', '--release-build', action='store_true', dest='release',
77 help='Run the release build of the findbugs plugin test.')
78 args = parser.parse_args()
80 test_jar_path = os.path.join(
81 constants.GetOutDirectory(
82 'Release' if args.release else 'Debug'),
83 'lib.java', 'findbugs_plugin_test.jar')
85 findbugs_command, findbugs_warnings = findbugs.Run(
86 None, 'org.chromium.tools.findbugs.plugin.*', None, None, None,
87 [test_jar_path])
89 missing_warnings = _EXPECTED_WARNINGS.difference(findbugs_warnings)
90 if missing_warnings:
91 print 'Missing warnings:'
92 for w in missing_warnings:
93 print '%s' % str(w)
95 unexpected_warnings = findbugs_warnings.difference(_EXPECTED_WARNINGS)
96 if unexpected_warnings:
97 print 'Unexpected warnings:'
98 for w in unexpected_warnings:
99 print '%s' % str(w)
101 return len(unexpected_warnings) + len(missing_warnings)
103 if __name__ == '__main__':
104 sys.exit(main(sys.argv))