58 """Return a dict whose keys are file names and values are coverage data.
60 Values are lists which take the form (lineno, coverage, code).
63 for root, dirs, files
in os.walk(os.getcwd()):
64 if 'third_party/externals' in root:
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] ==
'.']
69 all_files.append(os.path.join(root[(len(os.getcwd()) + 1):], name))
72 lines = report.splitlines()
78 m = re.match(
'([a-zA-Z0-9\./_-]+):', line)
80 if current_file
and current_file != not_checked_in:
81 files[current_file] = file_lines
83 current_file = match_filename
or not_checked_in
86 if current_file != not_checked_in:
87 skip = re.match(
'^\s{2}-+$|^\s{2}\|.+$', line)
89 cov, linenum, code = line.split(
'|', 2)
95 linenum =
int(linenum.strip())
96 assert linenum == len(file_lines) + 1
97 file_lines.append((linenum, cov, code.decode(
'utf-8',
'replace')))
170 """Generate useful data from a coverage report."""
172 parser = argparse.ArgumentParser()
173 parser.add_argument(
'--report', help=
'input file; an llvm coverage report.',
175 parser.add_argument(
'--nanobench', help=
'output file for nanobench data.')
177 '--key', metavar=
'key_or_value', nargs=
'+',
178 help=
'key/value pairs identifying this bot.')
180 '--properties', metavar=
'key_or_value', nargs=
'+',
181 help=
'key/value pairs representing properties of this build.')
182 parser.add_argument(
'--linebyline',
183 help=
'output file for line-by-line JSON data.')
184 args = parser.parse_args()
186 if args.nanobench
and not (args.key
and args.properties):
187 raise Exception(
'--key and --properties are required with --nanobench')
189 with open(args.report)
as f:
195 with open(args.linebyline,
'w')
as f:
196 json.dump(line_by_line, f)
208 with open(args.nanobench,
'w')
as f:
209 json.dump(format_results, f)