mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-15 14:48:00 +00:00
Compare commits
8 Commits
c770a9c8b5
...
49e000b505
Author | SHA1 | Date | |
---|---|---|---|
|
49e000b505 | ||
|
2e1ce37faa | ||
|
d0257fc1ff | ||
|
df2379218b | ||
|
7134ad9913 | ||
|
827733fe81 | ||
|
2f4a7dda68 | ||
|
6c3a5ef625 |
@ -49,7 +49,7 @@ class BuilderSettings(object):
|
||||
def reference(self):
|
||||
""" Read project version from branch create Conan reference
|
||||
"""
|
||||
return os.getenv("CONAN_REFERENCE", "Catch2/{}".format(self._version))
|
||||
return os.getenv("CONAN_REFERENCE", "catch2/{}".format(self._version))
|
||||
|
||||
@property
|
||||
def channel(self):
|
||||
@ -85,7 +85,7 @@ if __name__ == "__main__":
|
||||
reference=settings.reference,
|
||||
channel=settings.channel,
|
||||
upload=settings.upload,
|
||||
upload_only_when_stable=settings.upload_only_when_stable,
|
||||
upload_only_when_stable=False,
|
||||
stable_branch_pattern=settings.stable_branch_pattern,
|
||||
login_username=settings.login_username,
|
||||
username=settings.username,
|
||||
|
@ -1,11 +1,19 @@
|
||||
cmake_minimum_required(VERSION 3.2.0)
|
||||
project(test_package CXX)
|
||||
|
||||
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
conan_basic_setup(TARGETS)
|
||||
# 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})
|
||||
|
||||
find_package(Catch2 REQUIRED CONFIG)
|
||||
|
||||
add_executable(${PROJECT_NAME} test_package.cpp)
|
||||
target_link_libraries(${PROJECT_NAME} CONAN_PKG::Catch2)
|
||||
# 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)
|
||||
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"
|
||||
generators = "cmake_find_package_multi"
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
@ -14,6 +14,6 @@ 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)
|
||||
|
@ -1,6 +1,4 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
int Factorial( int number ) {
|
||||
return number <= 1 ? 1 : Factorial( number - 1 ) * number;
|
||||
|
24
.travis.yml
24
.travis.yml
@ -158,18 +158,18 @@ matrix:
|
||||
|
||||
|
||||
|
||||
# # Special builds, e.g. conan
|
||||
# - language: python
|
||||
# python:
|
||||
# - "3.7"
|
||||
# install:
|
||||
# - pip install conan-package-tools
|
||||
# env:
|
||||
# - CONAN_GCC_VERSIONS=8
|
||||
# - CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
# - CPP14=1
|
||||
# script:
|
||||
# - python .conan/build.py
|
||||
# Special builds, e.g. conan
|
||||
- language: python
|
||||
python:
|
||||
- "3.7"
|
||||
install:
|
||||
- pip install conan-package-tools
|
||||
env:
|
||||
- CONAN_GCC_VERSIONS=8
|
||||
- CONAN_DOCKER_IMAGE=conanio/gcc8
|
||||
- CPP14=1
|
||||
script:
|
||||
- python .conan/build.py
|
||||
|
||||
before_script:
|
||||
- export CXX=${COMPILER}
|
||||
|
@ -25,7 +25,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
endif()
|
||||
|
||||
|
||||
project(Catch2 LANGUAGES CXX VERSION 2.10.2)
|
||||
project(Catch2 LANGUAGES CXX VERSION 3.0.0)
|
||||
|
||||
# Provide path for scripts
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
|
||||
|
16
conanfile.py
16
conanfile.py
@ -3,16 +3,20 @@ from conans import ConanFile, CMake
|
||||
|
||||
|
||||
class CatchConan(ConanFile):
|
||||
name = "Catch2"
|
||||
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD"
|
||||
name = "catch2"
|
||||
description = "A modern, C++-native, framework for unit-tests, TDD and BDD"
|
||||
topics = ("conan", "catch2", "unit-test", "tdd", "bdd")
|
||||
url = "https://github.com/catchorg/Catch2"
|
||||
homepage = url
|
||||
license = "BSL-1.0"
|
||||
|
||||
exports = "LICENSE.txt"
|
||||
exports_sources = ("src/*", "CMakeLists.txt", "CMake/*", "extras/*")
|
||||
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
generators = "cmake"
|
||||
|
||||
options = {"with_main": [True, False]}
|
||||
default_options = {"with_main": True}
|
||||
|
||||
def _configure_cmake(self):
|
||||
cmake = CMake(self)
|
||||
@ -31,7 +35,11 @@ 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']
|
||||
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"
|
||||
|
@ -146,7 +146,6 @@ by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`.
|
||||
CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases
|
||||
CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows
|
||||
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed
|
||||
CATCH_CONFIG_DISABLE_MATCHERS // Do not compile Matchers in this compilation unit
|
||||
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
|
||||
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
|
||||
CATCH_CONFIG_DISABLE_STRINGIFICATION // Disable stringifying the original expression
|
||||
@ -183,11 +182,6 @@ should not lead to false negatives.
|
||||
`CATCH_CONFIG_FAST_COMPILE` has to be either defined, or not defined,
|
||||
in all translation units that are linked into single test binary.
|
||||
|
||||
### `CATCH_CONFIG_DISABLE_MATCHERS`
|
||||
When `CATCH_CONFIG_DISABLE_MATCHERS` is defined, all mentions of Catch's Matchers are ifdef-ed away from the translation unit. Doing so will speed up compilation of that TU.
|
||||
|
||||
_Note: If you define `CATCH_CONFIG_DISABLE_MATCHERS` in the same file as Catch's main is implemented, your test executable will fail to link if you use Matchers anywhere._
|
||||
|
||||
### `CATCH_CONFIG_DISABLE_STRINGIFICATION`
|
||||
This toggle enables a workaround for VS 2017 bug. For details see [known limitations](limitations.md#visual-studio-2017----raw-string-literal-in-assert-fails-to-compile).
|
||||
|
||||
|
@ -50,11 +50,14 @@
|
||||
* You can still write `SECTION("ShortName", "Long and wordy description")`, but the description is thrown away
|
||||
* The description type now must be a `const char*` or implicitly convertible to it
|
||||
|
||||
|
||||
### Fixes
|
||||
* The `INFO` macro no longer contains superfluous semicolon (#1456)
|
||||
* The `--list*` family of command line flags now return 0 on success (#1410, #1146)
|
||||
|
||||
### Other changes
|
||||
* `CATCH_CONFIG_DISABLE_MATCHERS` no longer exists.
|
||||
* If you do not want to use Matchers in a TU, do not include their header.
|
||||
|
||||
|
||||
## 2.10.2
|
||||
|
||||
|
@ -26,9 +26,7 @@
|
||||
#include <catch2/catch_compiler_capabilities.h>
|
||||
#include <catch2/catch_string_manip.h>
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#include <catch2/catch_capture_matchers.h>
|
||||
#endif
|
||||
#include <catch2/catch_generators.hpp>
|
||||
#include <catch2/catch_generators_generic.hpp>
|
||||
#include <catch2/catch_generators_specific.hpp>
|
||||
|
@ -51,7 +51,7 @@ namespace Catch {
|
||||
BeforeExit = 2,
|
||||
BeforeStartAndExit = BeforeStart | BeforeExit
|
||||
}; };
|
||||
|
||||
|
||||
class TestSpec;
|
||||
|
||||
struct IConfig : NonCopyable {
|
||||
|
@ -28,7 +28,7 @@ namespace Catch {
|
||||
|
||||
class StartupExceptionRegistry;
|
||||
|
||||
using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>;
|
||||
using IReporterFactoryPtr = std::unique_ptr<IReporterFactory>;
|
||||
|
||||
struct IRegistryHub {
|
||||
virtual ~IRegistryHub();
|
||||
@ -44,8 +44,8 @@ namespace Catch {
|
||||
|
||||
struct IMutableRegistryHub {
|
||||
virtual ~IMutableRegistryHub();
|
||||
virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0;
|
||||
virtual void registerListener( IReporterFactoryPtr const& factory ) = 0;
|
||||
virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0;
|
||||
virtual void registerListener( IReporterFactoryPtr factory ) = 0;
|
||||
virtual void registerTest(std::unique_ptr<TestCaseInfo>&& testInfo, std::unique_ptr<ITestInvoker>&& invoker) = 0;
|
||||
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
||||
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig )
|
||||
ReporterConfig::ReporterConfig( IConfig const* _fullConfig )
|
||||
: m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
|
||||
|
||||
ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream )
|
||||
ReporterConfig::ReporterConfig( IConfig const* _fullConfig, std::ostream& _stream )
|
||||
: m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
|
||||
|
||||
std::ostream& ReporterConfig::stream() const { return *m_stream; }
|
||||
IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; }
|
||||
IConfig const * ReporterConfig::fullConfig() const { return m_fullConfig; }
|
||||
|
||||
|
||||
TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {}
|
||||
|
@ -37,16 +37,16 @@ namespace Catch {
|
||||
struct TagInfo;
|
||||
|
||||
struct ReporterConfig {
|
||||
explicit ReporterConfig( IConfigPtr const& _fullConfig );
|
||||
explicit ReporterConfig( IConfig const* _fullConfig );
|
||||
|
||||
ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream );
|
||||
ReporterConfig( IConfig const* _fullConfig, std::ostream& _stream );
|
||||
|
||||
std::ostream& stream() const;
|
||||
IConfigPtr fullConfig() const;
|
||||
IConfig const* fullConfig() const;
|
||||
|
||||
private:
|
||||
std::ostream* m_stream;
|
||||
IConfigPtr m_fullConfig;
|
||||
IConfig const* m_fullConfig;
|
||||
};
|
||||
|
||||
struct ReporterPreferences {
|
||||
@ -261,14 +261,14 @@ namespace Catch {
|
||||
virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0;
|
||||
virtual std::string getDescription() const = 0;
|
||||
};
|
||||
using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>;
|
||||
using IReporterFactoryPtr = std::unique_ptr<IReporterFactory>;
|
||||
|
||||
struct IReporterRegistry {
|
||||
using FactoryMap = std::map<std::string, IReporterFactoryPtr>;
|
||||
using Listeners = std::vector<IReporterFactoryPtr>;
|
||||
|
||||
virtual ~IReporterRegistry();
|
||||
virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0;
|
||||
virtual IStreamingReporterPtr create( std::string const& name, IConfig const* config ) const = 0;
|
||||
virtual FactoryMap const& getFactories() const = 0;
|
||||
virtual Listeners const& getListeners() const = 0;
|
||||
};
|
||||
|
@ -29,13 +29,13 @@ namespace Catch {
|
||||
namespace {
|
||||
|
||||
void listTests(IStreamingReporter& reporter, Config const& config) {
|
||||
TestSpec testSpec = config.testSpec();
|
||||
auto const& testSpec = config.testSpec();
|
||||
auto matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
|
||||
reporter.listTests(matchedTestCases, config);
|
||||
}
|
||||
|
||||
void listTags(IStreamingReporter& reporter, Config const& config) {
|
||||
TestSpec testSpec = config.testSpec();
|
||||
auto const& testSpec = config.testSpec();
|
||||
std::vector<TestCaseHandle> matchedTestCases = filterTests(getAllTestCasesSorted(config), testSpec, config);
|
||||
|
||||
std::map<StringRef, TagInfo> tagCounts;
|
||||
|
@ -103,7 +103,6 @@ namespace Catch {
|
||||
return noTestMethods;
|
||||
}
|
||||
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
|
||||
namespace Matchers {
|
||||
namespace Impl {
|
||||
@ -193,8 +192,6 @@ namespace Catch {
|
||||
|
||||
using namespace Matchers;
|
||||
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -43,11 +43,11 @@ namespace Catch {
|
||||
}
|
||||
|
||||
public: // IMutableRegistryHub
|
||||
void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override {
|
||||
m_reporterRegistry.registerReporter( name, factory );
|
||||
void registerReporter( std::string const& name, IReporterFactoryPtr factory ) override {
|
||||
m_reporterRegistry.registerReporter( name, std::move(factory) );
|
||||
}
|
||||
void registerListener( IReporterFactoryPtr const& factory ) override {
|
||||
m_reporterRegistry.registerListener( factory );
|
||||
void registerListener( IReporterFactoryPtr factory ) override {
|
||||
m_reporterRegistry.registerListener( std::move(factory) );
|
||||
}
|
||||
void registerTest( std::unique_ptr<TestCaseInfo>&& testInfo, std::unique_ptr<ITestInvoker>&& invoker ) override {
|
||||
m_testCaseRegistry.registerTest( std::move(testInfo), std::move(invoker) );
|
||||
|
@ -17,7 +17,7 @@ namespace Catch {
|
||||
class ReporterFactory : public IReporterFactory {
|
||||
|
||||
IStreamingReporterPtr create( ReporterConfig const& config ) const override {
|
||||
return std::unique_ptr<T>( new T( config ) );
|
||||
return std::make_unique<T>( config );
|
||||
}
|
||||
|
||||
std::string getDescription() const override {
|
||||
@ -50,7 +50,7 @@ namespace Catch {
|
||||
public:
|
||||
|
||||
ListenerRegistrar() {
|
||||
getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() );
|
||||
getMutableRegistryHub().registerListener( std::make_unique<ListenerFactory>() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -18,30 +18,34 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
ReporterRegistry::ReporterRegistry():
|
||||
m_factories({
|
||||
{"automake", std::make_shared<ReporterFactory<AutomakeReporter>>() },
|
||||
{"compact", std::make_shared<ReporterFactory<CompactReporter>>() },
|
||||
{"console", std::make_shared<ReporterFactory<ConsoleReporter>>() },
|
||||
{"junit", std::make_shared<ReporterFactory<JunitReporter>>() },
|
||||
{"sonarqube", std::make_shared<ReporterFactory<SonarQubeReporter>>() },
|
||||
{"tap", std::make_shared<ReporterFactory<TAPReporter>>() },
|
||||
{"teamcity", std::make_shared<ReporterFactory<TeamCityReporter>>() },
|
||||
{"xml", std::make_shared<ReporterFactory<XmlReporter>>() },
|
||||
}) {}
|
||||
ReporterRegistry::ReporterRegistry() {
|
||||
// Because it is impossible to move out of initializer list,
|
||||
// we have to add the elements manually
|
||||
m_factories["automake"] = std::make_unique<ReporterFactory<AutomakeReporter>>();
|
||||
m_factories["compact"] = std::make_unique<ReporterFactory<CompactReporter>>();
|
||||
m_factories["console"] = std::make_unique<ReporterFactory<ConsoleReporter>>();
|
||||
m_factories["junit"] = std::make_unique<ReporterFactory<JunitReporter>>();
|
||||
m_factories["sonarqube"] = std::make_unique<ReporterFactory<SonarQubeReporter>>();
|
||||
m_factories["tap"] = std::make_unique<ReporterFactory<TAPReporter>>();
|
||||
m_factories["teamcity"] = std::make_unique<ReporterFactory<TeamCityReporter>>();
|
||||
m_factories["xml"] = std::make_unique<ReporterFactory<XmlReporter>>();
|
||||
}
|
||||
|
||||
IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const {
|
||||
ReporterRegistry::~ReporterRegistry() = default;
|
||||
|
||||
|
||||
IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfig const* config ) const {
|
||||
auto it = m_factories.find( name );
|
||||
if( it == m_factories.end() )
|
||||
return nullptr;
|
||||
return it->second->create( ReporterConfig( config ) );
|
||||
}
|
||||
|
||||
void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) {
|
||||
m_factories.emplace(name, factory);
|
||||
void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) {
|
||||
m_factories.emplace(name, std::move(factory));
|
||||
}
|
||||
void ReporterRegistry::registerListener( IReporterFactoryPtr const& factory ) {
|
||||
m_listeners.push_back( factory );
|
||||
void ReporterRegistry::registerListener( IReporterFactoryPtr factory ) {
|
||||
m_listeners.push_back( std::move(factory) );
|
||||
}
|
||||
|
||||
IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const {
|
||||
|
@ -18,12 +18,12 @@ namespace Catch {
|
||||
public:
|
||||
|
||||
ReporterRegistry();
|
||||
~ReporterRegistry() override = default;
|
||||
~ReporterRegistry() override; // = default, out of line to allow fwd decl
|
||||
|
||||
IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override;
|
||||
IStreamingReporterPtr create( std::string const& name, IConfig const* config ) const override;
|
||||
|
||||
void registerReporter( std::string const& name, IReporterFactoryPtr const& factory );
|
||||
void registerListener( IReporterFactoryPtr const& factory );
|
||||
void registerReporter( std::string const& name, IReporterFactoryPtr factory );
|
||||
void registerListener( IReporterFactoryPtr factory );
|
||||
|
||||
FactoryMap const& getFactories() const override;
|
||||
Listeners const& getListeners() const override;
|
||||
|
@ -33,14 +33,14 @@ namespace Catch {
|
||||
namespace {
|
||||
const int MaxExitCode = 255;
|
||||
|
||||
IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) {
|
||||
IStreamingReporterPtr createReporter(std::string const& reporterName, IConfig const* config) {
|
||||
auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config);
|
||||
CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << "'");
|
||||
|
||||
return reporter;
|
||||
}
|
||||
|
||||
IStreamingReporterPtr makeReporter(std::shared_ptr<Config> const& config) {
|
||||
IStreamingReporterPtr makeReporter(Config const* config) {
|
||||
if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()) {
|
||||
return createReporter(config->getReporterName(), config);
|
||||
}
|
||||
@ -273,7 +273,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
// Create reporter(s) so we can route listings through them
|
||||
auto reporter = makeReporter(m_config);
|
||||
auto reporter = makeReporter(m_config.get());
|
||||
|
||||
// Handle list request
|
||||
if (list(*reporter, m_config)) {
|
||||
|
@ -24,9 +24,7 @@
|
||||
#define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
|
||||
#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )
|
||||
#endif// CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||
|
||||
#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
@ -38,16 +36,12 @@
|
||||
#define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
|
||||
|
||||
#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg )
|
||||
#define CATCH_UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "CATCH_UNSCOPED_INFO", msg )
|
||||
@ -120,9 +114,7 @@
|
||||
#define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||
#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr )
|
||||
#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr )
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ )
|
||||
|
||||
#define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
@ -134,17 +126,13 @@
|
||||
#define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )
|
||||
#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )
|
||||
|
||||
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )
|
||||
|
||||
#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg )
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg )
|
||||
#define UNSCOPED_INFO( msg ) INTERNAL_CATCH_UNSCOPED_INFO( "UNSCOPED_INFO", msg )
|
||||
@ -228,9 +216,7 @@
|
||||
#define CATCH_REQUIRE_THROWS( ... ) (void)(0)
|
||||
#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)
|
||||
#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0)
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
|
||||
#endif// CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define CATCH_REQUIRE_NOTHROW( ... ) (void)(0)
|
||||
|
||||
#define CATCH_CHECK( ... ) (void)(0)
|
||||
@ -242,16 +228,12 @@
|
||||
#define CATCH_CHECK_THROWS( ... ) (void)(0)
|
||||
#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0)
|
||||
#define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0)
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define CATCH_CHECK_NOTHROW( ... ) (void)(0)
|
||||
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CATCH_CHECK_THAT( arg, matcher ) (void)(0)
|
||||
|
||||
#define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0)
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
#define CATCH_INFO( msg ) (void)(0)
|
||||
#define CATCH_UNSCOPED_INFO( msg ) (void)(0)
|
||||
@ -310,9 +292,7 @@
|
||||
#define REQUIRE_THROWS( ... ) (void)(0)
|
||||
#define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)
|
||||
#define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0)
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define REQUIRE_NOTHROW( ... ) (void)(0)
|
||||
|
||||
#define CHECK( ... ) (void)(0)
|
||||
@ -324,17 +304,12 @@
|
||||
#define CHECK_THROWS( ... ) (void)(0)
|
||||
#define CHECK_THROWS_AS( expr, exceptionType ) (void)(0)
|
||||
#define CHECK_THROWS_WITH( expr, matcher ) (void)(0)
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
#define CHECK_NOTHROW( ... ) (void)(0)
|
||||
|
||||
|
||||
#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)
|
||||
#define CHECK_THAT( arg, matcher ) (void)(0)
|
||||
|
||||
#define REQUIRE_THAT( arg, matcher ) (void)(0)
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
#define INFO( msg ) (void)(0)
|
||||
#define UNSCOPED_INFO( msg ) (void)(0)
|
||||
|
@ -25,6 +25,7 @@ namespace Catch {
|
||||
struct IConfig;
|
||||
|
||||
class TestSpec {
|
||||
|
||||
class Pattern {
|
||||
public:
|
||||
explicit Pattern( std::string const& name );
|
||||
@ -34,7 +35,6 @@ namespace Catch {
|
||||
private:
|
||||
std::string const m_name;
|
||||
};
|
||||
using PatternPtr = std::shared_ptr<Pattern>;
|
||||
|
||||
class NamePattern : public Pattern {
|
||||
public:
|
||||
@ -53,8 +53,8 @@ namespace Catch {
|
||||
};
|
||||
|
||||
struct Filter {
|
||||
std::vector<PatternPtr> m_required;
|
||||
std::vector<PatternPtr> m_forbidden;
|
||||
std::vector<std::unique_ptr<Pattern>> m_required;
|
||||
std::vector<std::unique_ptr<Pattern>> m_forbidden;
|
||||
|
||||
bool matches( TestCaseInfo const& testCase ) const;
|
||||
std::string name() const;
|
||||
|
@ -20,10 +20,10 @@ namespace Catch {
|
||||
m_substring.reserve(m_arg.size());
|
||||
m_patternName.reserve(m_arg.size());
|
||||
m_realPatternPos = 0;
|
||||
|
||||
|
||||
for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )
|
||||
//if visitChar fails
|
||||
if( !visitChar( m_arg[m_pos] ) ){
|
||||
if( !visitChar( m_arg[m_pos] ) ){
|
||||
m_testSpec.m_invalidArgs.push_back(arg);
|
||||
break;
|
||||
}
|
||||
@ -32,7 +32,7 @@ namespace Catch {
|
||||
}
|
||||
TestSpec TestSpecParser::testSpec() {
|
||||
addFilter();
|
||||
return m_testSpec;
|
||||
return std::move(m_testSpec);
|
||||
}
|
||||
bool TestSpecParser::visitChar( char c ) {
|
||||
if( (m_mode != EscapedName) && (c == '\\') ) {
|
||||
@ -148,7 +148,7 @@ namespace Catch {
|
||||
|
||||
void TestSpecParser::addFilter() {
|
||||
if( !m_currentFilter.m_required.empty() || !m_currentFilter.m_forbidden.empty() ) {
|
||||
m_testSpec.m_filters.push_back( m_currentFilter );
|
||||
m_testSpec.m_filters.push_back( std::move(m_currentFilter) );
|
||||
m_currentFilter = TestSpec::Filter();
|
||||
}
|
||||
}
|
||||
@ -156,12 +156,12 @@ namespace Catch {
|
||||
void TestSpecParser::saveLastMode() {
|
||||
lastMode = m_mode;
|
||||
}
|
||||
|
||||
|
||||
void TestSpecParser::revertBackToLastMode() {
|
||||
m_mode = lastMode;
|
||||
}
|
||||
|
||||
bool TestSpecParser::separate() {
|
||||
|
||||
bool TestSpecParser::separate() {
|
||||
if( (m_mode==QuotedName) || (m_mode==Tag) ){
|
||||
//invalid argument, signal failure to previous scope.
|
||||
m_mode = None;
|
||||
@ -174,7 +174,7 @@ namespace Catch {
|
||||
addFilter();
|
||||
return true; //success
|
||||
}
|
||||
|
||||
|
||||
TestSpec parseTestSpec( std::string const& arg ) {
|
||||
return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();
|
||||
}
|
||||
|
@ -65,11 +65,10 @@ namespace Catch {
|
||||
token = token.substr( 8 );
|
||||
}
|
||||
if( !token.empty() ) {
|
||||
TestSpec::PatternPtr pattern = std::make_shared<T>( token, m_substring );
|
||||
if (m_exclusion) {
|
||||
m_currentFilter.m_forbidden.push_back(pattern);
|
||||
m_currentFilter.m_forbidden.emplace_back(std::make_unique<T>(token, m_substring));
|
||||
} else {
|
||||
m_currentFilter.m_required.push_back(pattern);
|
||||
m_currentFilter.m_required.emplace_back(std::make_unique<T>(token, m_substring));
|
||||
}
|
||||
}
|
||||
m_substring.clear();
|
||||
|
@ -37,7 +37,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 2, 10, 2, "", 0 );
|
||||
static Version version( 3, 0, 0, "preview", 2 );
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_VERSION_MACROS_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_VERSION_MACROS_HPP_INCLUDED
|
||||
|
||||
#define CATCH_VERSION_MAJOR 2
|
||||
#define CATCH_VERSION_MINOR 10
|
||||
#define CATCH_VERSION_PATCH 2
|
||||
#define CATCH_VERSION_MAJOR 3
|
||||
#define CATCH_VERSION_MINOR 0
|
||||
#define CATCH_VERSION_PATCH 0
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_VERSION_MACROS_HPP_INCLUDED
|
||||
|
@ -81,7 +81,7 @@ namespace Catch {
|
||||
// It can optionally be overridden in the derived class.
|
||||
}
|
||||
|
||||
IConfigPtr m_config;
|
||||
IConfig const* m_config;
|
||||
std::ostream& stream;
|
||||
|
||||
LazyStat<TestRunInfo> currentTestRunInfo;
|
||||
@ -227,7 +227,7 @@ namespace Catch {
|
||||
|
||||
void skipTest(TestCaseInfo const&) override {}
|
||||
|
||||
IConfigPtr m_config;
|
||||
IConfig const* m_config;
|
||||
std::ostream& stream;
|
||||
std::vector<AssertionStats> m_assertions;
|
||||
std::vector<std::vector<std::shared_ptr<SectionNode>>> m_sections;
|
||||
|
@ -4,7 +4,6 @@ yet:
|
||||
CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases
|
||||
CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows
|
||||
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed
|
||||
CATCH_CONFIG_DISABLE_MATCHERS // Do not compile Matchers in this compilation unit
|
||||
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
|
||||
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
|
||||
CATCH_CONFIG_DEFAULT_REPORTER
|
||||
|
@ -286,9 +286,7 @@ TEST_CASE( "Parse test names and tags" ) {
|
||||
|
||||
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
using namespace Catch::Matchers;
|
||||
#endif
|
||||
|
||||
Catch::ConfigData config;
|
||||
auto cli = Catch::makeCommandLineParser(config);
|
||||
@ -367,9 +365,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
auto result = cli.parse({"test", "--reporter", "unsupported"});
|
||||
CHECK(!result);
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
REQUIRE_THAT(result.errorMessage(), Contains("Unrecognized reporter"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -401,10 +397,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
SECTION("-x must be numeric") {
|
||||
auto result = cli.parse({"test", "-x", "oops"});
|
||||
CHECK(!result);
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
REQUIRE_THAT(result.errorMessage(), Contains("convert") && Contains("oops"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -476,9 +469,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
||||
SECTION( "error" ) {
|
||||
auto result = cli.parse({"test", "--use-colour", "wrong"});
|
||||
CHECK( !result );
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
CHECK_THAT( result.errorMessage(), Contains( "colour mode must be one of" ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,14 +22,12 @@ TEST_CASE( "Tag alias can be registered against tag patterns" ) {
|
||||
FAIL( "expected exception" );
|
||||
}
|
||||
catch( std::exception& ex ) {
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
std::string what = ex.what();
|
||||
using namespace Catch::Matchers;
|
||||
CHECK_THAT( what, Contains( "[@zzz]" ) );
|
||||
CHECK_THAT( what, Contains( "file" ) );
|
||||
CHECK_THAT( what, Contains( "2" ) );
|
||||
CHECK_THAT( what, Contains( "10" ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,9 +79,7 @@ namespace { namespace CompilationTests {
|
||||
REQUIRE_THROWS(throws_int(true));
|
||||
CHECK_THROWS_AS(throws_int(true), int);
|
||||
REQUIRE_NOTHROW(throws_int(false));
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
REQUIRE_THAT("aaa", Catch::EndsWith("aaa"));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -162,8 +162,6 @@ TEST_CASE("thrown std::strings are translated", "[.][failing][!throws]") {
|
||||
}
|
||||
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
TEST_CASE( "Exception messages can be tested for", "[!throws]" ) {
|
||||
using namespace Catch::Matchers;
|
||||
SECTION( "exact match" )
|
||||
@ -178,8 +176,6 @@ TEST_CASE( "Exception messages can be tested for", "[!throws]" ) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST_CASE( "Mismatching exception messages failing the test", "[.][failing][!throws]" ) {
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "expected exception" );
|
||||
REQUIRE_THROWS_WITH( thisThrows(), "should fail" );
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
namespace { namespace MatchersTests {
|
||||
|
||||
#ifndef CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
#ifndef MATCHERS_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU
|
||||
#define MATCHERS_TEST_HELPERS_INCLUDED
|
||||
|
||||
@ -558,8 +556,6 @@ namespace { namespace MatchersTests {
|
||||
|
||||
} } // namespace MatchersTests
|
||||
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
@ -31,7 +31,7 @@ hexParser = re.compile(r'\b(0[xX][0-9a-fA-F]+)\b')
|
||||
durationsParser = re.compile(r' time="[0-9]*\.[0-9]*"')
|
||||
sonarqubeDurationParser = re.compile(r' duration="[0-9]+"')
|
||||
timestampsParser = re.compile(r'\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z')
|
||||
versionParser = re.compile(r'Catch v[0-9]+\.[0-9]+\.[0-9]+(-develop\.[0-9]+)?')
|
||||
versionParser = re.compile(r'Catch v[0-9]+\.[0-9]+\.[0-9]+(-\w*\.[0-9]+)?')
|
||||
nullParser = re.compile(r'\b(__null|nullptr)\b')
|
||||
exeNameParser = re.compile(r'''
|
||||
\b
|
||||
|
Loading…
Reference in New Issue
Block a user