2012-11-29 03:41:17 -05:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import re
|
|
|
|
|
2013-04-24 13:58:57 -04:00
|
|
|
from scriptCommon import catchPath
|
|
|
|
|
2013-06-29 06:59:49 -04:00
|
|
|
filenameParser = re.compile( r'\s*.*/(.*\..pp):([0-9]*)(.*)' )
|
2013-06-29 07:04:38 -04:00
|
|
|
lineNumberParser = re.compile( r'(.*)line="[0-9]*"(.*)' )
|
2012-11-29 03:41:17 -05:00
|
|
|
hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
|
|
|
|
|
2013-04-24 13:58:57 -04:00
|
|
|
#catchPath = os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0])))
|
|
|
|
|
|
|
|
baselinesPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/approvedResults.txt' )
|
|
|
|
rawResultsPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/_rawResults.tmp' )
|
|
|
|
filteredResultsPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/unapprovedResults.txt' )
|
2012-11-29 03:41:17 -05:00
|
|
|
|
2013-08-05 07:22:23 -04:00
|
|
|
print "len(sys.argv) = " + str(len(sys.argv))
|
2013-08-05 07:16:34 -04:00
|
|
|
print "sys.argv[0] = " + sys.argv[0]
|
|
|
|
print "sys.argv[1] = " + sys.argv[1]
|
|
|
|
|
2013-02-02 14:58:04 -05:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
cmdPath = sys.argv[1]
|
|
|
|
else:
|
2013-04-24 13:58:57 -04:00
|
|
|
cmdPath = os.path.join( catchPath, 'projects/XCode4/CatchSelfTest/DerivedData/CatchSelfTest/Build/Products/Debug/CatchSelfTest' )
|
2012-11-29 03:41:17 -05:00
|
|
|
|
2013-08-05 07:10:24 -04:00
|
|
|
print "Using executable: " + cmdPath
|
|
|
|
|
2012-11-29 03:41:17 -05:00
|
|
|
f = open( rawResultsPath, 'w' )
|
2013-06-28 11:23:14 -04:00
|
|
|
subprocess.call([ cmdPath, "~dummy", "-r", "console" ], stdout=f, stderr=f )
|
2012-12-09 16:46:15 -05:00
|
|
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "console" ], stdout=f, stderr=f )
|
|
|
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "console", "-a", "4" ], stdout=f, stderr=f )
|
2012-11-29 03:49:32 -05:00
|
|
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "junit" ], stdout=f, stderr=f )
|
|
|
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "xml" ], stdout=f, stderr=f )
|
2013-01-03 14:19:00 -05:00
|
|
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "basic" ], stdout=f, stderr=f )
|
|
|
|
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions", "-r", "basic", "-a", "4" ], stdout=f, stderr=f )
|
2012-11-29 03:41:17 -05:00
|
|
|
f.close()
|
|
|
|
|
|
|
|
rawFile = open( rawResultsPath, 'r' )
|
|
|
|
filteredFile = open( filteredResultsPath, 'w' )
|
|
|
|
for line in rawFile:
|
|
|
|
m = filenameParser.match( line )
|
|
|
|
if m:
|
2013-06-29 06:59:49 -04:00
|
|
|
line = m.group(1) + m.group(3)
|
2013-06-29 07:04:38 -04:00
|
|
|
else:
|
|
|
|
m = lineNumberParser.match( line )
|
|
|
|
if m:
|
|
|
|
line = m.group(1) + m.group(2)
|
2012-11-29 03:41:17 -05:00
|
|
|
|
|
|
|
while True:
|
|
|
|
m = hexParser.match( line )
|
|
|
|
if m:
|
|
|
|
line = m.group(1) + "0x<hex digits>" + m.group(3)
|
|
|
|
else:
|
|
|
|
break
|
|
|
|
filteredFile.write( line.rstrip() + "\n" )
|
|
|
|
filteredFile.close()
|
|
|
|
rawFile.close()
|
|
|
|
|
|
|
|
os.remove( rawResultsPath )
|
|
|
|
print
|
|
|
|
diffResult = subprocess.call([ "diff", baselinesPath, filteredResultsPath ] )
|
|
|
|
if diffResult == 0:
|
|
|
|
os.remove( filteredResultsPath )
|
|
|
|
print "\033[92mResults matched"
|
|
|
|
else:
|
|
|
|
print "\n****************************\n\033[91mResults differed"
|
|
|
|
print "\033[0m"
|
|
|
|
exit( diffResult)
|