diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 13:16:07 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-04 13:16:07 +0000 |
commit | 651bf1bad6306e680cf49c2f29d8e1a2be15e35e (patch) | |
tree | 23314c7749960d0fb2c8425b985b5ac6f256605b /base | |
parent | 59f6e74de99a7741d8c9e4717876067c387fe328 (diff) | |
download | chromium_src-651bf1bad6306e680cf49c2f29d8e1a2be15e35e.zip chromium_src-651bf1bad6306e680cf49c2f29d8e1a2be15e35e.tar.gz chromium_src-651bf1bad6306e680cf49c2f29d8e1a2be15e35e.tar.bz2 |
Clean up suppressing error dialogs for buildbots.
- also suppress dialogs caused by __debugbreak on Windows
- avoid bad interactions with gtest (they cause odd problems, really)
TEST=none
BUG=29997
Review URL: http://codereview.chromium.org/1867001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46343 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/debug_util.cc | 2 | ||||
-rw-r--r-- | base/debug_util.h | 10 | ||||
-rw-r--r-- | base/debug_util_win.cc | 3 | ||||
-rw-r--r-- | base/test/test_suite.h | 17 |
4 files changed, 20 insertions, 12 deletions
diff --git a/base/debug_util.cc b/base/debug_util.cc index 2a6cac2..21f5b70 100644 --- a/base/debug_util.cc +++ b/base/debug_util.cc @@ -6,6 +6,8 @@ #include "base/platform_thread.h" +bool DebugUtil::suppress_dialogs_ = false; + bool DebugUtil::WaitForDebugger(int wait_seconds, bool silent) { for (int i = 0; i < wait_seconds * 10; ++i) { if (BeingDebugged()) { diff --git a/base/debug_util.h b/base/debug_util.h index b9ece20..303b4df 100644 --- a/base/debug_util.h +++ b/base/debug_util.h @@ -81,6 +81,16 @@ class DebugUtil { // disables Apple Crash Reporter entirely. static void DisableOSCrashDumps(); #endif // defined(OS_MACOSX) + + // This should be used only in test code. + static void SuppressDialogs() { + suppress_dialogs_ = true; + } + + private: + // If true, avoid displaying any dialogs that could cause problems + // in non-interactive environments. + static bool suppress_dialogs_; }; #endif // BASE_DEBUG_UTIL_H_ diff --git a/base/debug_util_win.cc b/base/debug_util_win.cc index 9e7b444..b60ba31 100644 --- a/base/debug_util_win.cc +++ b/base/debug_util_win.cc @@ -219,6 +219,9 @@ bool DebugUtil::BeingDebugged() { // static void DebugUtil::BreakDebugger() { + if (suppress_dialogs_) + _exit(1); + __debugbreak(); } diff --git a/base/test/test_suite.h b/base/test/test_suite.h index a8dfdeb..9aaf055 100644 --- a/base/test/test_suite.h +++ b/base/test/test_suite.h @@ -147,19 +147,11 @@ class TestSuite { } protected: - // TODO(phajdan.jr): Clean this up. - // See http://crbug.com/29997 - - // By default, base::LogMessage::~LogMessage calls DebugUtil::BreakDebugger() - // when severity is LOG_FATAL. This results in error dialogs - // which are not friendly to buildbots. - // To avoid these problems, we override the LogMessage behaviour by - // replacing the assert handler with UnitTestAssertHandler. + // By default fatal log messages (e.g. from DCHECKs) result in error dialogs + // which gum up buildbots. Use a minimalistic assert handler which just + // terminates the process. static void UnitTestAssertHandler(const std::string& str) { - // FAIL is a googletest macro, it marks the current test as failed. - // If throw_on_failure is set to true, it also ends the process. - ::testing::FLAGS_gtest_throw_on_failure = true; - FAIL() << str; + RAW_LOG(FATAL, str.c_str()); } // Disable crash dialogs so that it doesn't gum up the buildbot @@ -204,6 +196,7 @@ class TestSuite { if (!DebugUtil::BeingDebugged() && !CommandLine::ForCurrentProcess()->HasSwitch("show-error-dialogs")) { SuppressErrorDialogs(); + DebugUtil::SuppressDialogs(); logging::SetLogAssertHandler(UnitTestAssertHandler); } |