diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-06-02 22:01:25 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-06-02 22:01:25 +0000 |
commit | f2f402059f79733304d17ab9a52b6d20ab956c59 (patch) | |
tree | 8143da43a08354ce919f43824454c4211211e5f1 /llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h | |
parent | c9b9bdcc20c40c832df08eb3583ab87ad8f8089f (diff) | |
download | bcm5719-llvm-f2f402059f79733304d17ab9a52b6d20ab956c59.tar.gz bcm5719-llvm-f2f402059f79733304d17ab9a52b6d20ab956c59.zip |
Merge gtest-1.3.0.
OSX users: make sure that CrashReporter is disabled when running unit tests.
Death tests are enabled now so you'll get a ton of message boxes.
llvm-svn: 105352
Diffstat (limited to 'llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h')
-rw-r--r-- | llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h | 54 |
1 files changed, 46 insertions, 8 deletions
diff --git a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h b/llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h index 0769fcaa0e8..ff2e490efee 100644 --- a/llvm/utils/unittest/googletest/include/gtest/internal/gtest-death-test-internal.h +++ b/llvm/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 |