Skip to content
This repository has been archived by the owner on Jun 10, 2024. It is now read-only.

Commit

Permalink
Added coveralls merge
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlucas committed Aug 16, 2015
1 parent da81dc8 commit e2a26ec
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tool/coveralls_merge.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python

import json
import os
import sys

def find_by_name(source_files_json, name):
for j in source_files_json:
if j['name'] == name:
return j

return None

def merge_source_files(master, source):
for sf in source:
dest_sf = find_by_name(master, sf['name'])
if dest_sf is None:
master.append(sf)
continue

assert len(dest_sf['coverage']) == len(sf['coverage'])

for i, line in enumerate(sf['coverage']):
if line is None:
continue

if dest_sf['coverage'][i] is None:
dest_sf['coverage'][i] = 0


dest_sf['coverage'][i] += line

def get_json_from_file(fpath):
with open(fpath, 'rb') as fp:
return json.load(fp)

def main():
out = {}
out['source_files'] = []

sources = []

for f in sys.argv[1:]:
assert os.path.isfile(f)
sources.append(get_json_from_file(f))

for s in sources:
merge_source_files(out['source_files'], s['source_files'])

print(json.dumps(out))

if __name__ == '__main__':
main()

0 comments on commit e2a26ec

Please sign in to comment.