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

Side by Side 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, 8 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 unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
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.
6
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.
11 #
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.
15
16
17 import argparse
18 import os
19 import sys
20
21 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
22 '..', '..', '..', '..',
23 'build', 'android')))
24
25 from pylib import constants
26 from pylib.utils import findbugs
27
28
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 )),
69 ])
70
71
72 def main(argv):
73
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()
79
80 test_jar_path = os.path.join(
81 constants.GetOutDirectory(
82 'Release' if args.release else 'Debug'),
83 'lib.java', 'findbugs_plugin_test.jar')
84
85 findbugs_command, findbugs_warnings = findbugs.Run(
86 None, 'org.chromium.tools.findbugs.plugin.*', None, None, None,
87 [test_jar_path])
88
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)
94
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)
100
101 return len(unexpected_warnings) + len(missing_warnings)
102
103 if __name__ == '__main__':
104 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698