adapt to python3

This commit is contained in:
kabeor 2021-11-21 12:37:28 +08:00
parent 649d4cab66
commit 263f7a280a
1 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,7 @@ import os
def Usage(s):
print 'Usage: {} -t <cstest_path> [-f <file_name.cs>] [-d <directory>]'.format(s)
print('Usage: {} -t <cstest_path> [-f <file_name.cs>] [-d <directory>]'.format(s))
sys.exit(-1)
def get_report_file(toolpath, filepath, getDetails, cmt_out):
@ -19,8 +19,8 @@ def get_report_file(toolpath, filepath, getDetails, cmt_out):
# stdout
failed_tests = []
# print '---> stdout\n', stdout
# print '---> stderr\n', stderr
# print('---> stdout\n', stdout)
# print('---> stderr\n', stderr)
matches = re.finditer(r'\[\s+RUN\s+\]\s+(.*)\n\[\s+FAILED\s+\]', stdout)
for match in matches:
failed_tests.append(match.group(1))
@ -41,12 +41,12 @@ def get_report_file(toolpath, filepath, getDetails, cmt_out):
counter += 1
else:
continue
print '\n[-] There are/is {} failed test(s)'.format(len(details))
print('\n[-] There are/is {} failed test(s)'.format(len(details)))
if len(details) > 0 and getDetails:
print '[-] Detailed report for {}:\n'.format(filepath)
print('[-] Detailed report for {}:\n'.format(filepath))
for c, f, d in details:
print '\t[+] {}: {}\n\t\t{}\n'.format(f, c, d)
print '\n'
print('\t[+] {}: {}\n\t\t{}\n'.format(f, c, d))
print('\n')
return 0
elif len(details) > 0:
for c, f, d in details:
@ -67,7 +67,7 @@ def get_report_folder(toolpath, folderpath, details, cmt_out):
path = root.split(os.sep)
for f in files:
if f.split('.')[-1] == 'cs':
print '[-] Target:', f,
print('[-] Target:', f,)
result *= get_report_file(toolpath, os.sep.join(x for x in path) + os.sep + f, details, cmt_out)
sys.exit(result ^ 1)