mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Scripts for running approval tests using diff.
Runs CATCH, filters results (truncates paths, removes hex digits which are probably pointers) then diffs the results)
This commit is contained in:
parent
4b36001698
commit
22694335a5
46
approvalTests.py
Normal file
46
approvalTests.py
Normal file
@ -0,0 +1,46 @@
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
filenameParser = re.compile( r'\s*.*/(.*\.cpp)(.*)' )
|
||||
hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
|
||||
|
||||
catchPath = os.path.realpath(os.path.dirname(sys.argv[0]))
|
||||
baselinesPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/results.txt' )
|
||||
rawResultsPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/_rawResults.tmp' )
|
||||
filteredResultsPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/newResults.txt' )
|
||||
|
||||
cmdPath = sys.argv[1]
|
||||
|
||||
f = open( rawResultsPath, 'w' )
|
||||
subprocess.call([ cmdPath, "~dummy", "-s", "-w", "NoAssertions" ], stdout=f, stderr=f )
|
||||
f.close()
|
||||
|
||||
rawFile = open( rawResultsPath, 'r' )
|
||||
filteredFile = open( filteredResultsPath, 'w' )
|
||||
for line in rawFile:
|
||||
m = filenameParser.match( line )
|
||||
if m:
|
||||
line = m.group(1) + m.group(2)
|
||||
|
||||
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)
|
13
approve.py
Normal file
13
approve.py
Normal file
@ -0,0 +1,13 @@
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
catchPath = os.path.realpath(os.path.dirname(sys.argv[0]))
|
||||
baselinesPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/results.txt' )
|
||||
filteredResultsPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/newResults.txt' )
|
||||
|
||||
if os.path.isfile( filteredResultsPath ):
|
||||
os.remove( baselinesPath )
|
||||
os.rename( filteredResultsPath, baselinesPath )
|
||||
else:
|
||||
print "approval file " + filteredResultsPath + " does not exist"
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user