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

Side by Side Diff: tools/parse_llvm_coverage.py

Issue 1246043002: Coverage: add a trace for not_covered_lines per file (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Adjust format Created 5 years, 5 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 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 6
7 """Parse an LLVM coverage report to generate useable results.""" 7 """Parse an LLVM coverage report to generate useable results."""
8 8
9 9
10 import argparse 10 import argparse
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 rv = {} 100 rv = {}
101 # Copy over the properties first, then set the 'key' and 'results' keys, 101 # Copy over the properties first, then set the 'key' and 'results' keys,
102 # in order to avoid bad formatting in case the user passes in a properties 102 # in order to avoid bad formatting in case the user passes in a properties
103 # dict containing those keys. 103 # dict containing those keys.
104 rv.update(properties) 104 rv.update(properties)
105 rv['key'] = key 105 rv['key'] = key
106 rv['results'] = { 106 rv['results'] = {
107 _testname(f): { 107 _testname(f): {
108 'coverage': { 108 'coverage': {
109 'percent': percent, 109 'percent': percent,
110 'lines_not_covered': not_covered_lines,
110 'options': { 111 'options': {
111 'fullname': f, 112 'fullname': f,
112 'dir': os.path.dirname(f), 113 'dir': os.path.dirname(f),
114 'source_type': 'coverage',
113 }, 115 },
114 }, 116 },
115 } for percent, f in results 117 } for percent, not_covered_lines, f in results
116 } 118 }
117 return rv 119 return rv
118 120
119 121
120 def _parse_key_value(kv_list): 122 def _parse_key_value(kv_list):
121 """Return a dict whose key/value pairs are derived from the given list. 123 """Return a dict whose key/value pairs are derived from the given list.
122 124
123 For example: 125 For example:
124 126
125 ['k1', 'v1', 'k2', 'v2'] 127 ['k1', 'v1', 'k2', 'v2']
(...skipping 17 matching lines...) Expand all
143 for filepath, lines in line_by_line.iteritems(): 145 for filepath, lines in line_by_line.iteritems():
144 total_lines = 0 146 total_lines = 0
145 covered_lines = 0 147 covered_lines = 0
146 for _, cov, _ in lines: 148 for _, cov, _ in lines:
147 if cov is not None: 149 if cov is not None:
148 total_lines += 1 150 total_lines += 1
149 if cov > 0: 151 if cov > 0:
150 covered_lines += 1 152 covered_lines += 1
151 if total_lines > 0: 153 if total_lines > 0:
152 per_file.append((float(covered_lines)/float(total_lines)*100.0, 154 per_file.append((float(covered_lines)/float(total_lines)*100.0,
155 total_lines - covered_lines,
153 filepath)) 156 filepath))
154 return per_file 157 return per_file
155 158
156 159
157 def main(): 160 def main():
158 """Generate useful data from a coverage report.""" 161 """Generate useful data from a coverage report."""
159 # Parse args. 162 # Parse args.
160 parser = argparse.ArgumentParser() 163 parser = argparse.ArgumentParser()
161 parser.add_argument('--report', help='input file; an llvm coverage report.', 164 parser.add_argument('--report', help='input file; an llvm coverage report.',
162 required=True) 165 required=True)
(...skipping 29 matching lines...) Expand all
192 per_file = _get_per_file_summaries(line_by_line) 195 per_file = _get_per_file_summaries(line_by_line)
193 196
194 # Write results. 197 # Write results.
195 format_results = _nanobench_json(per_file, properties, key) 198 format_results = _nanobench_json(per_file, properties, key)
196 with open(args.nanobench, 'w') as f: 199 with open(args.nanobench, 'w') as f:
197 json.dump(format_results, f) 200 json.dump(format_results, f)
198 201
199 202
200 if __name__ == '__main__': 203 if __name__ == '__main__':
201 main() 204 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