mirror of https://github.com/catchorg/Catch2.git
simplify output filtering in approvalTests.py
This commit is contained in:
parent
227598af47
commit
d38b9266e7
|
@ -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
|
||||||
|
line = line.replace(catchPath + '/', '')
|
||||||
|
|
||||||
|
# strip source line numbers
|
||||||
|
m = filelocParser.match(line)
|
||||||
if m:
|
if m:
|
||||||
line = m.group(2) + m.group(3)
|
# note that this also strips directories, leaving only the filename
|
||||||
m2 = filelineParser.match(line)
|
filename, lnum = m.groups()
|
||||||
if m2:
|
lnum = "<line number>" if lnum else ""
|
||||||
line = m2.group(1) + "<line number>" + m2.group(3)
|
line = filename + lnum + line[m.end():]
|
||||||
else:
|
else:
|
||||||
m2 = lineNumberParser.match(line)
|
line = lineNumberParser.sub(" ", 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 Catch version number
|
||||||
if m:
|
line = versionParser.sub("<version>", line)
|
||||||
line = m.group(1) + "0" + m.group(3)
|
|
||||||
|
|
||||||
m = exeNameParser.match(line)
|
# replace *null* with 0
|
||||||
if m:
|
line = nullParser.sub("0", line)
|
||||||
line = m.group(1) + "<exe-name>" + m.group(3)
|
|
||||||
|
|
||||||
while True:
|
# strip executable name
|
||||||
m = hexParser.match(line)
|
line = exeNameParser.sub("<exe-name>", line)
|
||||||
if m:
|
|
||||||
line = m.group(1) + "0x<hex digits>" + m.group(3)
|
# strip hexadecimal numbers (presumably pointer values)
|
||||||
else:
|
line = hexParser.sub("0x<hex digits>", line)
|
||||||
break
|
|
||||||
m = durationsParser.match(line)
|
# strip durations and timestamps
|
||||||
if m:
|
line = durationsParser.sub(' time="{duration}"', line)
|
||||||
line = m.group(1) + 'time="{duration}"' + m.group(2)
|
line = timestampsParser.sub(' timestamp="{iso8601-timestamp}"', line)
|
||||||
m = timestampsParser.match(line)
|
|
||||||
if m:
|
|
||||||
line = m.group(1) + 'timestamp="{iso8601-timestamp}"' + m.group(2)
|
|
||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue