mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-16 07:08:01 +00:00
Compare commits
9 Commits
e4474021ff
...
dd5652933a
Author | SHA1 | Date | |
---|---|---|---|
|
dd5652933a | ||
|
3a15433d52 | ||
|
67a9561fb5 | ||
|
2f31f9037d | ||
|
33bcdc6bf5 | ||
|
74b397e6b8 | ||
|
730ec39a74 | ||
|
71328bae90 | ||
|
ed9ef85a34 |
@ -1,19 +1,12 @@
|
||||
cmake_minimum_required(VERSION 3.2.0)
|
||||
project(test_package CXX)
|
||||
|
||||
# We set it only for the convenience of calling the executable
|
||||
# in the package test function
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
|
||||
conan_basic_setup()
|
||||
|
||||
find_package(Catch2 REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
||||
# Note: Conan 1.21 doesn't support granular target generation yet.
|
||||
# The Main library would be included into the unified target.
|
||||
# It's controlled by the `with_main` option in the recipe.
|
||||
target_link_libraries(${PROJECT_NAME} Catch2::Catch2)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} Catch2::Catch2WithMain)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)
|
||||
|
@ -6,7 +6,7 @@ import os
|
||||
|
||||
class TestPackageConan(ConanFile):
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake_find_package_multi"
|
||||
generators = "cmake_find_package_multi", "cmake"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
@ -14,6 +14,7 @@ class TestPackageConan(ConanFile):
|
||||
cmake.build()
|
||||
|
||||
def test(self):
|
||||
assert os.path.isfile(os.path.join(self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt"))
|
||||
assert os.path.isfile(os.path.join(
|
||||
self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt"))
|
||||
bin_path = os.path.join("bin", "test_package")
|
||||
self.run("%s -s" % bin_path, run_environment=True)
|
||||
|
30
conanfile.py
30
conanfile.py
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
from conans import ConanFile, CMake
|
||||
|
||||
from conans import ConanFile, CMake, tools
|
||||
|
||||
class CatchConan(ConanFile):
|
||||
name = "catch2"
|
||||
@ -15,8 +14,7 @@ class CatchConan(ConanFile):
|
||||
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
|
||||
options = {"with_main": [True, False]}
|
||||
default_options = {"with_main": True}
|
||||
generators = "cmake"
|
||||
|
||||
def _configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
@ -27,6 +25,14 @@ class CatchConan(ConanFile):
|
||||
return cmake
|
||||
|
||||
def build(self):
|
||||
# We need this workaround until the toolchains feature
|
||||
# to inject stuff like MD/MT
|
||||
line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")'
|
||||
tools.replace_in_file("CMakeLists.txt", line_to_replace,
|
||||
'''{}
|
||||
include("{}/conanbuildinfo.cmake")
|
||||
conan_basic_setup()'''.format(line_to_replace, self.install_folder.replace("\\", "/")))
|
||||
|
||||
cmake = self._configure_cmake()
|
||||
cmake.build()
|
||||
|
||||
@ -35,11 +41,17 @@ class CatchConan(ConanFile):
|
||||
cmake = self._configure_cmake()
|
||||
cmake.install()
|
||||
|
||||
def package_id(self):
|
||||
del self.info.options.with_main
|
||||
|
||||
def package_info(self):
|
||||
self.cpp_info.libs = [
|
||||
'Catch2Main', 'Catch2'] if self.options.with_main else ['Catch2']
|
||||
self.cpp_info.names["cmake_find_package"] = "Catch2"
|
||||
self.cpp_info.names["cmake_find_package_multi"] = "Catch2"
|
||||
# Catch2
|
||||
self.cpp_info.components["catch2base"].names["cmake_find_package"] = "Catch2"
|
||||
self.cpp_info.components["catch2base"].names["cmake_find_package_multi"] = "Catch2"
|
||||
self.cpp_info.components["catch2base"].names["pkg_config"] = "Catch2"
|
||||
self.cpp_info.components["catch2base"].libs = ["Catch2"]
|
||||
# Catch2WithMain
|
||||
self.cpp_info.components["catch2main"].names["cmake_find_package"] = "Catch2WithMain"
|
||||
self.cpp_info.components["catch2main"].names["cmake_find_package_multi"] = "Catch2WithMain"
|
||||
self.cpp_info.components["catch2main"].names["pkg_config"] = "Catch2WithMain"
|
||||
self.cpp_info.components["catch2main"].libs = ["Catch2Main"]
|
||||
self.cpp_info.components["catch2main"].requires = ["catch2base"]
|
||||
|
@ -94,6 +94,9 @@ A thread-safe header-only mocking framework for C++14.
|
||||
|
||||
## Applications & Tools
|
||||
|
||||
### [App Mesh](https://github.com/laoshanxi/app-mesh)
|
||||
A high available cloud native micro-service application management platform implemented by modern C++.
|
||||
|
||||
### [ArangoDB](https://github.com/arangodb/arangodb)
|
||||
ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values.
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
# Release notes
|
||||
**Contents**<br>
|
||||
[3.0.1](#301)<br>
|
||||
[2.13.3](#2133)<br>
|
||||
[2.13.2](#2132)<br>
|
||||
[2.13.1](#2131)<br>
|
||||
[2.13.0](#2130)<br>
|
||||
@ -154,6 +155,17 @@ new design.
|
||||
|
||||
|
||||
|
||||
## 2.13.3
|
||||
|
||||
### Fixes
|
||||
* Fixed possible infinite loop when combining generators with section filter (`-c` option) (#2025)
|
||||
|
||||
### Miscellaneous
|
||||
* Fixed `ParseAndAddCatchTests` not finding `TEST_CASE`s without tags (#2055, #2056)
|
||||
* `ParseAndAddCatchTests` supports `CMP0110` policy for changing behaviour of `add_test` (#2057)
|
||||
* This was the shortlived change in CMake 3.18.0 that temporarily broke `ParseAndAddCatchTests`
|
||||
|
||||
|
||||
## 2.13.2
|
||||
|
||||
### Improvements
|
||||
|
@ -108,7 +108,8 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
|
||||
ParseAndAddCatchTests_RemoveComments(Contents)
|
||||
|
||||
# Find definition of test names
|
||||
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([ \t\n]*\"[^\"]*\"[ \t\n]*,[ \t\n]*\"[^\"]*\"([^\(\)]+(\\([^\)]*\\))*)*\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
|
||||
# https://regex101.com/r/JygOND/1
|
||||
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEMPLATE_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([ \t\n]*\"[^\"]*\"[ \t\n]*(,[ \t\n]*\"[^\"]*\")?(,[ \t\n]*[^\,\)]*)*\\)[ \t\n]*\{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
|
||||
|
||||
if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests)
|
||||
ParseAndAddCatchTests_PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
|
||||
@ -119,6 +120,14 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
|
||||
)
|
||||
endif()
|
||||
|
||||
# check CMP0110 policy for new add_test() behavior
|
||||
if(POLICY CMP0110)
|
||||
cmake_policy(GET CMP0110 _cmp0110_value) # new add_test() behavior
|
||||
else()
|
||||
# just to be thorough explicitly set the variable
|
||||
set(_cmp0110_value)
|
||||
endif()
|
||||
|
||||
foreach(TestName ${Tests})
|
||||
# Strip newlines
|
||||
string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}")
|
||||
@ -193,14 +202,18 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget)
|
||||
|
||||
# Work around CMake 3.18.0 change in `add_test()`, before the escaped quotes were neccessary,
|
||||
# only with CMake 3.18.0 the escaped double quotes confuse the call. This change is reverted in 3.18.1
|
||||
if(NOT ${CMAKE_VERSION} VERSION_EQUAL "3.18")
|
||||
# And properly introduced in 3.19 with the CMP0110 policy
|
||||
if(_cmp0110_value STREQUAL "NEW" OR ${CMAKE_VERSION} VERSION_EQUAL "3.18")
|
||||
ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to NEW, no need for add_test(\"\") workaround")
|
||||
else()
|
||||
ParseAndAddCatchTests_PrintDebugMessage("CMP0110 set to OLD adding \"\" for add_test() workaround")
|
||||
set(CTestName "\"${CTestName}\"")
|
||||
endif()
|
||||
|
||||
# Handle template test cases
|
||||
if("${TestTypeAndFixture}" MATCHES ".*TEMPLATE_.*")
|
||||
set(Name "${Name} - *")
|
||||
endif()
|
||||
# Handle template test cases
|
||||
if("${TestTypeAndFixture}" MATCHES ".*TEMPLATE_.*")
|
||||
set(Name "${Name} - *")
|
||||
endif()
|
||||
|
||||
# Add the test and set its properties
|
||||
add_test(NAME "${CTestName}" COMMAND ${OptionalCatchTestLauncher} $<TARGET_FILE:${TestTarget}> ${Name} ${AdditionalCatchParameters})
|
||||
|
@ -56,7 +56,7 @@
|
||||
CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \
|
||||
} INTERNAL_CATCH_CATCH( catchAssertionHandler ) \
|
||||
INTERNAL_CATCH_REACT( catchAssertionHandler ) \
|
||||
} while( (void)0, (false) && static_cast<bool>( !!(__VA_ARGS__) ) )
|
||||
} while( (void)0, (false) && static_cast<const bool&>( !!(__VA_ARGS__) ) )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \
|
||||
|
Loading…
Reference in New Issue
Block a user