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

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

Issue 1711983002: Fix generate_emma_html.py failing due to 0-length .em files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | 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
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 'runtime.')) 51 'runtime.'))
52 options, _ = option_parser.parse_args() 52 options, _ = option_parser.parse_args()
53 53
54 devil_chromium.Initialize() 54 devil_chromium.Initialize()
55 55
56 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):
57 option_parser.error('One or more mandatory options are missing.') 57 option_parser.error('One or more mandatory options are missing.')
58 58
59 coverage_files = _GetFilesWithExt(options.coverage_dir, 'ec') 59 coverage_files = _GetFilesWithExt(options.coverage_dir, 'ec')
60 metadata_files = _GetFilesWithExt(options.metadata_dir, 'em') 60 metadata_files = _GetFilesWithExt(options.metadata_dir, 'em')
61 # Filter out zero-length files. These are created by emma_instr.py when a
62 # target has no classes matching the coverage filter.
63 metadata_files = [f for f in metadata_files if os.path.getsize(f)]
61 print 'Found coverage files: %s' % str(coverage_files) 64 print 'Found coverage files: %s' % str(coverage_files)
62 print 'Found metadata files: %s' % str(metadata_files) 65 print 'Found metadata files: %s' % str(metadata_files)
63 66
64 sources = [] 67 sources = []
65 for f in metadata_files: 68 for f in metadata_files:
66 sources_file = os.path.splitext(f)[0] + '_sources.txt' 69 sources_file = os.path.splitext(f)[0] + '_sources.txt'
67 with open(sources_file, 'r') as sf: 70 with open(sources_file, 'r') as sf:
68 sources.extend(json.load(sf)) 71 sources.extend(json.load(sf))
69 sources = [os.path.join(host_paths.DIR_SOURCE_ROOT, s) for s in sources] 72 sources = [os.path.join(host_paths.DIR_SOURCE_ROOT, s) for s in sources]
70 print 'Sources: %s' % sources 73 print 'Sources: %s' % sources
71 74
72 input_args = [] 75 input_args = []
73 for f in coverage_files + metadata_files: 76 for f in coverage_files + metadata_files:
74 input_args.append('-in') 77 input_args.append('-in')
75 input_args.append(f) 78 input_args.append(f)
76 79
77 output_args = ['-Dreport.html.out.file', options.output] 80 output_args = ['-Dreport.html.out.file', options.output]
78 source_args = ['-sp', ','.join(sources)] 81 source_args = ['-sp', ','.join(sources)]
79 82
80 exit_code = cmd_helper.RunCmd( 83 exit_code = cmd_helper.RunCmd(
81 ['java', '-cp', 84 ['java', '-cp',
82 os.path.join(constants.ANDROID_SDK_ROOT, 'tools', 'lib', 'emma.jar'), 85 os.path.join(constants.ANDROID_SDK_ROOT, 'tools', 'lib', 'emma.jar'),
83 'emma', 'report', '-r', 'html'] 86 'emma', 'report', '-r', 'html']
84 + input_args + output_args + source_args) 87 + input_args + output_args + source_args)
85 88
86 if options.cleanup: 89 if options.cleanup:
87 for f in coverage_files: 90 for f in coverage_files:
88 os.remove(f) 91 os.remove(f)
89 92
93 # Command tends to exit with status 0 when it actually failed.
94 if not exit_code and not os.path.exists(options.output):
95 exit_code = 1
96
90 return exit_code 97 return exit_code
91 98
92 99
93 if __name__ == '__main__': 100 if __name__ == '__main__':
94 sys.exit(main()) 101 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698