Skip to content

Commit 4ba0fad

Browse files
committed
Merge 64367 from mainline.
Fix MingW build: define GTEST_OS_WINDOWS if OS is MingW, but disable exceptions. llvm-svn: 64521
1 parent 031126c commit 4ba0fad

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

llvm/utils/unittest/googletest/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ BUILD_ARCHIVE = 1
1818
CPP.Flags += -I$(LLVM_SRC_ROOT)/utils/unittest/googletest/include/
1919
CPP.Flags += $(NO_MISSING_FIELD_INITIALIZERS) $(NO_VARIADIC_MACROS)
2020

21+
ifeq ($(OS),MingW)
22+
CPP.Flags += -DGTEST_OS_WINDOWS=1
23+
endif
24+
2125
include $(LEVEL)/Makefile.common

llvm/utils/unittest/googletest/gtest.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ void Test::Run() {
19931993
if (!HasSameFixtureClass()) return;
19941994

19951995
internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
1996-
#ifdef GTEST_OS_WINDOWS
1996+
#if defined(GTEST_OS_WINDOWS) && !defined(__MINGW32__)
19971997
// We are on Windows.
19981998
impl->os_stack_trace_getter()->UponLeavingGTest();
19991999
__try {
@@ -2025,7 +2025,7 @@ void Test::Run() {
20252025
AddExceptionThrownFailure(GetExceptionCode(), "TearDown()");
20262026
}
20272027

2028-
#else // We are on Linux or Mac - exceptions are disabled.
2028+
#else // We are on Linux, Mac or MingW - exceptions are disabled.
20292029
impl->os_stack_trace_getter()->UponLeavingGTest();
20302030
SetUp();
20312031

@@ -2227,7 +2227,7 @@ void TestInfoImpl::Run() {
22272227
const TimeInMillis start = GetTimeInMillis();
22282228

22292229
impl->os_stack_trace_getter()->UponLeavingGTest();
2230-
#ifdef GTEST_OS_WINDOWS
2230+
#if defined(GTEST_OS_WINDOWS) && !defined(__MINGW32__)
22312231
// We are on Windows.
22322232
Test* test = NULL;
22332233

@@ -2240,7 +2240,7 @@ void TestInfoImpl::Run() {
22402240
"the test fixture's constructor");
22412241
return;
22422242
}
2243-
#else // We are on Linux or Mac OS - exceptions are disabled.
2243+
#else // We are on Linux, Mac OS or MingW - exceptions are disabled.
22442244

22452245
// TODO(wan): If test->Run() throws, test won't be deleted. This is
22462246
// not a problem now as we don't use exceptions. If we were to
@@ -3271,7 +3271,7 @@ void UnitTest::RecordPropertyForCurrentTest(const char* key,
32713271
// We don't protect this under mutex_, as we only support calling it
32723272
// from the main thread.
32733273
int UnitTest::Run() {
3274-
#ifdef GTEST_OS_WINDOWS
3274+
#if defined(GTEST_OS_WINDOWS) && !defined(__MINGW32__)
32753275

32763276
#if !defined(_WIN32_WCE)
32773277
// SetErrorMode doesn't exist on CE.
@@ -3294,7 +3294,7 @@ int UnitTest::Run() {
32943294
}
32953295

32963296
#else
3297-
// We are on Linux or Mac OS. There is no exception of any kind.
3297+
// We are on Linux, Mac OS or MingW. There is no exception of any kind.
32983298

32993299
return impl_->RunAllTests();
33003300
#endif // GTEST_OS_WINDOWS

0 commit comments

Comments
 (0)