From 8cc0d21124e67b01ccc6e090db539ae83146079f Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sat, 23 Aug 2014 10:25:21 -0700 Subject: [PATCH] Move the Crash Reporter fix to Google Test where it belongs. --- gtest/gtest-all.cc | 7 +++++++ test/test-main.cc | 7 +------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gtest/gtest-all.cc b/gtest/gtest-all.cc index 7c858630..8ae4c5e8 100644 --- a/gtest/gtest-all.cc +++ b/gtest/gtest-all.cc @@ -6535,6 +6535,8 @@ void InitGoogleTest(int* argc, wchar_t** argv) { # if GTEST_OS_MAC # include +# include +# include # endif // GTEST_OS_MAC # include @@ -7337,6 +7339,11 @@ DeathTest::TestRole NoExecDeathTest::AssumeRole() { GTEST_DEATH_TEST_CHECK_(child_pid != -1); set_child_pid(child_pid); if (child_pid == 0) { +#if GTEST_OS_MAC + // This ensures that Crash Reporter is not invoked on death tests. + std::signal(SIGABRT, std::exit); + std::signal(SIGSEGV, std::exit); +#endif GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0])); set_write_fd(pipe_fd[1]); // Redirects all logging to stderr in the child process to prevent diff --git a/test/test-main.cc b/test/test-main.cc index 84609d20..036394cd 100644 --- a/test/test-main.cc +++ b/test/test-main.cc @@ -26,8 +26,6 @@ */ #include -#include -#include #ifdef _WIN32 # include @@ -35,10 +33,7 @@ #endif int main(int argc, char **argv) { -#if defined(__APPLE__) - // This ensures that Crash Reporter is not invoked on death tests. - std::signal(SIGABRT, std::exit); -#elif defined(_WIN32) +#ifdef _WIN32 // Don't display any error dialogs. This also suppresses message boxes // on assertion failures in MinGW where _set_error_mode/CrtSetReportMode // doesn't help.