OLD | NEW |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 print >> sys.stderr, ('WARNING: multiple matches for %s; skipping:\n\t%s' | 52 print >> sys.stderr, ('WARNING: multiple matches for %s; skipping:\n\t%s' |
53 % (new_file, '\n\t'.join(matched))) | 53 % (new_file, '\n\t'.join(matched))) |
54 return None | 54 return None |
55 | 55 |
56 | 56 |
57 def _get_per_file_per_line_coverage(report): | 57 def _get_per_file_per_line_coverage(report): |
58 """Return a dict whose keys are file names and values are coverage data. | 58 """Return a dict whose keys are file names and values are coverage data. |
59 | 59 |
60 Values are lists which take the form (lineno, coverage, code). | 60 Values are lists which take the form (lineno, coverage, code). |
61 """ | 61 """ |
62 all_files = subprocess.check_output(['git', 'ls-files']).splitlines() | 62 all_files = [] |
| 63 for root, dirs, files in os.walk(os.getcwd()): |
| 64 if 'third_party/externals' in root: |
| 65 continue |
| 66 files = [f for f in files if not (f[0] == '.' or f.endswith('.pyc'))] |
| 67 dirs[:] = [d for d in dirs if not d[0] == '.'] |
| 68 for name in files: |
| 69 all_files.append(os.path.join(root[(len(os.getcwd()) + 1):], name)) |
| 70 all_files.sort() |
| 71 |
63 lines = report.splitlines() | 72 lines = report.splitlines() |
64 current_file = None | 73 current_file = None |
65 file_lines = [] | 74 file_lines = [] |
66 files = {} | 75 files = {} |
67 not_checked_in = '%' # Use this as the file name for not-checked-in files. | 76 not_checked_in = '%' # Use this as the file name for not-checked-in files. |
68 for line in lines: | 77 for line in lines: |
69 m = re.match('([a-zA-Z0-9\./_-]+):', line) | 78 m = re.match('([a-zA-Z0-9\./_-]+):', line) |
70 if m: | 79 if m: |
71 if current_file and current_file != not_checked_in: | 80 if current_file and current_file != not_checked_in: |
72 files[current_file] = file_lines | 81 files[current_file] = file_lines |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 per_file = _get_per_file_summaries(line_by_line) | 204 per_file = _get_per_file_summaries(line_by_line) |
196 | 205 |
197 # Write results. | 206 # Write results. |
198 format_results = _nanobench_json(per_file, properties, key) | 207 format_results = _nanobench_json(per_file, properties, key) |
199 with open(args.nanobench, 'w') as f: | 208 with open(args.nanobench, 'w') as f: |
200 json.dump(format_results, f) | 209 json.dump(format_results, f) |
201 | 210 |
202 | 211 |
203 if __name__ == '__main__': | 212 if __name__ == '__main__': |
204 main() | 213 main() |
OLD | NEW |