exceptions reported as errors

48 views
Skip to first unread message

Keith Ray

unread,
Oct 3, 2008, 11:56:36 AM10/3/08
to Google C++ Testing Framework
I just noticed the 1.1 gTest code seems to catch exceptions and report them as errors but only on Windows and not MacOS X and Linux.

void Test::Run() {
 if (!HasSameFixtureClass()) return;

 internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
#ifdef GTEST_OS_WINDOWS
....  __try ... __catch ... AddExceptionThrownFailure ...
#else  // We are on Linux or Mac - exceptions are disabled.
#endif

what we're seeing with CGWIN on Windows is that exceptions crash the test app, and on MacOS X the exceptions are swallowed without error reporting.

Is there code post-1.1 that handles exceptions on all platforms?

--
C. Keith Ray, IXP Coach, Industrial Logic, Inc.
http://industriallogic.com      866-540-8336 (toll free)
Groove with our Agile Greatest Hits: http://www.industriallogic.com/elearning/
http://agilesolutionspace.blogspot.com/

Zhanyong Wan (λx.x x)

unread,
Oct 3, 2008, 2:56:12 PM10/3/08
to Keith Ray, Google C++ Testing Framework
Hi Keith,

On Fri, Oct 3, 2008 at 8:56 AM, Keith Ray <keit...@gmail.com> wrote:
> I just noticed the 1.1 gTest code seems to catch exceptions and report them
> as errors but only on Windows and not MacOS X and Linux.
>
> void Test::Run() {
> if (!HasSameFixtureClass()) return;
>
> internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();
> #ifdef GTEST_OS_WINDOWS
> .... __try ... __catch ... AddExceptionThrownFailure ...
> #else // We are on Linux or Mac - exceptions are disabled.
> #endif
>
> what we're seeing with CGWIN on Windows is that exceptions crash the test
> app, and on MacOS X the exceptions are swallowed without error reporting.
>
> Is there code post-1.1 that handles exceptions on all platforms?

We don't have the code for that yet. Could you log an issue and
perhaps contribute a patch? :-) If you do it, you should key off the
GTEST_HAS_EXCEPTIONS macro defined in
include/gtest/internal/gtest-port.h. We need to figure out how to
detect whether exceptions are enabled in gcc.

>
> --
> C. Keith Ray, IXP Coach, Industrial Logic, Inc.
> http://industriallogic.com 866-540-8336 (toll free)
> Groove with our Agile Greatest Hits:
> http://www.industriallogic.com/elearning/
> http://agilesolutionspace.blogspot.com/
>
>

--
Zhanyong

Keith Ray

unread,
Oct 3, 2008, 3:01:25 PM10/3/08
to Zhanyong Wan (λx.x x), Google C++ Testing Framework
OK.  I'm working on something that currently requires me to -D define GTEST_HAS_EXCEPTIONS when compiling.

Could you point me to a summary of how to log an issue and how to create a patch to send in?  (I'm on WindowsXP with mingw g++/Eclipse and MacOSX with gcc/Eclipse.)

Zhanyong Wan (λx.x x)

unread,
Oct 3, 2008, 3:59:03 PM10/3/08
to Keith Ray, Google C++ Testing Framework
On Fri, Oct 3, 2008 at 12:01 PM, Keith Ray <keit...@gmail.com> wrote:
> OK. I'm working on something that currently requires me to -D define
> GTEST_HAS_EXCEPTIONS when compiling.
>
> Could you point me to a summary of how to log an issue and how to create a
> patch to send in? (I'm on WindowsXP with mingw g++/Eclipse and MacOSX with
> gcc/Eclipse.)

To log an issue, please go to the project homepage
http://code.google.com/p/googletest/ and click on "Issues".

Please see http://code.google.com/p/googletest/wiki/GoogleTestDevGuide
for how to contribute a patch.

Thanks,

--
Zhanyong

Reply all
Reply to author
Forward
0 new messages