diff options
author | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 20:33:02 +0000 |
---|---|---|
committer | timurrrr@chromium.org <timurrrr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-10 20:33:02 +0000 |
commit | 31a80f2ad70f9c29ca604bbda2a934b3fe6fc7f4 (patch) | |
tree | f0903b0947fc84421556ebec81fdc7de78087db5 /base/test | |
parent | b2ba996f96dfd3bde403fce818258d97e3ca8002 (diff) | |
download | chromium_src-31a80f2ad70f9c29ca604bbda2a934b3fe6fc7f4.zip chromium_src-31a80f2ad70f9c29ca604bbda2a934b3fe6fc7f4.tar.gz chromium_src-31a80f2ad70f9c29ca604bbda2a934b3fe6fc7f4.tar.bz2 |
Force failing CHECK/DCHECKs to end the process on Windows.
The current implementation of Windows-only hook simply calls FAIL.
According to http://code.google.com/p/googletest/issues/list?cursor=234
it is a misuse of FAIL macros (it may not shut down the process).
As a result, it was impossible to write death tests on windows.
BUG=24885
Review URL: http://codereview.chromium.org/482001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/test')
-rw-r--r-- | base/test/test_suite.h | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/base/test/test_suite.h b/base/test/test_suite.h index 7eac0d4..03cbca2 100644 --- a/base/test/test_suite.h +++ b/base/test/test_suite.h @@ -58,7 +58,7 @@ class TestSuite { #if defined(OS_LINUX) g_thread_init(NULL); gtk_init_check(&argc, &argv); -#endif +#endif // defined(OS_LINUX) // Don't add additional code to this constructor. Instead add it to // Initialize(). See bug 6436. } @@ -146,12 +146,22 @@ class TestSuite { } protected: - // All fatal log messages (e.g. DCHECK failures) imply unit test failures. +#if defined(OS_WIN) + // TODO(phajdan.jr): Clean up the windows-specific hacks. + // See http://crbug.com/29997 + + // By default, base::LogMessage::~LogMessage calls DebugUtil::BreakDebugger() + // when severity is LOG_FATAL. On Windows, 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. 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; } -#if defined(OS_WIN) // Disable crash dialogs so that it doesn't gum up the buildbot virtual void SuppressErrorDialogs() { UINT new_flags = SEM_FAILCRITICALERRORS | @@ -163,7 +173,7 @@ class TestSuite { UINT existing_flags = SetErrorMode(new_flags); SetErrorMode(existing_flags | new_flags); } -#endif +#endif // defined(OS_WIN) // Override these for custom initialization and shutdown handling. Use these // instead of putting complex code in your constructor/destructor. |