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

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

Issue 1571803002: [Android] Prepare build/android/ for catapult+devil. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@create-device-library-links
Patch Set: rebase Created 4 years, 11 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/gyp/create_device_library_links.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 14
15 import devil_chromium
15 from devil.utils import cmd_helper 16 from devil.utils import cmd_helper
16 from pylib import constants 17 from pylib import constants
18 from pylib.constants import host_paths
17 19
18 20
19 def _GetFilesWithExt(root_dir, ext): 21 def _GetFilesWithExt(root_dir, ext):
20 """Gets all files with a given extension. 22 """Gets all files with a given extension.
21 23
22 Args: 24 Args:
23 root_dir: Directory in which to search for files. 25 root_dir: Directory in which to search for files.
24 ext: Extension to look for (including dot) 26 ext: Extension to look for (including dot)
25 27
26 Returns: 28 Returns:
(...skipping 15 matching lines...) Expand all
42 help=('Root of the directory in which to search for ' 44 help=('Root of the directory in which to search for '
43 'coverage data (.ec) files.')) 45 'coverage data (.ec) files.'))
44 option_parser.add_option('--metadata-dir', default=None, 46 option_parser.add_option('--metadata-dir', default=None,
45 help=('Root of the directory in which to search for ' 47 help=('Root of the directory in which to search for '
46 'coverage metadata (.em) files.')) 48 'coverage metadata (.em) files.'))
47 option_parser.add_option('--cleanup', action='store_true', 49 option_parser.add_option('--cleanup', action='store_true',
48 help=('If set, removes coverage files generated at ' 50 help=('If set, removes coverage files generated at '
49 'runtime.')) 51 'runtime.'))
50 options, _ = option_parser.parse_args() 52 options, _ = option_parser.parse_args()
51 53
54 devil_chromium.Initialize()
55
52 if not (options.coverage_dir and options.metadata_dir and options.output): 56 if not (options.coverage_dir and options.metadata_dir and options.output):
53 option_parser.error('One or more mandatory options are missing.') 57 option_parser.error('One or more mandatory options are missing.')
54 58
55 coverage_files = _GetFilesWithExt(options.coverage_dir, 'ec') 59 coverage_files = _GetFilesWithExt(options.coverage_dir, 'ec')
56 metadata_files = _GetFilesWithExt(options.metadata_dir, 'em') 60 metadata_files = _GetFilesWithExt(options.metadata_dir, 'em')
57 print 'Found coverage files: %s' % str(coverage_files) 61 print 'Found coverage files: %s' % str(coverage_files)
58 print 'Found metadata files: %s' % str(metadata_files) 62 print 'Found metadata files: %s' % str(metadata_files)
59 63
60 sources = [] 64 sources = []
61 for f in metadata_files: 65 for f in metadata_files:
62 sources_file = os.path.splitext(f)[0] + '_sources.txt' 66 sources_file = os.path.splitext(f)[0] + '_sources.txt'
63 with open(sources_file, 'r') as sf: 67 with open(sources_file, 'r') as sf:
64 sources.extend(json.load(sf)) 68 sources.extend(json.load(sf))
65 sources = [os.path.join(constants.DIR_SOURCE_ROOT, s) for s in sources] 69 sources = [os.path.join(host_paths.DIR_SOURCE_ROOT, s) for s in sources]
66 print 'Sources: %s' % sources 70 print 'Sources: %s' % sources
67 71
68 input_args = [] 72 input_args = []
69 for f in coverage_files + metadata_files: 73 for f in coverage_files + metadata_files:
70 input_args.append('-in') 74 input_args.append('-in')
71 input_args.append(f) 75 input_args.append(f)
72 76
73 output_args = ['-Dreport.html.out.file', options.output] 77 output_args = ['-Dreport.html.out.file', options.output]
74 source_args = ['-sp', ','.join(sources)] 78 source_args = ['-sp', ','.join(sources)]
75 79
76 exit_code = cmd_helper.RunCmd( 80 exit_code = cmd_helper.RunCmd(
77 ['java', '-cp', 81 ['java', '-cp',
78 os.path.join(constants.ANDROID_SDK_ROOT, 'tools', 'lib', 'emma.jar'), 82 os.path.join(constants.ANDROID_SDK_ROOT, 'tools', 'lib', 'emma.jar'),
79 'emma', 'report', '-r', 'html'] 83 'emma', 'report', '-r', 'html']
80 + input_args + output_args + source_args) 84 + input_args + output_args + source_args)
81 85
82 if options.cleanup: 86 if options.cleanup:
83 for f in coverage_files: 87 for f in coverage_files:
84 os.remove(f) 88 os.remove(f)
85 89
86 return exit_code 90 return exit_code
87 91
88 92
89 if __name__ == '__main__': 93 if __name__ == '__main__':
90 sys.exit(main()) 94 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/findbugs_diff.py ('k') | build/android/gyp/create_device_library_links.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698