mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add a script to cleanup the file listing before sending to Coveralls
GCC has a "feature" where it doesn't realize that files in the src/zeek/... tree are the same as files in the normal 'src/' tree. This leads the coverage script to send duplicates to Coveralls and pollute the display with them. The new script scrapes the intermediate output from lcov and de-duplicates anything in src/zeek/ to be just from src/.
This commit is contained in:
parent
e460d66e03
commit
a05356eb79
2 changed files with 55 additions and 2 deletions
47
testing/coverage/coverage_cleanup.py
Executable file
47
testing/coverage/coverage_cleanup.py
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print("Expected one argument containing the file to clean")
|
||||
sys.exit(-1)
|
||||
|
||||
with open(sys.argv[1], 'r') as f:
|
||||
|
||||
files = {}
|
||||
cur_file = ''
|
||||
lines = f.readlines()
|
||||
|
||||
for line in lines:
|
||||
|
||||
if line == 'end_of_record':
|
||||
cur_file = ''
|
||||
continue
|
||||
|
||||
parts = line.split(':', 1)
|
||||
if parts[0] == 'SF':
|
||||
cur_file = parts[1].strip()
|
||||
while cur_file.find('src/zeek/') != -1:
|
||||
cur_file = cur_file.replace('src/zeek/', 'src/', 1)
|
||||
|
||||
if cur_file not in files:
|
||||
files[cur_file] = {}
|
||||
elif parts[0] == 'DA':
|
||||
da_parts = parts[1].split(',')
|
||||
line = int(da_parts[0])
|
||||
count = int(da_parts[1])
|
||||
|
||||
if files[cur_file].get(line, 0) == 0:
|
||||
files[cur_file][line] = count
|
||||
|
||||
for name in files:
|
||||
|
||||
print('TN:')
|
||||
print('SF:{}'.format(name))
|
||||
|
||||
das = list(files[name].keys())
|
||||
das.sort()
|
||||
|
||||
for da in das:
|
||||
print('DA:{},{}'.format(da, files[name][da]))
|
||||
print('end_of_record')
|
Loading…
Add table
Add a link
Reference in a new issue