aboutsummaryrefslogtreecommitdiff
path: root/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h')
-rw-r--r--utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h54
1 files changed, 46 insertions, 8 deletions
diff --git a/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h b/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
index 0769fcaa0e..ff2e490efe 100644
--- a/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
+++ b/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h
@@ -39,6 +39,10 @@
#include <gtest/internal/gtest-internal.h>
+#if GTEST_HAS_DEATH_TEST && GTEST_OS_WINDOWS
+#include <io.h>
+#endif // GTEST_HAS_DEATH_TEST && GTEST_OS_WINDOWS
+
namespace testing {
namespace internal {
@@ -46,9 +50,10 @@ GTEST_DECLARE_string_(internal_run_death_test);
// Names of the flags (needed for parsing Google Test flags).
const char kDeathTestStyleFlag[] = "death_test_style";
+const char kDeathTestUseFork[] = "death_test_use_fork";
const char kInternalRunDeathTestFlag[] = "internal_run_death_test";
-#ifdef GTEST_HAS_DEATH_TEST
+#if GTEST_HAS_DEATH_TEST
// DeathTest is a class that hides much of the complexity of the
// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method
@@ -120,7 +125,12 @@ class DeathTest {
// the last death test.
static const char* LastMessage();
+ static void set_last_death_test_message(const String& message);
+
private:
+ // A string containing a description of the outcome of the last death test.
+ static String last_death_test_message_;
+
GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);
};
@@ -166,7 +176,7 @@ bool ExitedUnsuccessfully(int exit_status);
case ::testing::internal::DeathTest::EXECUTE_TEST: { \
::testing::internal::DeathTest::ReturnSentinel \
gtest_sentinel(gtest_dt); \
- { statement; } \
+ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \
break; \
} \
@@ -178,14 +188,42 @@ bool ExitedUnsuccessfully(int exit_status);
// The symbol "fail" here expands to something into which a message
// can be streamed.
-// A struct representing the parsed contents of the
+// A class representing the parsed contents of the
// --gtest_internal_run_death_test flag, as it existed when
// RUN_ALL_TESTS was called.
-struct InternalRunDeathTestFlag {
- String file;
- int line;
- int index;
- int status_fd;
+class InternalRunDeathTestFlag {
+ public:
+ InternalRunDeathTestFlag(const String& file,
+ int line,
+ int index,
+ int status_fd)
+ : file_(file), line_(line), index_(index), status_fd_(status_fd) {}
+
+ ~InternalRunDeathTestFlag() {
+ if (status_fd_ >= 0)
+// Suppress MSVC complaints about POSIX functions.
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4996)
+#endif // _MSC_VER
+ close(status_fd_);
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif // _MSC_VER
+ }
+
+ String file() const { return file_; }
+ int line() const { return line_; }
+ int index() const { return index_; }
+ int status_fd() const { return status_fd_; }
+
+ private:
+ String file_;
+ int line_;
+ int index_;
+ int status_fd_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);
};
// Returns a newly created InternalRunDeathTestFlag object with fields