simplify output filtering in approvalTests.py

This commit is contained in:
Mickey Rose 2017-01-19 15:15:06 +01:00
parent ee0ca512ea
commit a09dfd1731

View File

@ -10,17 +10,14 @@ from scriptCommon import catchPath
rootPath = os.path.join(catchPath, 'projects/SelfTest/Baselines') rootPath = os.path.join(catchPath, 'projects/SelfTest/Baselines')
filenameParser = re.compile(r'(.*)/(.*\..pp:)(.*)') filelocParser = re.compile(r'.*/(.+\.[ch]pp:)([0-9]*)')
filelineParser = re.compile(r'(.*\..pp:)([0-9]*)(.*)') lineNumberParser = re.compile(r' line="[0-9]*"')
pathParser = re.compile(r'(.*?)/(.*\..pp)(.*)') hexParser = re.compile(r'\b(0[xX][0-9a-fA-F]+)\b')
lineNumberParser = re.compile(r'(.*)line="[0-9]*"(.*)') durationsParser = re.compile(r' time="[0-9]*\.[0-9]*"')
hexParser = re.compile(r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)') timestampsParser = re.compile(r' timestamp="\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z"')
durationsParser = re.compile(r'(.*)time="[0-9]*\.[0-9]*"(.*)') versionParser = re.compile(r'Catch v[0-9]+\.[0-9]+\.[0-9]+(-develop\.[0-9]+)?')
timestampsParser = re.compile(r'(.*)timestamp="\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z"(.*)') nullParser = re.compile(r'\b(__null|nullptr)\b')
versionParser = re.compile(r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*(.*)') exeNameParser = re.compile(r'\b(CatchSelfTest|SelfTest)\b')
devVersionParser = re.compile(r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*-develop\.[0-9]*(.*)')
nullParser = re.compile(r'(.*?)\b(__null|nullptr)\b(.*)')
exeNameParser = re.compile(r'(.*?)\b(CatchSelfTest|SelfTest)\b(.*)')
if len(sys.argv) == 2: if len(sys.argv) == 2:
cmdPath = sys.argv[1] cmdPath = sys.argv[1]
@ -33,50 +30,34 @@ if not cmdPath.startswith("/"):
overallResult = 0 overallResult = 0
def filterLine(line): def filterLine(line):
m = filenameParser.match(line) # make paths relative to Catch root
if m: line = line.replace(catchPath + '/', '')
line = m.group(2) + m.group(3)
m2 = filelineParser.match(line)
if m2:
line = m2.group(1) + "<line number>" + m2.group(3)
else:
m2 = lineNumberParser.match(line)
if m2:
line = m2.group(1) + m2.group(2)
m = pathParser.match(line)
if m:
path = "/" + m.group(2)
if path.startswith(catchPath):
path = path[1 + len(catchPath):]
line = m.group(1) + path + m.group(3)
m = devVersionParser.match(line)
if m:
line = m.group(1) + "<version>" + m.group(2)
else:
m = versionParser.match(line)
if m:
line = m.group(1) + "<version>" + m.group(2)
m = nullParser.match(line) # strip source line numbers
m = filelocParser.match(line)
if m: if m:
line = m.group(1) + "0" + m.group(3) # note that this also strips directories, leaving only the filename
filename, lnum = m.groups()
m = exeNameParser.match(line) lnum = "<line number>" if lnum else ""
if m: line = filename + lnum + line[m.end():]
line = m.group(1) + "<exe-name>" + m.group(3)
while True:
m = hexParser.match(line)
if m:
line = m.group(1) + "0x<hex digits>" + m.group(3)
else: else:
break line = lineNumberParser.sub(" ", line)
m = durationsParser.match(line)
if m: # strip Catch version number
line = m.group(1) + 'time="{duration}"' + m.group(2) line = versionParser.sub("<version>", line)
m = timestampsParser.match(line)
if m: # replace *null* with 0
line = m.group(1) + 'timestamp="{iso8601-timestamp}"' + m.group(2) line = nullParser.sub("0", line)
# strip executable name
line = exeNameParser.sub("<exe-name>", line)
# strip hexadecimal numbers (presumably pointer values)
line = hexParser.sub("0x<hex digits>", line)
# strip durations and timestamps
line = durationsParser.sub(' time="{duration}"', line)
line = timestampsParser.sub(' timestamp="{iso8601-timestamp}"', line)
return line return line