| OLD | NEW | 
|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 import optparse | 5 import optparse | 
| 6 import os | 6 import os | 
| 7 import re | 7 import re | 
| 8 import shlex | 8 import shlex | 
| 9 import subprocess | 9 import subprocess | 
| 10 import sys | 10 import sys | 
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 55     print | 55     print | 
| 56   else: | 56   else: | 
| 57     print 'No new FindBugs warnings.' | 57     print 'No new FindBugs warnings.' | 
| 58   print | 58   print | 
| 59   return count | 59   return count | 
| 60 | 60 | 
| 61 | 61 | 
| 62 def _Rebaseline(current_warnings_set, known_bugs_file): | 62 def _Rebaseline(current_warnings_set, known_bugs_file): | 
| 63   with file(known_bugs_file, 'w') as known_bugs: | 63   with file(known_bugs_file, 'w') as known_bugs: | 
| 64     for warning in sorted(current_warnings_set): | 64     for warning in sorted(current_warnings_set): | 
| 65       print >> known_bugs, warning | 65       print >>known_bugs, warning | 
| 66   return 0 | 66   return 0 | 
| 67 | 67 | 
| 68 | 68 | 
| 69 def _GetChromeClasses(release_version): | 69 def _GetChromeClasses(release_version): | 
| 70   version = 'Debug' | 70   version = 'Debug' | 
| 71   if release_version: | 71   if release_version: | 
| 72     version = 'Release' | 72     version = 'Release' | 
| 73   path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version) | 73   path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version) | 
| 74   cmd = 'find %s -name "*.class"' % path | 74   cmd = 'find %s -name "*.class"' % path | 
| 75   out = cmd_helper.GetCmdOutput(shlex.split(cmd)) | 75   out = cmd_helper.GetCmdOutput(shlex.split(cmd)) | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 125     cmd = '%s %s ' % (cmd, findbug_args) | 125     cmd = '%s %s ' % (cmd, findbug_args) | 
| 126 | 126 | 
| 127 | 127 | 
| 128   chrome_classes = _GetChromeClasses(release_version) | 128   chrome_classes = _GetChromeClasses(release_version) | 
| 129   if not chrome_classes: | 129   if not chrome_classes: | 
| 130     return 1 | 130     return 1 | 
| 131   cmd = '%s %s ' % (cmd, chrome_classes) | 131   cmd = '%s %s ' % (cmd, chrome_classes) | 
| 132 | 132 | 
| 133   proc = subprocess.Popen(shlex.split(cmd), | 133   proc = subprocess.Popen(shlex.split(cmd), | 
| 134                           stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 134                           stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 
| 135   out, _err = proc.communicate() | 135   out, err = proc.communicate() | 
| 136   current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines()))) | 136   current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines()))) | 
| 137 | 137 | 
| 138   if rebaseline: | 138   if rebaseline: | 
| 139     return _Rebaseline(current_warnings_set, known_bugs) | 139     return _Rebaseline(current_warnings_set, known_bugs) | 
| 140   else: | 140   else: | 
| 141     return _DiffKnownWarnings(current_warnings_set, known_bugs) | 141     return _DiffKnownWarnings(current_warnings_set, known_bugs) | 
| 142 | 142 | 
| 143 def Run(options): | 143 def Run(options): | 
| 144   exclude_file = None | 144   exclude_file = None | 
| 145   known_bugs_file = None | 145   known_bugs_file = None | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 213   parser.add_option('-b', | 213   parser.add_option('-b', | 
| 214                     '--base-dir', | 214                     '--base-dir', | 
| 215                     action='store', | 215                     action='store', | 
| 216                     default=None, | 216                     default=None, | 
| 217                     dest='base_dir', | 217                     dest='base_dir', | 
| 218                     help='Base directory for configuration file.') | 218                     help='Base directory for configuration file.') | 
| 219 | 219 | 
| 220   return parser | 220   return parser | 
| 221 | 221 | 
| 222 | 222 | 
| 223 def main(): | 223 def main(argv): | 
| 224   parser = GetCommonParser() | 224   parser = GetCommonParser() | 
| 225   options, _ = parser.parse_args() | 225   options, _ = parser.parse_args() | 
| 226 | 226 | 
| 227   return Run(options) | 227   return Run(options) | 
| 228 | 228 | 
| 229 | 229 | 
| 230 if __name__ == '__main__': | 230 if __name__ == '__main__': | 
| 231   sys.exit(main()) | 231   sys.exit(main(sys.argv)) | 
| OLD | NEW | 
|---|