mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Merge branch 'feature/conan' of https://github.com/uilianries/Catch
This commit is contained in:
commit
df7c5622b9
16
conanfile.py
Normal file
16
conanfile.py
Normal 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")
|
@ -7,5 +7,6 @@ v = Version()
|
|||||||
v.incrementBuildNumber()
|
v.incrementBuildNumber()
|
||||||
v.updateVersionFile()
|
v.updateVersionFile()
|
||||||
v.updateReadmeFile()
|
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() ) )
|
||||||
|
@ -7,5 +7,6 @@ v = Version()
|
|||||||
v.incrementMajorVersion()
|
v.incrementMajorVersion()
|
||||||
v.updateVersionFile()
|
v.updateVersionFile()
|
||||||
v.updateReadmeFile()
|
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() ) )
|
||||||
|
@ -7,5 +7,6 @@ v = Version()
|
|||||||
v.incrementMinorVersion()
|
v.incrementMinorVersion()
|
||||||
v.updateVersionFile()
|
v.updateVersionFile()
|
||||||
v.updateReadmeFile()
|
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() ) )
|
||||||
|
@ -7,5 +7,6 @@ v = Version()
|
|||||||
v.incrementPatchNumber()
|
v.incrementPatchNumber()
|
||||||
v.updateVersionFile()
|
v.updateVersionFile()
|
||||||
v.updateReadmeFile()
|
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() ) )
|
||||||
|
@ -11,6 +11,7 @@ versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.
|
|||||||
rootPath = os.path.join( catchPath, 'include/' )
|
rootPath = os.path.join( catchPath, 'include/' )
|
||||||
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
||||||
readmePath = os.path.join( catchPath, "README.md" )
|
readmePath = os.path.join( catchPath, "README.md" )
|
||||||
|
conanPath = os.path.join(catchPath, 'conanfile.py')
|
||||||
|
|
||||||
class Version:
|
class Version:
|
||||||
def __init__(self):
|
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)
|
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" )
|
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" )
|
||||||
|
7
test_package/CMakeLists.txt
Normal file
7
test_package/CMakeLists.txt
Normal 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
21
test_package/MainTest.cpp
Normal 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
21
test_package/conanfile.py
Normal 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"))
|
Loading…
Reference in New Issue
Block a user