Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Fix generating single header using Python3

Commit
aa7b0c91044ec61c1fd594ed057b2dedf8d2555c
Author
Martin Hořeňovský ·
Parents
375f2052bde3

Files · Download .tar.gz

Changes

 scripts/generateSingleHeader.py | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/scripts/generateSingleHeader.py b/scripts/generateSingleHeader.py
index 633e8c12..471b872e 100755
--- a/scripts/generateSingleHeader.py
+++ b/scripts/generateSingleHeader.py
@@ -51,7 +51,7 @@ def generate(v):
 
     def write( line ):
         if globals['includeImpl'] or globals['implIfDefs'] == -1:
-            out.write( line.decode('utf-8') )
+            out.write( line )
 
     def insertCpps():
         dirs = [os.path.join( rootPath, s) for s in ['', 'internal', 'reporters']]
@@ -65,9 +65,9 @@ def generate(v):
             parseFile(dir, name)
 
     def parseFile( path, filename ):
-        f = open( os.path.join(path, filename), 'r' )
+        f = io.open( os.path.join(path, filename), 'r', encoding='utf-8' )
         blanks = 0
-        write( "// start {0}\n".format( filename ) )
+        write( u"// start {0}\n".format( filename ) )
         for line in f:
             if '// ~*~* CATCH_CPP_STITCH_PLACE *~*~' in line:
                 insertCpps()
@@ -102,25 +102,25 @@ def generate(v):
                         blanks = 0
                     if blanks < 2 and not defineParser.match(line):
                         write( line.rstrip() + "\n" )
-        write( '// end {}\n'.format(filename) )
-
-
-    write( "/*\n" )
-    write( " *  Catch v{0}\n".format( v.getVersionString() ) )
-    write( " *  Generated: {0}\n".format( datetime.datetime.now() ) )
-    write( " *  ----------------------------------------------------------\n" )
-    write( " *  This file has been merged from multiple headers. Please don't edit it directly\n" )
-    write( " *  Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) )
-    write( " *\n" )
-    write( " *  Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
-    write( " *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
-    write( " */\n" )
-    write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
-    write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
+        write( u'// end {}\n'.format(filename) )
+
+
+    write( u"/*\n" )
+    write( u" *  Catch v{0}\n".format( v.getVersionString() ) )
+    write( u" *  Generated: {0}\n".format( datetime.datetime.now() ) )
+    write( u" *  ----------------------------------------------------------\n" )
+    write( u" *  This file has been merged from multiple headers. Please don't edit it directly\n" )
+    write( u" *  Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) )
+    write( u" *\n" )
+    write( u" *  Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
+    write( u" *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
+    write( u" */\n" )
+    write( u"#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
+    write( u"#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
 
     parseFile( rootPath, 'catch.hpp' )
 
-    write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
+    write( u"#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
     out.close()
     print ("Generated single include for Catch v{0}\n".format( v.getVersionString() ) )