def print_output(obj):
# to-do:
# Error while executing code
if obj['status'] != 0:
print ( '~ Test #{} - '.format(obj['testcase']) + Fore.RED + 'ERROR')
# In some cases the process spawn by cftool returns SIGSEGV (-11)
# and process.stderr is empty
if obj['stderr'] == '' and obj['status'] == -11:
print ('Process exited with SIGSEGV, probably because of a segmentation fault')
else:
print (obj['stderr'])
return
# split time between numbers and letters
m = re.split(r'(\d+)', obj['time'])
if int(m[1]) >= 5 and m[2] in ['s', 'm', 'h']:
print ( '~ Test #{} - '.format(obj['testcase']) + Fore.RED + '{}'.format(obj['time']) )
else:
print ( '~ Test #{} - {}'.format(obj['testcase'], obj['time']) )
stdout = obj['stdout']
expected = obj['expected']
if compare_outputs(stdout, expected):
print (Fore.GREEN + stdout)
print ('')
else:
print (Fore.RED + stdout)
print ('')
print (Fore.LIGHTBLACK_EX + 'Expected:')
print (Fore.LIGHTBLACK_EX + expected)
print ('')
评论列表
文章目录