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

summaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorPhil Nash2015-12-04 10:19:08 +0000
committerPhil Nash2015-12-04 10:19:08 +0000
commitfdc42d0af47f58fa13a42b685bbeaf55a8347673 (patch)
tree779ff3d692eeffd33353d89ad7697a592ab5201e /scripts
parentd758428fe297655e558a86cc6a013fcb1bcc8c7d (diff)
parentd274fc571c3980b5ac04cbe1416cf2205e6c99f7 (diff)
downloadcatch3-1.3.0.tar.gz
Merged from develop branchv1.3.0
- now v1.3.0
Diffstat (limited to 'scripts')
-rw-r--r--scripts/approvalTests.py9
-rw-r--r--scripts/fixTrailingWhitespace.py46
2 files changed, 53 insertions, 2 deletions
diff --git a/scripts/approvalTests.py b/scripts/approvalTests.py
index 92e2876c..618812f8 100644
--- a/scripts/approvalTests.py
+++ b/scripts/approvalTests.py
@@ -15,7 +15,8 @@ pathParser = re.compile( r'(.*?)/(.*\..pp)(.*)' )
lineNumberParser = re.compile( r'(.*)line="[0-9]*"(.*)' )
hexParser = re.compile( r'(.*)\b(0[xX][0-9a-fA-F]+)\b(.*)' )
durationsParser = re.compile( r'(.*)time="[0-9]*\.[0-9]*"(.*)' )
-versionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9].?( .*)' )
+versionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*(.*)' )
+devVersionParser = re.compile( r'(.*?)Catch v[0-9]*\.[0-9]*\.[0-9]*-develop\.[0-9]*(.*)' )
if len(sys.argv) == 2:
cmdPath = sys.argv[1]
@@ -41,9 +42,13 @@ def filterLine( line ):
if path.startswith( catchPath ):
path = path[1+len(catchPath):]
line = m.group(1) + path + m.group(3)
- m = versionParser.match( line )
+ 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)
while True:
m = hexParser.match( line )
diff --git a/scripts/fixTrailingWhitespace.py b/scripts/fixTrailingWhitespace.py
new file mode 100644
index 00000000..a1b6bbe8
--- /dev/null
+++ b/scripts/fixTrailingWhitespace.py
@@ -0,0 +1,46 @@
+from __future__ import print_function
+import os
+from scriptCommon import catchPath
+
+changedFiles = 0
+
+def isSourceFile( path ):
+ return path.endswith( ".cpp" ) or path.endswith( ".h" ) or path.endswith( ".hpp" )
+
+def fixAllFilesInDir( dir ):
+ for f in os.listdir( dir ):
+ path = os.path.join( dir,f )
+ if os.path.isfile( path ):
+ if isSourceFile( path ):
+ fixFile( path )
+ else:
+ fixAllFilesInDir( path )
+
+def fixFile( path ):
+ f = open( path, 'r' )
+ lines = []
+ changed = 0
+ for line in f:
+ trimmed = line.rstrip() + "\n"
+ if trimmed != line:
+ changed = changed +1
+ lines.append( trimmed )
+ f.close()
+ if changed > 0:
+ global changedFiles
+ changedFiles = changedFiles + 1
+ print( path + ":" )
+ print( " - fixed " + str(changed) + " line(s)" )
+ altPath = path + ".backup"
+ os.rename( path, altPath )
+ f2 = open( path, 'w' )
+ for line in lines:
+ f2.write( line )
+ f2.close()
+ os.remove( altPath )
+
+fixAllFilesInDir(catchPath)
+if changedFiles > 0:
+ print( "Fixed " + str(changedFiles) + " file(s)" )
+else:
+ print( "No trailing whitespace found" )