Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorPhil Nash2013-06-28 14:11:28 +0100
committerPhil Nash2013-06-28 14:11:28 +0100
commit235204393a45900a9f8d92f14eaaf287b9f178ec (patch)
treec74dbdd52a192a2461cd9fa88d2bf0ff6bbef83f /scripts
parent53f128fac5c366fa75e037ff19007b641ee3b608 (diff)
parenta76d93ad548ff553799d7f96d60593a9fee97885 (diff)
downloadcatch3-235204393a45900a9f8d92f14eaaf287b9f178ec.tar.gz
Big merge from Integration
- now v1.0 build 1
Diffstat (limited to 'scripts')
-rw-r--r--scripts/approvalTests.py57
-rw-r--r--scripts/approve.py14
-rw-r--r--scripts/generateSingleHeader.py117
-rw-r--r--scripts/scriptCommon.py4
4 files changed, 192 insertions, 0 deletions
diff --git a/scripts/approvalTests.py b/scripts/approvalTests.py
new file mode 100644
index 00000000..14a5354e
--- /dev/null
+++ b/scripts/approvalTests.py
@@ -0,0 +1,57 @@
+import os
+import sys
+import subprocess
+import re
+
+from scriptCommon import catchPath
+
+filenameParser = re.compile( r'\s*.*/(.*\..pp)(.*)' )
+hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
+
+#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' )
+
+if len(sys.argv) == 2:
+ cmdPath = sys.argv[1]
+else:
+ cmdPath = os.path.join( catchPath, 'projects/XCode4/CatchSelfTest/DerivedData/CatchSelfTest/Build/Products/Debug/CatchSelfTest' )
+
+f = open( rawResultsPath, 'w' )
+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 )
+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 )
+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 )
+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) \ No newline at end of file
diff --git a/scripts/approve.py b/scripts/approve.py
new file mode 100644
index 00000000..9302ae56
--- /dev/null
+++ b/scripts/approve.py
@@ -0,0 +1,14 @@
+import os
+import sys
+import shutil
+
+from scriptCommon import catchPath
+
+baselinesPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/approvedResults.txt' )
+filteredResultsPath = os.path.join( catchPath, 'projects/SelfTest/Baselines/unapprovedResults.txt' )
+
+if os.path.isfile( filteredResultsPath ):
+ os.remove( baselinesPath )
+ os.rename( filteredResultsPath, baselinesPath )
+else:
+ print "approval file " + filteredResultsPath + " does not exist"
diff --git a/scripts/generateSingleHeader.py b/scripts/generateSingleHeader.py
new file mode 100644
index 00000000..ba4c5cde
--- /dev/null
+++ b/scripts/generateSingleHeader.py
@@ -0,0 +1,117 @@
+import os
+import sys
+import re
+import datetime
+
+from scriptCommon import catchPath
+
+versionParser = re.compile( r'(\s*Version\slibraryVersion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*\).*' )
+includesParser = re.compile( r'\s*#include\s*"(.*)"' )
+guardParser = re.compile( r'\s*#.*_INCLUDED')
+defineParser = re.compile( r'\s*#define')
+commentParser1 = re.compile( r'^\s*/\*')
+commentParser2 = re.compile( r'^\s*\*')
+blankParser = re.compile( r'^\s*$')
+seenHeaders = set([])
+rootPath = os.path.join( catchPath, 'include/' )
+versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
+readmePath = os.path.join( catchPath, "README.md" )
+outputPath = os.path.join( catchPath, 'single_include/catch.hpp' )
+
+bumpVersion = len(sys.argv) < 2 or sys.argv[1] <> "nobump"
+
+out = open( outputPath, 'w' )
+
+def parseFile( path, filename ):
+ f = open( path + filename, 'r' )
+ blanks = 0
+ for line in f:
+ m = includesParser.match( line )
+ if m:
+ header = m.group(1)
+ headerPath, sep, headerFile = header.rpartition( "/" )
+ if not headerFile in seenHeaders:
+ seenHeaders.add( headerFile )
+ out.write( "// #included from: {0}\n".format( header ) )
+ if( headerPath == "internal" and path.endswith( "internal/" ) ):
+ headerPath = ""
+ sep = ""
+ if os.path.exists( path + headerPath + sep + headerFile ):
+ parseFile( path + headerPath + sep, headerFile )
+ else:
+ parseFile( rootPath + headerPath + sep, headerFile )
+ elif (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ):
+ if blankParser.match( line ):
+ blanks = blanks + 1
+ else:
+ blanks = 0
+ if blanks < 2:
+ out.write( line.rstrip() + "\n" )
+
+class Version:
+ def __init__(self):
+ f = open( versionPath, 'r' )
+ for line in f:
+ m = versionParser.match( line )
+ if m:
+ self.variableDecl = m.group(1)
+ self.majorVersion = int(m.group(2))
+ self.minorVersion = int(m.group(3))
+ self.buildNumber = int(m.group(4))
+ self.branchName = m.group(5)
+ f.close()
+
+ def incrementBuildNumber(self):
+ self.buildNumber = self.buildNumber+1
+
+ def updateVersionFile(self):
+ f = open( versionPath, 'r' )
+ lines = []
+ for line in f:
+ m = versionParser.match( line )
+ if m:
+ lines.append( '{0}( {1}, {2}, {3}, "{4}" );'.format( self.variableDecl, self.majorVersion, self.minorVersion, self.buildNumber, self.branchName ) )
+ else:
+ lines.append( line.rstrip() )
+ f.close()
+ f = open( versionPath, 'w' )
+ for line in lines:
+ f.write( line + "\n" )
+
+ def updateReadmeFile(self):
+ f = open( readmePath, 'r' )
+ lines = []
+ for line in f:
+ lines.append( line.rstrip() )
+ f.close()
+ f = open( readmePath, 'w' )
+ for line in lines:
+ if line.startswith( "*v" ):
+ f.write( '*v{0}.{1} build {2} ({3} branch)*\n'.format( self.majorVersion, self.minorVersion, self.buildNumber, self.branchName ) )
+ else:
+ f.write( line + "\n" )
+
+def generateSingleInclude():
+ v = Version()
+ if bumpVersion:
+ v.incrementBuildNumber()
+ v.updateVersionFile()
+ v.updateReadmeFile()
+ out.write( "/*\n" )
+ out.write( " * CATCH v{0}.{1} build {2} ({3} branch)\n".format( v.majorVersion, v.minorVersion, v.buildNumber, v.branchName ) )
+ out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
+ out.write( " * ----------------------------------------------------------\n" )
+ out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
+ out.write( " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.\n" )
+ out.write( " *\n" )
+ out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
+ out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
+ out.write( " */\n" )
+ out.write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
+ out.write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
+
+ parseFile( rootPath, 'catch.hpp' )
+
+ out.write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
+
+generateSingleInclude()
diff --git a/scripts/scriptCommon.py b/scripts/scriptCommon.py
new file mode 100644
index 00000000..5710ba9c
--- /dev/null
+++ b/scripts/scriptCommon.py
@@ -0,0 +1,4 @@
+import os
+import sys
+
+catchPath = os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0]))) \ No newline at end of file