mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 03:43:28 +01:00
Added versioning
This commit is contained in:
parent
70c5ef9eed
commit
7673a308d9
98
generateSingleHeader.py
Normal file
98
generateSingleHeader.py
Normal file
@ -0,0 +1,98 @@
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import datetime
|
||||
|
||||
versionParser = re.compile( r'(\s*Version\slibraryVersion\s*=)\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([])
|
||||
catchPath = os.path.realpath(os.path.dirname(sys.argv[0]))
|
||||
rootPath = os.path.join( catchPath, 'include/' )
|
||||
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
||||
#outputPath = os.path.join( catchPath, 'single_include/catch.hpp' )
|
||||
|
||||
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 )
|
||||
print "// #included from: " + 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:
|
||||
print line.rstrip()
|
||||
|
||||
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 generateSingleInclude():
|
||||
v = Version()
|
||||
v.incrementBuildNumber()
|
||||
v.updateVersionFile()
|
||||
print "/*"
|
||||
print " * CATCH v{0}.{1} build {2} ({3} branch)".format( v.majorVersion, v.minorVersion, v.buildNumber, v.branchName )
|
||||
print " * Generated: " + str( datetime.datetime.now() )
|
||||
print " * ----------------------------------------------------------"
|
||||
print " * This file has been merged from multiple headers. Please don't edit it directly"
|
||||
print " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved."
|
||||
print " *"
|
||||
print " * Distributed under the Boost Software License, Version 1.0. (See accompanying"
|
||||
print " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)"
|
||||
print " */"
|
||||
print '#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
||||
print '#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
||||
parseFile( rootPath, 'catch.hpp' )
|
||||
print '#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
||||
print
|
||||
|
||||
#v = Version()
|
||||
#v.incrementBuildNumber()
|
||||
#v.updateVersionFile()
|
||||
generateSingleInclude()
|
@ -1,54 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import datetime
|
||||
|
||||
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( os.path.realpath(os.path.dirname(sys.argv[0])), 'include/' )
|
||||
|
||||
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 )
|
||||
print "// #included from: " + 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:
|
||||
print line.rstrip()
|
||||
|
||||
print "/*"
|
||||
print " * Generated: " + str( datetime.datetime.now() )
|
||||
print " * ----------------------------------------------------------"
|
||||
print " * This file has been merged from multiple headers. Please don't edit it directly"
|
||||
print " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved."
|
||||
print " *"
|
||||
print " * Distributed under the Boost Software License, Version 1.0. (See accompanying"
|
||||
print " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)"
|
||||
print " */"
|
||||
print '#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
||||
print '#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
||||
parseFile( rootPath, 'catch.hpp' )
|
||||
print '#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED'
|
||||
print
|
@ -12,6 +12,7 @@
|
||||
#include "internal/catch_list.hpp"
|
||||
#include "internal/catch_runner_impl.hpp"
|
||||
#include "internal/catch_test_spec.h"
|
||||
#include "internal/catch_version.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
@ -219,7 +220,13 @@ namespace Catch {
|
||||
}
|
||||
|
||||
if( !displayedSpecificOption ) {
|
||||
std::cout << exeName << " is a CATCH host application. Options are as follows:\n\n";
|
||||
std::cout << "\nCATCH v" << libraryVersion.MajorVersion << "."
|
||||
<< libraryVersion.MinorVersion << " build "
|
||||
<< libraryVersion.BuildNumber;
|
||||
if( libraryVersion.BranchName != "master" )
|
||||
std::cout << " (" << libraryVersion.BranchName << " branch)";
|
||||
|
||||
std::cout << "\n\n" << exeName << " is a CATCH host application. Options are as follows:\n\n";
|
||||
showUsage( std::cout );
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "catch_expressionresult_builder.hpp"
|
||||
#include "catch_test_case_info.hpp"
|
||||
#include "catch_tags.hpp"
|
||||
#include "catch_version.hpp"
|
||||
|
||||
#include "../reporters/catch_reporter_basic.hpp"
|
||||
#include "../reporters/catch_reporter_xml.hpp"
|
||||
|
24
include/internal/catch_version.h
Normal file
24
include/internal/catch_version.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Created by Phil on 13/11/2012.
|
||||
* Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
|
||||
|
||||
namespace Catch {
|
||||
|
||||
// Versioning information
|
||||
struct Version {
|
||||
const unsigned int MajorVersion;
|
||||
const unsigned int MinorVersion;
|
||||
const unsigned int BuildNumber;
|
||||
const std::string BranchName;
|
||||
};
|
||||
|
||||
extern Version libraryVersion;
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
|
19
include/internal/catch_version.hpp
Normal file
19
include/internal/catch_version.hpp
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Created by Phil on 14/11/2012.
|
||||
* Copyright 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#ifndef TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||
|
||||
#include "catch_version.h"
|
||||
|
||||
namespace Catch {
|
||||
|
||||
// These numbers are maintained by a script
|
||||
Version libraryVersion = { 0, 9, 1, "integration" };
|
||||
}
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
@ -117,6 +117,7 @@
|
||||
4A6D0C67149B3E3D00DB3EAA /* catch_reporter_junit.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_junit.hpp; sourceTree = "<group>"; };
|
||||
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_xml.hpp; sourceTree = "<group>"; };
|
||||
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_totals.hpp; sourceTree = "<group>"; };
|
||||
4A7DB2CD1652FE4B00FA6523 /* catch_version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = catch_version.h; path = ../../../../include/internal/catch_version.h; sourceTree = "<group>"; };
|
||||
4A8E4DCC160A344100194CBD /* catch_tags.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_tags.hpp; sourceTree = "<group>"; };
|
||||
4A8E4DD0160A352200194CBD /* catch_tags.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_tags.cpp; path = ../../../SelfTest/SurrogateCpps/catch_tags.cpp; sourceTree = "<group>"; };
|
||||
4A90B59B15D0F61A00EF71BC /* catch_interfaces_generators.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_generators.h; sourceTree = "<group>"; };
|
||||
@ -124,6 +125,7 @@
|
||||
4A90B59E15D2521E00EF71BC /* catch_expressionresult_builder.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_expressionresult_builder.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||
4A9D84B11558FC0400FBB209 /* catch_tostring.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_tostring.hpp; sourceTree = "<group>"; };
|
||||
4A9D84B315599AC900FBB209 /* catch_expressionresult_builder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_expressionresult_builder.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||
4AA7B8B4165428BA003155F6 /* catch_version.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = catch_version.hpp; path = ../../../../include/internal/catch_version.hpp; sourceTree = "<group>"; };
|
||||
4AA7FF4115F3E89D009AD7F9 /* BDDTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BDDTests.cpp; sourceTree = "<group>"; };
|
||||
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_console_colour_impl.hpp; sourceTree = "<group>"; };
|
||||
4AB1C73714F97C1300F31DF7 /* catch_console_colour.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_console_colour.hpp; sourceTree = "<group>"; };
|
||||
@ -204,6 +206,8 @@
|
||||
4A6D0C41149B3DE900DB3EAA /* Catch */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4A7DB2CD1652FE4B00FA6523 /* catch_version.h */,
|
||||
4AA7B8B4165428BA003155F6 /* catch_version.hpp */,
|
||||
4A8E4DCF160A34E200194CBD /* SurrogateCpps */,
|
||||
4A6D0C44149B3E1500DB3EAA /* catch.hpp */,
|
||||
4A6D0C42149B3E1500DB3EAA /* catch_runner.hpp */,
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Generated: 2012-11-13 21:45:42.830677
|
||||
* CATCH v0.9 build 1 (integration branch)
|
||||
* Generated: 2012-11-15 22:13:35.214657
|
||||
* ----------------------------------------------------------
|
||||
* This file has been merged from multiple headers. Please don't edit it directly
|
||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||
@ -4160,6 +4161,22 @@ namespace Catch {
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
// #included from: internal/catch_version.h
|
||||
#define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED
|
||||
|
||||
namespace Catch {
|
||||
|
||||
// Versioning information
|
||||
struct Version {
|
||||
const unsigned int MajorVersion;
|
||||
const unsigned int MinorVersion;
|
||||
const unsigned int BuildNumber;
|
||||
const std::string BranchName;
|
||||
};
|
||||
|
||||
extern Version libraryVersion;
|
||||
}
|
||||
|
||||
#include <fstream>
|
||||
#include <stdlib.h>
|
||||
#include <limits>
|
||||
@ -4366,7 +4383,13 @@ namespace Catch {
|
||||
}
|
||||
|
||||
if( !displayedSpecificOption ) {
|
||||
std::cout << exeName << " is a CATCH host application. Options are as follows:\n\n";
|
||||
std::cout << "\nCATCH v" << libraryVersion.MajorVersion << "."
|
||||
<< libraryVersion.MinorVersion << " build "
|
||||
<< libraryVersion.BuildNumber;
|
||||
if( libraryVersion.BranchName != "master" )
|
||||
std::cout << " (" << libraryVersion.BranchName << " branch)";
|
||||
|
||||
std::cout << "\n\n" << exeName << " is a CATCH host application. Options are as follows:\n\n";
|
||||
showUsage( std::cout );
|
||||
}
|
||||
}
|
||||
@ -5346,6 +5369,15 @@ namespace Catch {
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
// #included from: catch_version.hpp
|
||||
#define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||
|
||||
namespace Catch {
|
||||
|
||||
// These numbers are maintained by a script
|
||||
Version libraryVersion = { 0, 9, 1, "integration" };
|
||||
}
|
||||
|
||||
// #included from: ../reporters/catch_reporter_basic.hpp
|
||||
#define TWOBLUECUBES_CATCH_REPORTER_BASIC_HPP_INCLUDED
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user