Boost unit test with BOOST_NO_EXCEPTIONS
I work on a team that uses compiles with exception support disabled. (That... is not my decision, and no value judgments on that, please. :-)) I'd kind of like to use the unit test library. However, at a surface level it has lots of uses of raw try/catch/throw instead of BOOST_TRY/BOOST_CATCH/BOOST_THROW. At a deeper level, I suspect what's doing is throwing an exception on an EXPECT or ASSERT failure -- and thus that disabling exceptions will basically mean that a test failure will cause an immediate abort in the program. (I guess I can hack around that in an ugly but somewhat-reasonable way.) How hopeless is using the library with BOOST_NO_EXCEPTIONS? Evan
[Please do not mail me a copy of your followup]
boost@lists.boost.org spake the secret code
I work on a team that uses compiles with exception support disabled. (That... is not my decision, and no value judgments on that, please. :-))
I'd kind of like to use the unit test library.
Is it possible to compile your tests with exceptions enabled and simply link against your code that isn't using exceptions? Remember, you're not shipping your unit tests, so whatever has caused you to decide against exceptions for production code could be relaxed for your unit tests.
However, at a surface level it has lots of uses of raw try/catch/throw instead of BOOST_TRY/BOOST_CATCH/BOOST_THROW.
If you do things like BOOST_REQUIRE_EQUAL and the assertion fails, it does indeed use an exception to terminate the execution of the test case. Exceptions are pretty much the only mechanism you're going to find that supports this. If you do BOOST_CHECK, then it simply records the failure of the test case and continues executing. However, I find that REQUIRE is the behavior that I want all the time -- if I've identified a failed assertion, I don't see the point of continuing to execute the test, particularly when it may just crash the whole executable if I continue executing it.
How hopeless is using the library with BOOST_NO_EXCEPTIONS?
Modifying the library not to use exceptions would be a significant
amount of work, I think. There are other unit test frameworks that
provide much less and don't use exceptions.
You might also take a look at
driscoll
I work on a team that uses compiles with exception support disabled. How hopeless is using the library with BOOST_NO_EXCEPTIONS?
Not a small undertaking. It is might be theoretically be possible, but someone need to invest time into supporting this. Feel free to file feature request. Maybe we can find someone to work on this. Regards, Gennadiy
participants (3)
-
driscoll
-
Gennadiy Rozental
-
legalize+jeeves@mail.xmission.com