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

Side by Side Diff: build/android/generate_emma_html.py

Issue 201853007: [Android] Linting the rest of build/android/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « build/android/findbugs_diff.py ('k') | build/android/host_heartbeat.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 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 """Aggregates EMMA coverage files to produce html output.""" 7 """Aggregates EMMA coverage files to produce html output."""
8 8
9 import fnmatch 9 import fnmatch
10 import json 10 import json
11 import optparse 11 import optparse
12 import os 12 import os
13 import sys 13 import sys
14 import traceback
15 14
16 from pylib import cmd_helper 15 from pylib import cmd_helper
17 from pylib import constants 16 from pylib import constants
18 17
19 18
20 def _GetFilesWithExt(root_dir, ext): 19 def _GetFilesWithExt(root_dir, ext):
21 """Gets all files with a given extension. 20 """Gets all files with a given extension.
22 21
23 Args: 22 Args:
24 root_dir: Directory in which to search for files. 23 root_dir: Directory in which to search for files.
25 ext: Extension to look for (including dot) 24 ext: Extension to look for (including dot)
26 25
27 Returns: 26 Returns:
28 A list of absolute paths to files that match. 27 A list of absolute paths to files that match.
29 """ 28 """
30 files = [] 29 files = []
31 for root, _, filenames in os.walk(root_dir): 30 for root, _, filenames in os.walk(root_dir):
32 basenames = fnmatch.filter(filenames, '*.' + ext) 31 basenames = fnmatch.filter(filenames, '*.' + ext)
33 files.extend([os.path.join(root, basename) 32 files.extend([os.path.join(root, basename)
34 for basename in basenames]) 33 for basename in basenames])
35 34
36 return files 35 return files
37 36
38 37
39 def main(argv): 38 def main():
40 option_parser = optparse.OptionParser() 39 option_parser = optparse.OptionParser()
41 option_parser.add_option('--output', help='HTML output filename.') 40 option_parser.add_option('--output', help='HTML output filename.')
42 option_parser.add_option('--coverage-dir', default=None, 41 option_parser.add_option('--coverage-dir', default=None,
43 help=('Root of the directory in which to search for ' 42 help=('Root of the directory in which to search for '
44 'coverage data (.ec) files.')) 43 'coverage data (.ec) files.'))
45 option_parser.add_option('--metadata-dir', default=None, 44 option_parser.add_option('--metadata-dir', default=None,
46 help=('Root of the directory in which to search for ' 45 help=('Root of the directory in which to search for '
47 'coverage metadata (.em) files.')) 46 'coverage metadata (.em) files.'))
48 option_parser.add_option('--cleanup', action='store_true', 47 option_parser.add_option('--cleanup', action='store_true',
49 help=('If set, removes coverage files generated at ' 48 help=('If set, removes coverage files generated at '
50 'runtime.')) 49 'runtime.'))
51 options, args = option_parser.parse_args() 50 options, _ = option_parser.parse_args()
52 51
53 if not (options.coverage_dir and options.metadata_dir and options.output): 52 if not (options.coverage_dir and options.metadata_dir and options.output):
54 option_parser.error('One or more mandatory options are missing.') 53 option_parser.error('One or more mandatory options are missing.')
55 54
56 coverage_files = _GetFilesWithExt(options.coverage_dir, 'ec') 55 coverage_files = _GetFilesWithExt(options.coverage_dir, 'ec')
57 metadata_files = _GetFilesWithExt(options.metadata_dir, 'em') 56 metadata_files = _GetFilesWithExt(options.metadata_dir, 'em')
58 print 'Found coverage files: %s' % str(coverage_files) 57 print 'Found coverage files: %s' % str(coverage_files)
59 print 'Found metadata files: %s' % str(metadata_files) 58 print 'Found metadata files: %s' % str(metadata_files)
60 59
61 sources = [] 60 sources = []
(...skipping 19 matching lines...) Expand all
81 + input_args + output_args + source_args) 80 + input_args + output_args + source_args)
82 81
83 if options.cleanup: 82 if options.cleanup:
84 for f in coverage_files: 83 for f in coverage_files:
85 os.remove(f) 84 os.remove(f)
86 85
87 return exit_code 86 return exit_code
88 87
89 88
90 if __name__ == '__main__': 89 if __name__ == '__main__':
91 sys.exit(main(sys.argv)) 90 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/findbugs_diff.py ('k') | build/android/host_heartbeat.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698