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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # This is used to test the findbugs plugin, it calls 7 # This is used to test the findbugs plugin, it calls
8 # build/android/pylib/utils/findbugs.py to analyze the classes in 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 9 # org.chromium.tools.findbugs.plugin package, and expects to get the same
10 # issue with those in expected_result.txt. 10 # issue with those in expected_result.txt.
11 # 11 #
12 # Useful command line: 12 # Useful command line:
13 # --rebaseline to generate the expected_result.txt, please make sure don't 13 # --rebaseline to generate the expected_result.txt, please make sure don't
14 # remove the expected result of exsting tests. 14 # remove the expected result of exsting tests.
15 15
16 16
17 import optparse 17 import argparse
18 import os 18 import os
19 import sys 19 import sys
20 20
21 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 21 sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__),
22 '..', '..', '..', '..', 22 '..', '..', '..', '..',
23 'build', 'android'))) 23 'build', 'android')))
24 24
25 from pylib import constants 25 from pylib import constants
26 from pylib.utils import findbugs 26 from pylib.utils import findbugs
27 27
28 28
29 _EXPECTED_WARNINGS = set([
30 findbugs.FindBugsWarning(
31 bug_type='CHROMIUM_SYNCHRONIZED_THIS',
32 class_name='org.chromium.tools.findbugs.plugin.SimpleSynchronizedThis',
33 method_name='synchronizedThis',
34 start_line=15,
35 end_line=15,
36 message="Shouldn't use synchronized(this)"),
37 findbugs.FindBugsWarning(
38 bug_type='CHROMIUM_SYNCHRONIZED_METHOD',
39 class_name=
40 'org.chromium.tools.findbugs.plugin.SimpleSynchronizedStaticMethod',
41 method_name='synchronizedStaticMethod',
42 start_line=14,
43 end_line=14,
44 message="Shouldn't use synchronized method"),
45 findbugs.FindBugsWarning(
46 bug_type='CHROMIUM_SYNCHRONIZED_METHOD',
47 class_name=
48 'org.chromium.tools.findbugs.plugin.SimpleSynchronizedMethod',
49 method_name='synchronizedMethod',
50 start_line=15,
51 end_line=15,
52 message="Shouldn't use synchronized method"),
53 ])
54
55
29 def main(argv): 56 def main(argv):
30 parser = findbugs.GetCommonParser()
31 57
32 options, _ = parser.parse_args() 58 parser = argparse.ArgumentParser()
59 parser.add_argument(
60 '-l', '--release-build', action='store_true', dest='release',
61 help='Run the release build of the findbugs plugin test.')
62 args = parser.parse_args()
33 63
34 if not options.known_bugs: 64 test_jar_path = os.path.join(
35 options.known_bugs = os.path.join(constants.DIR_SOURCE_ROOT, 'tools', 65 constants.GetOutDirectory(
36 'android', 'findbugs_plugin', 'test', 66 'Release' if args.release else 'Debug'),
37 'expected_result.txt') 67 'lib.java', 'findbugs_plugin_test.jar')
38 68
39 if not options.only_analyze: 69 findbugs_command, findbugs_warnings = findbugs.Run(
40 options.only_analyze = 'org.chromium.tools.findbugs.plugin.*' 70 None, 'org.chromium.tools.findbugs.plugin.*', None, None, None,
71 [test_jar_path])
41 72
42 # crbug.com/449101 73 missing_warnings = _EXPECTED_WARNINGS.difference(findbugs_warnings)
43 # Temporary workaround to have the Android Clang Builder (dbg) bot 74 if missing_warnings:
44 # pass the findbugs_tests step. 75 print 'Missing warnings:'
45 if not options.exclude: 76 for w in missing_warnings:
46 options.exclude = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 77 print ' %s' % str(w)
47 'android', 'findbugs_filter',
48 'findbugs_exclude.xml')
49 78
50 return findbugs.Run(options) 79 unexpected_warnings = findbugs_warnings.difference(_EXPECTED_WARNINGS)
80 if unexpected_warnings:
81 print 'Unexpected warnings:'
82 for w in unexpected_warnings:
83 print ' %s' % str(w)
84
85 return len(unexpected_warnings) + len(missing_warnings)
51 86
52 if __name__ == '__main__': 87 if __name__ == '__main__':
53 sys.exit(main(sys.argv)) 88 sys.exit(main(sys.argv))
OLDNEW
« build/java_apk.gypi ('K') | « 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