summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-02-02 01:25:37 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-02-02 01:25:37 +0000
commit34b3f298ed6c093e36511e235fff9d7501ec4395 (patch)
tree856fa37e8b637bae48943f0e9fe6df3d73ad125c /src
parentc5e8d7a2ecb1ff1f8d295f801b89b12deb8c63fb (diff)
downloadgtest-34b3f298ed6c093e36511e235fff9d7501ec4395.tar.gz
gtest-34b3f298ed6c093e36511e235fff9d7501ec4395.tar.bz2
gtest-34b3f298ed6c093e36511e235fff9d7501ec4395.tar.xz
Add markers to death test messages to make them more recogizable (by Jeff Shute).
git-svn-id: http://googletest.googlecode.com/svn/trunk@539 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'src')
-rw-r--r--src/gtest-death-test.cc29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/gtest-death-test.cc b/src/gtest-death-test.cc
index 3ab9cf9..3e65193 100644
--- a/src/gtest-death-test.cc
+++ b/src/gtest-death-test.cc
@@ -438,6 +438,24 @@ void DeathTestImpl::Abort(AbortReason reason) {
_exit(1); // Exits w/o any normal exit hooks (we were supposed to crash)
}
+// Returns an indented copy of stderr output for a death test.
+// This makes distinguishing death test output lines from regular log lines
+// much easier.
+static ::std::string FormatDeathTestOutput(const ::std::string& output) {
+ ::std::string ret;
+ for (size_t at = 0; ; ) {
+ const size_t line_end = output.find('\n', at);
+ ret += "[ DEATH ] ";
+ if (line_end == ::std::string::npos) {
+ ret += output.substr(at);
+ break;
+ }
+ ret += output.substr(at, line_end + 1 - at);
+ at = line_end + 1;
+ }
+ return ret;
+}
+
// Assesses the success or failure of a death test, using both private
// members which have previously been set, and one argument:
//
@@ -473,15 +491,15 @@ bool DeathTestImpl::Passed(bool status_ok) {
switch (outcome()) {
case LIVED:
buffer << " Result: failed to die.\n"
- << " Error msg: " << error_message;
+ << " Error msg:\n" << FormatDeathTestOutput(error_message);
break;
case THREW:
buffer << " Result: threw an exception.\n"
- << " Error msg: " << error_message;
+ << " Error msg:\n" << FormatDeathTestOutput(error_message);
break;
case RETURNED:
buffer << " Result: illegal return in test statement.\n"
- << " Error msg: " << error_message;
+ << " Error msg:\n" << FormatDeathTestOutput(error_message);
break;
case DIED:
if (status_ok) {
@@ -491,11 +509,12 @@ bool DeathTestImpl::Passed(bool status_ok) {
} else {
buffer << " Result: died but not with expected error.\n"
<< " Expected: " << regex()->pattern() << "\n"
- << "Actual msg: " << error_message;
+ << "Actual msg:\n" << FormatDeathTestOutput(error_message);
}
} else {
buffer << " Result: died but not with expected exit code:\n"
- << " " << ExitSummary(status()) << "\n";
+ << " " << ExitSummary(status()) << "\n"
+ << "Actual msg:\n" << FormatDeathTestOutput(error_message);
}
break;
case IN_PROGRESS: