mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Small cleanup of fatal condition handler
This commit is contained in:
parent
b955355ec4
commit
517839fb3f
@ -55,7 +55,7 @@ set(INTERNAL_HEADERS
|
|||||||
${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
|
${SOURCES_DIR}/internal/catch_enum_values_registry.hpp
|
||||||
${SOURCES_DIR}/internal/catch_errno_guard.hpp
|
${SOURCES_DIR}/internal/catch_errno_guard.hpp
|
||||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.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_generator_exception.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generators.hpp
|
${SOURCES_DIR}/generators/catch_generators.hpp
|
||||||
${SOURCES_DIR}/generators/catch_generators_adapters.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_enum_values_registry.cpp
|
||||||
${SOURCES_DIR}/internal/catch_errno_guard.cpp
|
${SOURCES_DIR}/internal/catch_errno_guard.cpp
|
||||||
${SOURCES_DIR}/internal/catch_exception_translator_registry.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_generator_exception.cpp
|
||||||
${SOURCES_DIR}/generators/catch_generators.cpp
|
${SOURCES_DIR}/generators/catch_generators.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_capture.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_capture.cpp
|
||||||
|
@ -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/internal/catch_context.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||||
@ -75,10 +75,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FatalConditionHandler::~FatalConditionHandler() {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FatalConditionHandler::isSet = false;
|
bool FatalConditionHandler::isSet = false;
|
||||||
ULONG FatalConditionHandler::guaranteeSize = 0;
|
ULONG FatalConditionHandler::guaranteeSize = 0;
|
||||||
PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr;
|
PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr;
|
||||||
@ -138,11 +134,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FatalConditionHandler::~FatalConditionHandler() {
|
|
||||||
reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FatalConditionHandler::reset() {
|
void FatalConditionHandler::reset() {
|
||||||
if( isSet ) {
|
if( isSet ) {
|
||||||
// Set signals back to previous values -- hopefully nobody overwrote them in the meantime
|
// Set signals back to previous values -- hopefully nobody overwrote them in the meantime
|
||||||
@ -163,12 +154,6 @@ namespace Catch {
|
|||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
void FatalConditionHandler::reset() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // signals/SEH handling
|
#endif // signals/SEH handling
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
@ -23,7 +23,7 @@ namespace Catch {
|
|||||||
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo);
|
static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo);
|
||||||
FatalConditionHandler();
|
FatalConditionHandler();
|
||||||
static void reset();
|
static void reset();
|
||||||
~FatalConditionHandler();
|
~FatalConditionHandler() { reset(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool isSet;
|
static bool isSet;
|
||||||
@ -49,7 +49,7 @@ namespace Catch {
|
|||||||
static void handleSignal( int sig );
|
static void handleSignal( int sig );
|
||||||
|
|
||||||
FatalConditionHandler();
|
FatalConditionHandler();
|
||||||
~FatalConditionHandler();
|
~FatalConditionHandler() { reset(); }
|
||||||
static void reset();
|
static void reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,9 +59,7 @@ namespace Catch {
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
struct FatalConditionHandler {
|
struct FatalConditionHandler {};
|
||||||
void reset();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -2,7 +2,7 @@
|
|||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
#include <catch2/internal/catch_context.hpp>
|
#include <catch2/internal/catch_context.hpp>
|
||||||
#include <catch2/internal/catch_enforce.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_random_number_generator.hpp>
|
||||||
#include <catch2/internal/catch_stream.hpp>
|
#include <catch2/internal/catch_stream.hpp>
|
||||||
#include <catch2/catch_timer.hpp>
|
#include <catch2/catch_timer.hpp>
|
||||||
@ -377,9 +377,11 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RunContext::invokeActiveTestCase() {
|
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();
|
m_activeTestCase->invoke();
|
||||||
fatalConditionHandler.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunContext::handleUnfinishedSections() {
|
void RunContext::handleUnfinishedSections() {
|
||||||
|
Loading…
Reference in New Issue
Block a user