mirror of
https://github.com/catchorg/Catch2.git
synced 2024-12-23 11:43:29 +01:00
Add fatalErrorEncountered method to Reporter/Listener interface
An empty default implementation is provided to keep backward compatibility. Called when signal or Structured Exception is encountered. Related to #1005
This commit is contained in:
parent
eaf850cd0c
commit
4e85267203
@ -105,7 +105,7 @@ namespace Catch {
|
|||||||
|
|
||||||
TestRunStats::~TestRunStats() = default;
|
TestRunStats::~TestRunStats() = default;
|
||||||
|
|
||||||
|
void IStreamingReporter::fatalErrorEncountered( StringRef name ) {}
|
||||||
bool IStreamingReporter::isMulti() const { return false; }
|
bool IStreamingReporter::isMulti() const { return false; }
|
||||||
|
|
||||||
IReporterFactory::~IReporterFactory() = default;
|
IReporterFactory::~IReporterFactory() = default;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "catch_assertionresult.h"
|
#include "catch_assertionresult.h"
|
||||||
#include "catch_message.h"
|
#include "catch_message.h"
|
||||||
#include "catch_option.hpp"
|
#include "catch_option.hpp"
|
||||||
|
#include "catch_stringref.h"
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -201,6 +202,9 @@ namespace Catch {
|
|||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
|
||||||
|
|
||||||
|
// Default empty implementation provided
|
||||||
|
virtual void fatalErrorEncountered( StringRef name );
|
||||||
|
|
||||||
virtual bool isMulti() const;
|
virtual bool isMulti() const;
|
||||||
};
|
};
|
||||||
using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>;
|
using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>;
|
||||||
|
@ -209,6 +209,9 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RunContext::handleFatalErrorCondition(std::string const & message) {
|
void RunContext::handleFatalErrorCondition(std::string const & message) {
|
||||||
|
// First notify reporter that bad things happened
|
||||||
|
m_reporter->fatalErrorEncountered(message);
|
||||||
|
|
||||||
// Don't rebuild the result -- the stringification itself can cause more fatal errors
|
// Don't rebuild the result -- the stringification itself can cause more fatal errors
|
||||||
// Instead, fake a result data.
|
// Instead, fake a result data.
|
||||||
AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } );
|
AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } );
|
||||||
|
Loading…
Reference in New Issue
Block a user