Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorMartin Hořeňovský2017-09-14 19:57:59 +0200
committerMartin Hořeňovský2017-09-14 19:57:59 +0200
commit4e852672033ac989e303a4a00de607738e64e7e5 (patch)
tree9c3947fa71243d72122c85e0df9243a5f64bdf99 /include
parenteaf850cd0c2c3322a1dddb9a2e37210db3f15df4 (diff)
downloadcatch3-4e852672033ac989e303a4a00de607738e64e7e5.tar.gz
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
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_interfaces_reporter.cpp2
-rw-r--r--include/internal/catch_interfaces_reporter.h4
-rw-r--r--include/internal/catch_run_context.cpp3
3 files changed, 8 insertions, 1 deletions
diff --git a/include/internal/catch_interfaces_reporter.cpp b/include/internal/catch_interfaces_reporter.cpp
index 06e409ae..3859c546 100644
--- a/include/internal/catch_interfaces_reporter.cpp
+++ b/include/internal/catch_interfaces_reporter.cpp
@@ -105,7 +105,7 @@ namespace Catch {
TestRunStats::~TestRunStats() = default;
-
+ void IStreamingReporter::fatalErrorEncountered( StringRef name ) {}
bool IStreamingReporter::isMulti() const { return false; }
IReporterFactory::~IReporterFactory() = default;
diff --git a/include/internal/catch_interfaces_reporter.h b/include/internal/catch_interfaces_reporter.h
index 43beca68..318ce669 100644
--- a/include/internal/catch_interfaces_reporter.h
+++ b/include/internal/catch_interfaces_reporter.h
@@ -16,6 +16,7 @@
#include "catch_assertionresult.h"
#include "catch_message.h"
#include "catch_option.hpp"
+#include "catch_stringref.h"
#include <string>
@@ -201,6 +202,9 @@ namespace Catch {
virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
+ // Default empty implementation provided
+ virtual void fatalErrorEncountered( StringRef name );
+
virtual bool isMulti() const;
};
using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>;
diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index 60f133a0..b034ec62 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -209,6 +209,9 @@ namespace Catch {
}
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
// Instead, fake a result data.
AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } );