bitcoin/contrib/filter-lcov.py
Andrew Chow d5711f4a2d Filter subtrees and and benchmarks from coverage report
Remove leveldb baseline coverage gathering.

Added filter rules to remove all of the subtress (leveldb, secp256k1, ctaes, univalue) and
benchmarking from the coverage report. These items are unnecessary as we do not test for any
of the subtrees and benchmark coverage is unneeded.
2017-06-12 15:53:30 -07:00

26 lines
916 B
Python
Executable File

#!/usr/bin/env python3
import argparse
parser = argparse.ArgumentParser(description='Remove the coverage data from a tracefile for all files matching the pattern.')
parser.add_argument('--pattern', '-p', action='append', help='the pattern of files to remove', required=True)
parser.add_argument('tracefile', help='the tracefile to remove the coverage data from')
parser.add_argument('outfile', help='filename for the output to be written to')
args = parser.parse_args()
tracefile = args.tracefile
pattern = args.pattern
outfile = args.outfile
in_remove = False
with open(tracefile, 'r') as f:
with open(outfile, 'w') as wf:
for line in f:
for p in pattern:
if line.startswith("SF:") and p in line:
in_remove = True
if not in_remove:
wf.write(line)
if line == 'end_of_record\n':
in_remove = False