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

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_run_context.cpp
diff options
context:
space:
mode:
authorMartin Hořeňovský2017-08-10 11:34:26 +0200
committerMartin Hořeňovský2017-08-10 11:34:26 +0200
commitaa42dd92d104e894e2b54d29a3defdf4b00eec21 (patch)
tree4bdf430c746a2c98e6092705760d3f78c5421436 /include/internal/catch_run_context.cpp
parente658bacb04ef5c14c1dcb192c9e5c99cef390582 (diff)
parent7e4038d8488596e850a11c8fe236b59bca605444 (diff)
downloadcatch3-aa42dd92d104e894e2b54d29a3defdf4b00eec21.tar.gz
Merge branch 'master' into dev-modernize
Diffstat (limited to 'include/internal/catch_run_context.cpp')
-rw-r--r--include/internal/catch_run_context.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index b54742ff..d25b958a 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -18,6 +18,19 @@ namespace Catch {
m_stream.rdbuf(m_prevBuf);
}
+ StdErrRedirect::StdErrRedirect(std::string & targetString)
+ :m_cerrBuf(cerr().rdbuf()), m_clogBuf(clog().rdbuf()),
+ m_targetString(targetString) {
+ cerr().rdbuf(m_oss.rdbuf());
+ clog().rdbuf(m_oss.rdbuf());
+ }
+
+ StdErrRedirect::~StdErrRedirect() {
+ m_targetString += m_oss.str();
+ cerr().rdbuf(m_cerrBuf);
+ clog().rdbuf(m_clogBuf);
+ }
+
RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter)
: m_runInfo(_config->name()),
m_context(getCurrentMutableContext()),
@@ -256,7 +269,7 @@ namespace Catch {
timer.start();
if (m_reporter->getPreferences().shouldRedirectStdOut) {
StreamRedirect coutRedir(cout(), redirectedCout);
- StreamRedirect cerrRedir(cerr(), redirectedCerr);
+ StdErrRedirect errRedir(redirectedCerr);
invokeActiveTestCase();
} else {
invokeActiveTestCase();
@@ -318,5 +331,4 @@ namespace Catch {
else
CATCH_INTERNAL_ERROR("No result capture instance");
}
-
} \ No newline at end of file