attempt at optimizing parse_test_output.py

This commit is contained in:
Arvid Norberg 2013-10-06 01:16:50 +00:00
parent d8c51a29eb
commit 861b6c4c71
1 changed files with 13 additions and 14 deletions

View File

@ -39,17 +39,17 @@ import json
# TODO: different parsers could be run on output from different actions # TODO: different parsers could be run on output from different actions
# if we would use the xml output in stead of stdout/stderr # if we would use the xml output in stead of stdout/stderr
def style_output(o): def style_output(logfile, outfile):
ret = ''
subtle = False subtle = False
for l in o.split('\n'): for l in logfile.split('\n'):
l = l.encode('utf-8')
l = l.replace('<', '&lt;') l = l.replace('<', '&lt;')
l = l.replace('>', '&gt;') l = l.replace('>', '&gt;')
if 'TEST_CHECK' in l or 'TEST_EQUAL_ERROR' in l or l.startswith('EXIT STATUS: ') or \ if 'TEST_CHECK' in l or 'TEST_EQUAL_ERROR' in l or l.startswith('EXIT STATUS: ') or \
' second time limit exceeded' in l or l.startswith('signal: SIG'): ' second time limit exceeded' in l or l.startswith('signal: SIG'):
ret += '<span class="test-error">%s</span>\n' % l print >>outfile, '<span class="test-error">%s</span>' % l
elif '**passed**' in l: elif '**passed**' in l:
ret += '<span class="test-pass">%s</span>\n' % l print >>outfile, '<span class="test-pass">%s</span>' % l
elif ': error: ' in l or ': fatal error: ' in l or ' : fatal error ' in l or \ elif ': error: ' in l or ': fatal error: ' in l or ' : fatal error ' in l or \
'failed to write output file' in l or ') : error C' in l or \ 'failed to write output file' in l or ') : error C' in l or \
' : error LNK' in l or ': undefined reference to ' in l or \ ' : error LNK' in l or ': undefined reference to ' in l or \
@ -58,18 +58,17 @@ def style_output(o):
'Invalid write of size' in l or \ 'Invalid write of size' in l or \
'Use of uninitialised value of size' in l or \ 'Use of uninitialised value of size' in l or \
'Uninitialised byte(s) found during' in l: 'Uninitialised byte(s) found during' in l:
ret += '<span class="compile-error">%s</span>\n' % l print >>outfile, '<span class="compile-error">%s</span>' % l
elif ': warning: ' in l or ') : warning C' in l or \ elif ': warning: ' in l or ') : warning C' in l or \
'Uninitialised value was created by a' in l or \ 'Uninitialised value was created by a' in l or \
'bytes after a block of size' in l: 'bytes after a block of size' in l:
ret += '<span class="compile-warning">%s</span>\n' % l.strip() print >>outfile, '<span class="compile-warning">%s</span>' % l.strip()
elif l == '====== END OUTPUT ======' and not subtle: elif l == '====== END OUTPUT ======' and not subtle:
ret += '<span class="subtle">%s\n' % l print >>outfile, '<span class="subtle">%s' % l
subtle = True subtle = True
else: else:
ret += '%s\n' % l print >>outfile, '%s' % l
if subtle: ret += '</span>' if subtle: print >>outfile, '</span>'
return ret
def modification_time(file): def modification_time(file):
mtime = 0 mtime = 0
@ -100,10 +99,10 @@ def save_log_file(log_name, project_name, branch_name, test_name, timestamp, dat
pre { color: #999; white-space: pre-wrap; word-wrap: break-word; } pre { color: #999; white-space: pre-wrap; word-wrap: break-word; }
</style> </style>
</head><body><h1>%s - %s</h1>''' % (project_name, branch_name, project_name, branch_name) </head><body><h1>%s - %s</h1>''' % (project_name, branch_name, project_name, branch_name)
print >>html, '<h3>%s</h3><pre>%s</pre>' % \ print >>html, '<h3>%s</h3><pre>' % test_name.encode('utf-8')
(test_name.encode('utf-8'), style_output(data).encode('utf-8')) style_output(data, html)
print >>html, '</body></html>' print >>html, '</pre></body></html>'
html.close() html.close()
sys.stdout.write('.') sys.stdout.write('.')
sys.stdout.flush() sys.stdout.flush()