test icon indicating copy to clipboard operation
test copied to clipboard

Provide an option to disable exception catching

Open TheQuantumPhysicist opened this issue 4 years ago • 6 comments

Some times it's useful to just let unexpected exceptions do their work in tests. Especially when debugging. For example, gtest provides the option --gtest_catch_exceptions=0 or the environment variable GTEST_CATCH_EXCEPTIONS, where the test framework doesn't catch any exceptions if any of these options is set to 0.

Granted, catching unexpected exceptions by default is helpful because otherwise the tests will abort. But then during debugging (at the dev's will, for example, using a command line argument like the one above), it's much easier to catch unintended bug by just letting the tests/program fire and abort the program. A debugger will immediately show the correct stack trace and the source of the problem.

I think adding such a command line argument (and maybe also environment variable) is very useful and saves lots of time when debugging.

TheQuantumPhysicist avatar Sep 14 '21 07:09 TheQuantumPhysicist

Isn't the command line argument --catch_system_errors doing this already? Or maybe it is still catching things?

raffienficiaud avatar Mar 02 '22 09:03 raffienficiaud

Well, given that the default value of --catch_system_errors is no, then it's obviously not working.

TheQuantumPhysicist avatar Mar 02 '22 10:03 TheQuantumPhysicist

The documentation seems to be wrong ! I can see the following code

#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
            false,
#else
            true,
#endif

which seems to be doing the exact opposite of the documentation. Would it be possible for you to explicitly indicate --catch-system-error=no and let me know if this works for you?

raffienficiaud avatar Mar 02 '22 14:03 raffienficiaud

I'm sorry, but I'm in a very bad health condition that I'm almost incapacitated I can't do anything right now. If someone else can do this, that'd be great.

TheQuantumPhysicist avatar Mar 03 '22 06:03 TheQuantumPhysicist

I am sorry to hear that, take care and get well soon

raffienficiaud avatar Mar 03 '22 06:03 raffienficiaud

I can confirm the framework does not catch system exceptions with --catch_system_errors=no.

I also believe the documentation and implementation have the values swapped.

Locally we have #defined BOOST_TEST_DEFAULTS_TO_CORE_DUMP to get the expected default.

krwalker avatar Oct 10 '22 20:10 krwalker