mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-16 07:08:01 +00:00
Compare commits
4 Commits
7c97554565
...
517839fb3f
Author | SHA1 | Date | |
---|---|---|---|
|
517839fb3f | ||
|
b955355ec4 | ||
|
c5ec936a72 | ||
|
8d44c2450c |
@ -42,7 +42,6 @@ set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} )
|
||||
|
||||
foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} )
|
||||
add_executable( ${name}
|
||||
000-CatchMain.cpp
|
||||
${EXAMPLES_DIR}/${name}.cpp )
|
||||
endforeach()
|
||||
|
||||
@ -53,7 +52,7 @@ set(ALL_EXAMPLE_TARGETS
|
||||
)
|
||||
|
||||
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
||||
target_link_libraries( ${name} Catch2 )
|
||||
target_link_libraries( ${name} Catch2 Catch2Main )
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF)
|
||||
endforeach()
|
||||
|
@ -55,7 +55,7 @@ set(INTERNAL_HEADERS
|
||||
${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_errno_guard.hpp
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.hpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition.hpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.hpp
|
||||
${SOURCES_DIR}/generators/catch_generator_exception.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators.hpp
|
||||
${SOURCES_DIR}/generators/catch_generators_adapters.hpp
|
||||
@ -141,7 +141,7 @@ set(IMPL_SOURCES
|
||||
${SOURCES_DIR}/internal/catch_enum_values_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_errno_guard.cpp
|
||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.cpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition.cpp
|
||||
${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp
|
||||
${SOURCES_DIR}/generators/catch_generator_exception.cpp
|
||||
${SOURCES_DIR}/generators/catch_generators.cpp
|
||||
${SOURCES_DIR}/interfaces/catch_interfaces_capture.cpp
|
||||
@ -175,7 +175,6 @@ set(IMPL_SOURCES
|
||||
${SOURCES_DIR}/internal/catch_stream.cpp
|
||||
${SOURCES_DIR}/internal/catch_stringref.cpp
|
||||
${SOURCES_DIR}/internal/catch_string_manip.cpp
|
||||
${SOURCES_DIR}/catch_tag_alias.cpp
|
||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp
|
||||
${SOURCES_DIR}/internal/catch_tag_alias_registry.cpp
|
||||
${SOURCES_DIR}/catch_test_case_info.cpp
|
||||
|
@ -1,5 +0,0 @@
|
||||
#include <catch2/catch_tag_alias.hpp>
|
||||
|
||||
namespace Catch {
|
||||
TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {}
|
||||
}
|
@ -15,7 +15,10 @@
|
||||
namespace Catch {
|
||||
|
||||
struct TagAlias {
|
||||
TagAlias(std::string const& _tag, SourceLineInfo _lineInfo);
|
||||
TagAlias(std::string const& _tag, SourceLineInfo _lineInfo):
|
||||
tag(_tag),
|
||||
lineInfo(_lineInfo)
|
||||
{}
|
||||
|
||||
std::string tag;
|
||||
SourceLineInfo lineInfo;
|
||||
|
@ -9,8 +9,12 @@
|
||||
|
||||
namespace Catch {
|
||||
|
||||
//! Simple RAII class that stores the value of `errno`
|
||||
//! at construction and restores it at destruction.
|
||||
class ErrnoGuard {
|
||||
public:
|
||||
// Keep these outlined to avoid dragging in macros from <cerrno>
|
||||
|
||||
ErrnoGuard();
|
||||
~ErrnoGuard();
|
||||
private:
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <catch2/internal/catch_fatal_condition.hpp>
|
||||
#include <catch2/internal/catch_fatal_condition_handler.hpp>
|
||||
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||
@ -75,10 +75,6 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
FatalConditionHandler::~FatalConditionHandler() {
|
||||
reset();
|
||||
}
|
||||
|
||||
bool FatalConditionHandler::isSet = false;
|
||||
ULONG FatalConditionHandler::guaranteeSize = 0;
|
||||
PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr;
|
||||
@ -94,7 +90,7 @@ namespace Catch {
|
||||
int id;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
|
||||
// 32kb for the alternate stack seems to be sufficient. However, this value
|
||||
// is experimentally determined, so that's not guaranteed.
|
||||
static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
|
||||
@ -138,11 +134,6 @@ namespace Catch {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FatalConditionHandler::~FatalConditionHandler() {
|
||||
reset();
|
||||
}
|
||||
|
||||
void FatalConditionHandler::reset() {
|
||||
if( isSet ) {
|
||||
// Set signals back to previous values -- hopefully nobody overwrote them in the meantime
|
||||
@ -163,12 +154,6 @@ namespace Catch {
|
||||
|
||||
} // namespace Catch
|
||||
|
||||
#else
|
||||
|
||||
namespace Catch {
|
||||
void FatalConditionHandler::reset() {}
|
||||
}
|
||||
|
||||
#endif // signals/SEH handling
|
||||
|
||||
#if defined(__GNUC__)
|
@ -23,7 +23,7 @@ namespace Catch {
|
||||
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo);
|
||||
FatalConditionHandler();
|
||||
static void reset();
|
||||
~FatalConditionHandler();
|
||||
~FatalConditionHandler() { reset(); }
|
||||
|
||||
private:
|
||||
static bool isSet;
|
||||
@ -49,7 +49,7 @@ namespace Catch {
|
||||
static void handleSignal( int sig );
|
||||
|
||||
FatalConditionHandler();
|
||||
~FatalConditionHandler();
|
||||
~FatalConditionHandler() { reset(); }
|
||||
static void reset();
|
||||
};
|
||||
|
||||
@ -59,9 +59,7 @@ namespace Catch {
|
||||
#else
|
||||
|
||||
namespace Catch {
|
||||
struct FatalConditionHandler {
|
||||
void reset();
|
||||
};
|
||||
struct FatalConditionHandler {};
|
||||
}
|
||||
|
||||
#endif
|
@ -2,7 +2,7 @@
|
||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||
#include <catch2/internal/catch_context.hpp>
|
||||
#include <catch2/internal/catch_enforce.hpp>
|
||||
#include <catch2/internal/catch_fatal_condition.hpp>
|
||||
#include <catch2/internal/catch_fatal_condition_handler.hpp>
|
||||
#include <catch2/internal/catch_random_number_generator.hpp>
|
||||
#include <catch2/internal/catch_stream.hpp>
|
||||
#include <catch2/catch_timer.hpp>
|
||||
@ -377,9 +377,11 @@ namespace Catch {
|
||||
}
|
||||
|
||||
void RunContext::invokeActiveTestCase() {
|
||||
FatalConditionHandler fatalConditionHandler; // Handle signals
|
||||
// We need to register a handler for signals/structured exceptions
|
||||
// before running the tests themselves, or the binary can crash
|
||||
// without failed test being reported.
|
||||
FatalConditionHandler _;
|
||||
m_activeTestCase->invoke();
|
||||
fatalConditionHandler.reset();
|
||||
}
|
||||
|
||||
void RunContext::handleUnfinishedSections() {
|
||||
|
Loading…
Reference in New Issue
Block a user