This commit is contained in:
Phil Nash 2017-06-27 11:48:55 +01:00
commit df7c5622b9
9 changed files with 88 additions and 4 deletions

16
conanfile.py Normal file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python
from conans import ConanFile
class CatchConan(ConanFile):
name = "Catch"
version = "1.9.5"
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD"
author = "philsquared"
generators = "cmake"
exports_sources = "single_include/*"
url = "https://github.com/philsquared/Catch"
license = "BSL-1.0"
def package(self):
self.copy(pattern="catch.hpp", src="single_include", dst="include")

View File

@ -7,5 +7,6 @@ v = Version()
v.incrementBuildNumber()
v.updateVersionFile()
v.updateReadmeFile()
v.updateConanFile()
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )

View File

@ -7,5 +7,6 @@ v = Version()
v.incrementMajorVersion()
v.updateVersionFile()
v.updateReadmeFile()
v.updateConanFile()
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )

View File

@ -7,5 +7,6 @@ v = Version()
v.incrementMinorVersion()
v.updateVersionFile()
v.updateReadmeFile()
v.updateConanFile()
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )

View File

@ -7,5 +7,6 @@ v = Version()
v.incrementPatchNumber()
v.updateVersionFile()
v.updateReadmeFile()
v.updateConanFile()
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )

View File

@ -11,6 +11,7 @@ versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.
rootPath = os.path.join( catchPath, 'include/' )
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
readmePath = os.path.join( catchPath, "README.md" )
conanPath = os.path.join(catchPath, 'conanfile.py')
class Version:
def __init__(self):
@ -86,3 +87,17 @@ class Version:
line = downloadParser.sub( r'<a href="https://github.com/philsquared/Catch/releases/download/v{0}/catch.hpp">'.format(self.getVersionString()) , line)
f.write( line + "\n" )
def updateConanFile(self):
conanParser = re.compile( r' version = "\d+\.\d+\.\d+.*"')
f = open( conanPath, 'r' )
lines = []
for line in f:
m = conanParser.match( line )
if m:
lines.append( ' version = "{0}"'.format(format(self.getVersionString())) )
else:
lines.append( line.rstrip() )
f.close()
f = open( conanPath, 'w' )
for line in lines:
f.write( line + "\n" )

View File

@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.0)
project(CatchTest CXX)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(${CMAKE_PROJECT_NAME} MainTest.cpp)

21
test_package/MainTest.cpp Normal file
View File

@ -0,0 +1,21 @@
/*
* Created by Phil on 22/10/2010.
* Copyright 2010 Two Blue Cubes Ltd
*
* 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)
*/
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
unsigned int Factorial( unsigned int number ) {
return number > 1 ? Factorial(number-1)*number : 1;
}
TEST_CASE( "Factorials are computed", "[factorial]" ) {
REQUIRE( Factorial(0) == 1 );
REQUIRE( Factorial(1) == 1 );
REQUIRE( Factorial(2) == 2 );
REQUIRE( Factorial(3) == 6 );
REQUIRE( Factorial(10) == 3628800 );
}

21
test_package/conanfile.py Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
from os import getenv
from os import path
from conans import ConanFile
from conans import CMake
class CatchConanTest(ConanFile):
generators = "cmake"
settings = "os", "compiler", "arch", "build_type"
username = getenv("CONAN_USERNAME", "philsquared")
channel = getenv("CONAN_CHANNEL", "testing")
requires = "Catch/1.9.5@%s/%s" % (username, channel)
def build(self):
cmake = CMake(self)
cmake.configure(build_dir="./")
cmake.build()
def test(self):
self.run(path.join("bin", "CatchTest"))