1
0
mirror of https://github.com/catchorg/Catch2.git synced 2025-01-16 07:08:01 +00:00

Compare commits

...

9 Commits

Author SHA1 Message Date
Morwenn
dd5652933a Silence -Wuseless-cast warning with GCC10
With GCC 10, the `static_cast<bool>` triggers the -Wuseless-cast warning. This commit changes the cast into `static_cast<const bool&>`: it achieves the same thing but doesn't trigger the warning thanks to the "gratuitous" type conversion to `const bool&`. As per references rules, `const bool&` should bind to anything, be it `const` or not, an rvalue or an lvalue, so I doubt that this change is breaking anything.
2020-11-02 16:01:17 +01:00
Alexandr Timofeev
3a15433d52 Add support for Components 2020-11-02 15:37:35 +01:00
Alexandr Timofeev
67a9561fb5 Fix slashes for Windows builds 2020-11-02 15:37:35 +01:00
Alexandr Timofeev
2f31f9037d Inject conan_basic_setup to properly set MD/MT flags 2020-11-02 15:37:35 +01:00
Martin Hořeňovský
33bcdc6bf5
Picked release notes for v2.13.3 2020-11-02 14:42:24 +01:00
Reinhold Gschweicher
74b397e6b8
Consider CMP0110 add_test() policy
CMake 3.19 introduces new add_test() behavior guarded with the policy
CMP0110.

See: https://cmake.org/cmake/help/latest/policy/CMP0110.html

Update the helper script ParseAndAddCatchTests to consider the policy and
handle the test case name accordingly.
2020-11-02 14:42:22 +01:00
Reinhold Gschweicher
730ec39a74
Fix indentation in ParseAndAddCatchTests
Consistently use 4 spaces instead of tabs
2020-11-02 14:42:19 +01:00
Reinhold Gschweicher
71328bae90
Fix CMake regex to add tests
Fix regex that requires two string arguments in the form of
TEST_CASE("a", "b") resulting in not finding TEST_CASE("a") entries.

See https://regex101.com/r/JygOND/1

Fixes: https://github.com/catchorg/Catch2/issues/2055
2020-11-02 14:42:17 +01:00
laoshanxi
ed9ef85a34
Add AppMesh to Open Source projects using Catch 2020-11-02 14:42:13 +01:00
7 changed files with 63 additions and 29 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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"]

View File

@ -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.

View File

@ -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

View File

@ -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})

View File

@ -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, ... ) \