diff options
author | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-03-06 01:20:15 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-03-06 01:20:15 +0000 |
commit | 4984c93490eeeb7d3d1979b30a39a21cad07cba5 (patch) | |
tree | ca3c2306a370dda3388a4cbd34d22331debaec87 /src/gtest.cc | |
parent | 0af0709b02899f9177db55eba7929e65e5834b29 (diff) | |
download | googletest-4984c93490eeeb7d3d1979b30a39a21cad07cba5.tar.gz googletest-4984c93490eeeb7d3d1979b30a39a21cad07cba5.tar.bz2 googletest-4984c93490eeeb7d3d1979b30a39a21cad07cba5.zip |
Implements death tests on Windows (by Vlad Losev); enables POSIX regex on Mac and Cygwin; fixes build issue on some Linux versions due to PATH_MAX.
Diffstat (limited to 'src/gtest.cc')
-rw-r--r-- | src/gtest.cc | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/src/gtest.cc b/src/gtest.cc index e4f9d0f3..f86a2a35 100644 --- a/src/gtest.cc +++ b/src/gtest.cc @@ -3300,17 +3300,43 @@ void UnitTest::RecordPropertyForCurrentTest(const char* key, int UnitTest::Run() { #if GTEST_OS_WINDOWS + const bool in_death_test_child_process = + internal::GTEST_FLAG(internal_run_death_test).GetLength() > 0; + + // Either the user wants Google Test to catch exceptions thrown by the + // tests or this is executing in the context of death test child + // process. In either case the user does not want to see pop-up dialogs + // about crashes - they are expected.. + if (GTEST_FLAG(catch_exceptions) || in_death_test_child_process) { #if !defined(_WIN32_WCE) - // SetErrorMode doesn't exist on CE. - if (GTEST_FLAG(catch_exceptions)) { - // The user wants Google Test to catch exceptions thrown by the tests. - - // This lets fatal errors be handled by us, instead of causing pop-ups. + // SetErrorMode doesn't exist on CE. SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); - } #endif // _WIN32_WCE + // Death test children can be terminated with _abort(). On Windows, + // _abort() can show a dialog with a warning message. This forces the + // abort message to go to stderr instead. + _set_error_mode(_OUT_TO_STDERR); + + // In the debug version, Visual Studio pops up a separate dialog + // offering a choice to debug the aborted program. We need to suppress + // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement + // executed. Google Test will notify the user of any unexpected + // failure via stderr. +#if _MSC_VER >= 1400 + // VC++ doesn't define _set_abort_behavior() prior to the version 8.0. + // Users of prior VC versions shall suffer the agony and pain of + // clicking through the countless debug dialogs. + // TODO(vladl@google.com): find a way to suppress the abort dialog() in the + // debug mode when compiled with VC 7.1 or lower. + if (!GTEST_FLAG(break_on_failure)) + _set_abort_behavior( + 0x0, // Clear the following flags: + _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. +#endif // _MSC_VER >= 1400 + } + __try { return impl_->RunAllTests(); } __except(internal::UnitTestOptions::GTestShouldProcessSEH( |