diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000..564b6514 --- /dev/null +++ b/conanfile.py @@ -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") diff --git a/scripts/developBuild.py b/scripts/developBuild.py index c16c8a6d..3d3f6f0a 100755 --- a/scripts/developBuild.py +++ b/scripts/developBuild.py @@ -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() ) ) \ No newline at end of file +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/scripts/majorRelease.py b/scripts/majorRelease.py index f367506a..2341ecb5 100755 --- a/scripts/majorRelease.py +++ b/scripts/majorRelease.py @@ -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() ) ) \ No newline at end of file +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/scripts/minorRelease.py b/scripts/minorRelease.py index ac36df96..585b7019 100755 --- a/scripts/minorRelease.py +++ b/scripts/minorRelease.py @@ -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() ) ) \ No newline at end of file +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/scripts/patchRelease.py b/scripts/patchRelease.py index 878662f8..312b4d5a 100755 --- a/scripts/patchRelease.py +++ b/scripts/patchRelease.py @@ -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() ) ) \ No newline at end of file +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/scripts/releaseCommon.py b/scripts/releaseCommon.py index c49f7461..16b5f199 100644 --- a/scripts/releaseCommon.py +++ b/scripts/releaseCommon.py @@ -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''.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" ) diff --git a/test_package/CMakeLists.txt b/test_package/CMakeLists.txt new file mode 100644 index 00000000..339facbf --- /dev/null +++ b/test_package/CMakeLists.txt @@ -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) diff --git a/test_package/MainTest.cpp b/test_package/MainTest.cpp new file mode 100644 index 00000000..b8ed744e --- /dev/null +++ b/test_package/MainTest.cpp @@ -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 ); +} diff --git a/test_package/conanfile.py b/test_package/conanfile.py new file mode 100644 index 00000000..9444b737 --- /dev/null +++ b/test_package/conanfile.py @@ -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"))