Bug 1424227 - Support merging multiple input info files into a single output info file. r=chmanchester

--HG--
extra : rebase_source : 1df6385ebcdb7a5af04b53d517311c80c3d74086
This commit is contained in:
Marco Castelluccio 2017-12-09 01:38:34 +01:00
Родитель f7232c4f34
Коммит b1502eb28e
1 изменённых файлов: 44 добавлений и 36 удалений

Просмотреть файл

@ -245,14 +245,16 @@ class LcovFile(object):
'LF': 0,
}
def __init__(self, lcov_fh):
self.lcov_fh = lcov_fh
def __init__(self, lcov_paths):
self.lcov_paths = lcov_paths
def iterate_records(self, rewrite_source=None):
current_source_file = None
current_preprocessed = False
current_lines = []
for line in self.lcov_fh:
for lcov_path in self.lcov_paths:
with open(lcov_path) as lcov_fh:
for line in lcov_fh:
line = line.rstrip()
if not line:
continue
@ -664,10 +666,7 @@ class LcovFileRewriter(object):
self.url_finder = UrlFinder(appdir, gredir, extra_chrome_manifests)
self.pp_rewriter = RecordRewriter()
def rewrite_file(self, in_path, output_suffix):
in_path = os.path.abspath(in_path)
out_path = in_path + output_suffix
def rewrite_files(self, in_paths, output_file, output_suffix):
unknowns = set()
found_valid = False
@ -694,8 +693,16 @@ class LcovFileRewriter(object):
return source_file, preprocessed
with open(in_path) as fh, open(out_path, 'w+') as out_fh:
lcov_file = LcovFile(fh)
in_paths = [os.path.abspath(in_path) for in_path in in_paths]
if output_file:
lcov_file = LcovFile(in_paths)
with open(output_file, 'w+') as out_fh:
lcov_file.print_file(out_fh, rewrite_source, self.pp_rewriter.rewrite_record)
else:
for in_path in in_paths:
lcov_file = LcovFile([in_path])
with open(in_path + output_suffix, 'w+') as out_fh:
lcov_file.print_file(out_fh, rewrite_source, self.pp_rewriter.rewrite_record)
if not found_valid:
@ -720,6 +727,8 @@ def main():
help="The suffix to append to output files.")
parser.add_argument("--extra-chrome-manifests", nargs='+',
help="Paths to files containing extra chrome registration.")
parser.add_argument("--output-file", default="",
help="The output file where the results are merged. Leave empty to make the rewriter not merge files.")
parser.add_argument("files", nargs='+',
help="The set of files to process.")
@ -740,8 +749,7 @@ def main():
else:
files.append(f)
for f in files:
rewriter.rewrite_file(f, args.output_suffix)
rewriter.rewrite_files(files, args.output_file, args.output_suffix)
if __name__ == '__main__':
main()