Commit f2334aa1 by zhanyong.wan

Ports gtest to minGW (by Kenton Varda).

parent fa2b06c5
......@@ -181,8 +181,9 @@ samples_sample8_unittest_LDADD = lib/libgtest_main.la \
TESTS += test/gtest-death-test_test
check_PROGRAMS += test/gtest-death-test_test
test_gtest_death_test_test_SOURCES = test/gtest-death-test_test.cc
test_gtest_death_test_test_CXXFLAGS = $(AM_CXXFLAGS) -pthread
test_gtest_death_test_test_LDADD = -lpthread lib/libgtest_main.la
test_gtest_death_test_test_CXXFLAGS = $(AM_CXXFLAGS) $(PTHREAD_CFLAGS)
test_gtest_death_test_test_LDADD = $(PTHREAD_LIBS) $(PTHREAD_CFLAGS) \
lib/libgtest_main.la
TESTS += test/gtest_environment_test
check_PROGRAMS += test/gtest_environment_test
......
m4_include(m4/acx_pthread.m4)
# At this point, the Xcode project assumes the version string will be three
# integers separated by periods and surrounded by square brackets (e.g.
# "[1.0.1]"). It also asumes that there won't be any closing parenthesis
......@@ -37,6 +39,9 @@ AS_IF([test "$PYTHON" != ":"],
[AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=":"])])
AM_CONDITIONAL([HAVE_PYTHON],[test "$PYTHON" != ":"])
# Check for pthreads.
ACX_PTHREAD
# TODO(chandlerc@google.com) Check for the necessary system headers.
# TODO(chandlerc@google.com) Check the types, structures, and other compiler
......
......@@ -60,6 +60,9 @@
// be used where std::wstring is unavailable).
// GTEST_HAS_TR1_TUPLE 1 - Define it to 1/0 to indicate tr1::tuple
// is/isn't available.
// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the
// compiler supports Microsoft's "Structured
// Exception Handling".
// This header defines the following utilities:
//
......@@ -473,6 +476,22 @@
#define GTEST_MUST_USE_RESULT_
#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
// Determine whether the compiler supports Microsoft's Structured Exception
// Handling. This is supported by several Windows compilers but generally
// does not exist on any other system.
#ifndef GTEST_HAS_SEH
// The user didn't tell us, so we need to figure it out.
#if defined(_MSC_VER) || defined(__BORLANDC__)
// These two compilers are known to support SEH.
#define GTEST_HAS_SEH 1
#else
// Assume no SEH.
#define GTEST_HAS_SEH 0
#endif
#endif // GTEST_HAS_SEH
namespace testing {
class Message;
......
......@@ -2013,8 +2013,8 @@ void Test::Run() {
if (!HasSameFixtureClass()) return;
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
#if GTEST_OS_WINDOWS
// We are on Windows.
#if GTEST_HAS_SEH
// Catch SEH-style exceptions.
impl->os_stack_trace_getter()->UponLeavingGTest();
__try {
SetUp();
......@@ -2045,7 +2045,7 @@ void Test::Run() {
AddExceptionThrownFailure(GetExceptionCode(), "TearDown()");
}
#else // We are on Linux or Mac - exceptions are disabled.
#else // We are on a compiler or platform that doesn't support SEH.
impl->os_stack_trace_getter()->UponLeavingGTest();
SetUp();
......@@ -2060,7 +2060,7 @@ void Test::Run() {
// failed.
impl->os_stack_trace_getter()->UponLeavingGTest();
TearDown();
#endif // GTEST_OS_WINDOWS
#endif // GTEST_HAS_SEH
}
......@@ -2256,8 +2256,8 @@ void TestInfoImpl::Run() {
const TimeInMillis start = GetTimeInMillis();
impl->os_stack_trace_getter()->UponLeavingGTest();
#if GTEST_OS_WINDOWS
// We are on Windows.
#if GTEST_HAS_SEH
// Catch SEH-style exceptions.
Test* test = NULL;
__try {
......@@ -2269,7 +2269,7 @@ void TestInfoImpl::Run() {
"the test fixture's constructor");
return;
}
#else // We are on Linux or Mac OS - exceptions are disabled.
#else // We are on a compiler or platform that doesn't support SEH.
// TODO(wan): If test->Run() throws, test won't be deleted. This is
// not a problem now as we don't use exceptions. If we were to
......@@ -2278,7 +2278,7 @@ void TestInfoImpl::Run() {
// Creates the test object.
Test* test = factory_->CreateTest();
#endif // GTEST_OS_WINDOWS
#endif // GTEST_HAS_SEH
// Runs the test only if the constructor of the test fixture didn't
// generate a fatal failure.
......@@ -3333,7 +3333,8 @@ void UnitTest::RecordPropertyForCurrentTest(const char* key,
// We don't protect this under mutex_, as we only support calling it
// from the main thread.
int UnitTest::Run() {
#if GTEST_OS_WINDOWS
#if GTEST_HAS_SEH
// Catch SEH-style exceptions.
const bool in_death_test_child_process =
internal::GTEST_FLAG(internal_run_death_test).GetLength() > 0;
......@@ -3381,11 +3382,10 @@ int UnitTest::Run() {
return 1;
}
#else
// We are on Linux or Mac OS. There is no exception of any kind.
#else // We are on a compiler or platform that doesn't support SEH.
return impl_->RunAllTests();
#endif // GTEST_OS_WINDOWS
#endif // GTEST_HAS_SEH
}
// Returns the working directory when the first TEST() or TEST_F() was
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment