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)
def main():
    parser = findbugs.GetCommonParser()

    options, _ = parser.parse_args()

    if not options.base_dir:
        options.base_dir = os.path.join(constants.DIR_SOURCE_ROOT, 'build',
                                        'android', 'findbugs_filter')
    if not options.only_analyze:
        options.only_analyze = 'org.chromium.-'

    return findbugs.Run(options)
def main(argv):
  parser = findbugs.GetCommonParser()

  options, _ = parser.parse_args()

  if not options.known_bugs:
    options.known_bugs = os.path.join(constants.CHROME_DIR, 'tools', 'android',
                                      'findbugs_plugin', 'test',
                                      'expected_result.txt')
  if not options.only_analyze:
    options.only_analyze = 'org.chromium.tools.findbugs.plugin.*'

  return findbugs.Run(options)
示例#4
0
def main(argv):
    parser = findbugs.GetCommonParser()

    options, _ = parser.parse_args()

    if not options.known_bugs:
        options.known_bugs = os.path.join(constants.DIR_SOURCE_ROOT, 'tools',
                                          'android', 'findbugs_plugin', 'test',
                                          'expected_result.txt')

    if not options.only_analyze:
        options.only_analyze = 'org.chromium.tools.findbugs.plugin.*'

    # 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')

    return findbugs.Run(options)
示例#5
0
def main():
  parser = argparse.ArgumentParser()

  parser.add_argument(
      '-v', '--verbose', action='count', help='Enable verbose logging.')
  parser.add_argument(
      '-a', '--auxclasspath', default=None, dest='auxclasspath',
      help='Set aux classpath for analysis.')
  parser.add_argument(
      '--auxclasspath-gyp', dest='auxclasspath_gyp',
      help='A gyp list containing the aux classpath for analysis')
  parser.add_argument(
      '-o', '--only-analyze', default=None,
      dest='only_analyze', help='Only analyze the given classes and packages.')
  parser.add_argument(
      '-e', '--exclude', default=None, dest='exclude',
      help='Exclude bugs matching given filter.')
  parser.add_argument(
      '-l', '--release-build', action='store_true', dest='release_build',
      help='Analyze release build instead of debug.')
  parser.add_argument(
      '-f', '--findbug-args', default=None, dest='findbug_args',
      help='Additional findbug arguments.')
  parser.add_argument(
      '-b', '--base-dir', default=_DEFAULT_BASE_DIR,
      dest='base_dir', help='Base directory for configuration file.')
  parser.add_argument(
      '--output-file', dest='output_file',
      help='Path to save the output to.')
  parser.add_argument(
      '--stamp', help='Path to touch on success.')
  parser.add_argument(
      '--depfile', help='Path to the depfile. This must be specified as the '
                        "action's first output.")

  parser.add_argument(
      'jar_paths', metavar='JAR_PATH', nargs='+',
      help='JAR file to analyze')

  args = parser.parse_args(build_utils.ExpandFileArgs(sys.argv[1:]))

  run_tests_helper.SetLogLevel(args.verbose)

  devil_chromium.Initialize()

  if args.auxclasspath:
    args.auxclasspath = args.auxclasspath.split(':')
  elif args.auxclasspath_gyp:
    args.auxclasspath = build_utils.ParseGnList(args.auxclasspath_gyp)

  if args.base_dir:
    if not args.exclude:
      args.exclude = os.path.join(args.base_dir, 'findbugs_exclude.xml')

  findbugs_command, findbugs_warnings = findbugs.Run(
      args.exclude, args.only_analyze, args.auxclasspath,
      args.output_file, args.findbug_args, args.jar_paths)

  if findbugs_warnings:
    print
    print '*' * 80
    print 'FindBugs run via:'
    print findbugs_command
    print
    print 'FindBugs reported the following issues:'
    for warning in sorted(findbugs_warnings):
      print str(warning)
    print '*' * 80
    print
  else:
    if args.depfile:
      deps = args.auxclasspath + args.jar_paths
      build_utils.WriteDepfile(args.depfile, args.output_file, deps)
    if args.stamp:
      build_utils.Touch(args.stamp)

  return len(findbugs_warnings)