Commit a742e9d5 authored by Daniel Smith's avatar Daniel Smith

Initial commit

parents
Pipeline #1341 canceled with stages
import os
import argparse
import re
failedTests = {} # Typing.dict()
totalCount = 0
def findFailedTests(logfile: str):
global totalCount
pattern = re.compile(r'[0-9]{1,}(?<!0) failed')
with open(logfile) as log:
logtext = log.read()
if pattern.search(logtext):
with open("{0}_failures.txt".format(logfile[:-4]), mode='w+') as outfile:
for match in pattern.finditer(logtext):
tstnameindex = 0
tstnameindex = logtext.rfind("********* Start testing of ", 0, match.span()[0]) + 27
tstname = logtext[tstnameindex:
logtext.find("*********", tstnameindex)-1]
print("{0}: {1}".format(tstname,match.group(0))) # Print the test name and count failed.
outfile.writelines("{0}: {1}\r\n".format(tstname,match.group(0)))
if int(re.match(r'[0-9]{0,}', match.group(0)).group(0)) > 9:
outfile.writelines("Too many fail cases. Not printing the failures here. See the original log for failure details.")
print("Too many fail cases. Not printing the failures here. See the original log for failure details.")
break
logsnip = logtext[tstnameindex : logtext.find("********* Finished testing of ", tstnameindex)]
for failcasematch in re.finditer('FAIL! : ', logsnip):
failcasestring = logsnip[failcasematch.span()[0] : logsnip.find('\n', logsnip.find("Loc: ", failcasematch.span()[0]))]
print("{0}\r\n".format(failcasestring))
outfile.writelines("{0}\r\n".format(failcasestring))
totalCount += 1
print("\r\n")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--logdir',dest='logDir', type=str,
required=True, help='The full path to a directory of logs')
args = parser.parse_args()
logfiles = os.listdir(args.logDir)
print(logfiles)
for logfile in logfiles:
print(logfile)
findFailedTests(os.path.join(args.logDir, logfile))
print("total failed test applications: {0}".format(totalCount))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment