hammondt / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Death tests don't pass when using FAIL() in a child process on Windows. #235

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here's the sample code:

#include <gtest/gtest.h>
void foo() {
  FAIL() << "Test";
}
TEST(DeathTest, FailTest) {
  ASSERT_DEATH(foo(), "");
}

It works ok on Linux and Mac, but fails on Windows.
After a bit of debugging I think this is because "exit(1") is not called inside 
"UnitTest::AddTestPartResult" 
(gtest/src/gtest.cc).

This test passes if I set "::testing::FLAGS_gtest_throw_on_failure = true;"

I faced this issue in Chromium since its ~LogMessage with type=FATAL calls 
FAIL().
As a result, we can't write cross-platform death tests for Chromium without the 
hack described above.

Original issue reported on code.google.com by timurrrr@chromium.org on 7 Dec 2009 at 10:42