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

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

Issue 20210002: [Android] Sets up a coverage system for java using EMMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes dex/obfuscate actions slightly Created 7 years, 4 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
(Empty)
1 #!/usr/bin/env python
2
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
5 # found in the LICENSE file.
6
7 """Aggregates EMMA coverage files to produce html output."""
8
9 import optparse
10 import os
11 import sys
12
13 from pylib import cmd_helper
14 from pylib import constants
15
16
17 def _GetFilesWithExt(root_dir, ext):
18 """Gets all files with a given extension.
19
20 Args:
21 root_dir: Directory in which to search for files.
22 ext: Extension to look for (including dot)
23
24 Returns:
25 A list of absolute paths to files that match.
26 """
27 files = []
28 for root, _, filenames in os.walk(root_dir):
29 basenames = [f for f in filenames if os.path.splitext(f)[1] == ext]
cjhopman 2013/08/09 18:54:37 basenames = fnmatch.filter(filenames, '*.' + ext)
gkanwar1 2013/08/09 23:32:53 Done.
30 files.extend([os.path.join(root, basename)
31 for basename in basenames])
32
33 return files
34
35
36 def main(argv):
37 option_parser = optparse.OptionParser()
38 option_parser.add_option('-o', '--output', help='HTML output filename.')
39 option_parser.add_option('-c', '--coverage-dir', default=None,
40 help=('Root of the directory in which to search for '
41 'coverage data (.ec) files.'))
42 option_parser.add_option('-m', '--metadata-dir', default=None,
43 help=('Root of the directory in which to search for '
44 'coverage metadata (.em) files.'))
45 options, args = option_parser.parse_args()
46
47 if not (options.coverage_dir and options.metadata_dir and options.output):
48 option_parser.error('All arguments are required.')
49
50 emma_jar = os.path.join(constants.ANDROID_SDK_ROOT, 'tools', 'lib',
51 'emma.jar')
52
53 coverage_files = _GetFilesWithExt(options.coverage_dir, '.ec')
54 metadata_files = _GetFilesWithExt(options.metadata_dir, '.em')
55 sources_files = []
56 for f in metadata_files:
57 sources_file = os.path.join(os.path.dirname(f), 'emma_sources.txt')
58 if os.path.exists(sources_file):
59 with open(sources_file, 'r') as f:
60 sources_files.extend(f.read().split())
61 sources_files = [os.path.join(constants.DIR_SOURCE_ROOT, s)
62 for s in sources_files]
63
64 input_args = []
65 for f in coverage_files + metadata_files:
66 input_args.append('-in')
67 input_args.append(f)
68
69 output_args = ['-Dreport.html.out.file', options.output]
70 source_args = ['-sp', ','.join(sources_files)]
71
72 return cmd_helper.RunCmd(
73 ['java', '-cp', emma_jar, 'emma', 'report', '-r', 'html']
74 + input_args + output_args + source_args)
75
76
77 if __name__ == '__main__':
78 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698