From fc2083eca2dcf8446dfda3e488cb92cb728e424a Mon Sep 17 00:00:00 2001 From: Gennadiy Rozental Date: Wed, 8 Jul 2015 00:49:31 -0400 Subject: [PATCH] Support for build with no exceptions --- include/boost/test/data/config.hpp | 3 +- include/boost/test/execution_monitor.hpp | 11 +++- include/boost/test/framework.hpp | 8 ++- include/boost/test/impl/cpp_main.ipp | 6 +- include/boost/test/impl/decorator.ipp | 9 ++- include/boost/test/impl/execution_monitor.ipp | 45 ++++++++++---- include/boost/test/impl/framework.ipp | 28 +++++---- include/boost/test/impl/progress_monitor.ipp | 59 ++++++++++++++++++- include/boost/test/impl/test_tools.ipp | 7 ++- include/boost/test/impl/test_tree.ipp | 3 +- include/boost/test/impl/unit_test_main.ipp | 10 ++-- include/boost/test/impl/unit_test_monitor.ipp | 4 +- .../boost/test/impl/unit_test_parameters.ipp | 15 ++--- include/boost/test/tools/assertion.hpp | 1 - include/boost/test/utils/named_params.hpp | 4 +- .../utils/runtime/cla/argument_factory.hpp | 6 +- .../boost/test/utils/runtime/cla/parser.ipp | 6 +- .../test/utils/runtime/cla/validation.ipp | 7 +-- .../test/utils/runtime/env/environment.hpp | 4 +- .../boost/test/utils/runtime/validation.hpp | 3 +- test/Jamfile.v2 | 5 ++ 21 files changed, 173 insertions(+), 71 deletions(-) diff --git a/include/boost/test/data/config.hpp b/include/boost/test/data/config.hpp index 4eccbe29..bedfae5d 100644 --- a/include/boost/test/data/config.hpp +++ b/include/boost/test/data/config.hpp @@ -14,6 +14,7 @@ // Boost.Test #include +#include // STL #include // for std::logic_error @@ -40,7 +41,7 @@ //____________________________________________________________________________// -#define BOOST_TEST_DS_ERROR( msg ) throw std::logic_error( msg ) +#define BOOST_TEST_DS_ERROR( msg ) BOOST_TEST_IMPL_THROW( std::logic_error( msg ) ) #define BOOST_TEST_DS_ASSERT( cond, msg ) if( cond ) {} else BOOST_TEST_DS_ERROR( msg ) #endif // BOOST_TEST_DATA_CONFIG_HPP_112611GER diff --git a/include/boost/test/execution_monitor.hpp b/include/boost/test/execution_monitor.hpp index 45867553..b01137da 100644 --- a/include/boost/test/execution_monitor.hpp +++ b/include/boost/test/execution_monitor.hpp @@ -16,6 +16,8 @@ // Boost.Test #include #include +#include + #include // Boost @@ -413,9 +415,10 @@ public: // translator holder interface virtual int operator()( boost::function const& F ) { - try { + BOOST_TEST_IMPL_TRY { return m_next ? (*m_next)( F ) : F(); - } catch( ExceptionType const& e ) { + } + BOOST_TEST_IMPL_CATCH( ExceptionType, e ) { m_translator( e ); return boost::exit_exception_failure; } @@ -462,7 +465,9 @@ public: unit_test::readonly_property p_failed_exp; }; -#define BOOST_TEST_SYS_ASSERT( exp ) if( (exp) ) ; else throw ::boost::system_error( BOOST_STRINGIZE( exp ) ) +#define BOOST_TEST_SYS_ASSERT( exp ) \ + if( (exp) ) ; \ + else BOOST_TEST_IMPL_THROW( ::boost::system_error( BOOST_STRINGIZE( exp ) ) ) // ************************************************************************** // // **************Floating point exception management interface ************** // diff --git a/include/boost/test/framework.hpp b/include/boost/test/framework.hpp index 3c57e656..82e3fc66 100644 --- a/include/boost/test/framework.hpp +++ b/include/boost/test/framework.hpp @@ -16,6 +16,8 @@ // Boost.Test #include #include +#include + #include #include @@ -61,7 +63,7 @@ namespace framework { /// @param[in] argv command line arguments collection BOOST_TEST_DECL void init( init_unit_test_func init_func, int argc, char* argv[] ); -/// This function applies all the decorators and figures out default run status. This argument facilitates an +/// This function applies all the decorators and figures out default run status. This argument facilitates an /// ability of the test cases to prepare some other test units (primarily used internally for self testing) /// @param[in] tu Optional id of the test unit representing root of test tree. If absent, master test suite is used BOOST_TEST_DECL void finalize_setup_phase( test_unit_id tu = INV_TEST_UNIT_ID); @@ -252,7 +254,9 @@ struct BOOST_TEST_DECL setup_error : public std::runtime_error { setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {} }; -#define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg ) +#define BOOST_TEST_SETUP_ASSERT( cond, msg ) \ + if( cond ) {} \ + else BOOST_TEST_IMPL_THROW( unit_test::framework::setup_error( msg ) ) //____________________________________________________________________________// diff --git a/include/boost/test/impl/cpp_main.ipp b/include/boost/test/impl/cpp_main.ipp index 8fef6f7f..5cab0f42 100644 --- a/include/boost/test/impl/cpp_main.ipp +++ b/include/boost/test/impl/cpp_main.ipp @@ -68,7 +68,7 @@ prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char { int result = 0; - try { + BOOST_TEST_IMPL_TRY { boost::unit_test::const_string p( std::getenv( "BOOST_TEST_CATCH_SYSTEM_ERRORS" ) ); ::boost::execution_monitor ex_mon; @@ -83,11 +83,11 @@ prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char result = ::boost::exit_failure; } } - catch( ::boost::execution_exception const& exex ) { + BOOST_TEST_IMPL_CATCH( ::boost::execution_exception, exex ) { std::cout << "\n**** exception(" << exex.code() << "): " << exex.what() << std::endl; result = ::boost::exit_exception_failure; } - catch( ::boost::system_error const& ex ) { + BOOST_TEST_IMPL_CATCH( ::boost::system_error, ex ) { std::cout << "\n**** failed to initialize execution monitor." << "\n**** expression at fault: " << ex.p_failed_exp << "\n**** error(" << ex.p_errno << "): " << std::strerror( ex.p_errno ) << std::endl; diff --git a/include/boost/test/impl/decorator.ipp b/include/boost/test/impl/decorator.ipp index 864f2c3b..bf179078 100644 --- a/include/boost/test/impl/decorator.ipp +++ b/include/boost/test/impl/decorator.ipp @@ -23,6 +23,9 @@ #if BOOST_TEST_SUPPORT_TOKEN_ITERATOR #include #endif + +#include + #include //____________________________________________________________________________// @@ -127,7 +130,7 @@ void depends_on::apply( test_unit& tu ) { #if !BOOST_TEST_SUPPORT_TOKEN_ITERATOR - throw setup_error( "depends_on decorator is not supported on this platform" ); + BOOST_TEST_SETUP_ASSERT( false, "depends_on decorator is not supported on this platform" ); #else string_token_iterator tit( m_dependency, (dropped_delimeters = "/", kept_delimeters = dt_none) ); @@ -137,8 +140,8 @@ depends_on::apply( test_unit& tu ) test_unit_id next_id = static_cast(dep)->get( *tit ); - if( next_id == INV_TEST_UNIT_ID ) - throw framework::setup_error( std::string( "incorrect dependency specification " ) + m_dependency ); + BOOST_TEST_SETUP_ASSERT( next_id != INV_TEST_UNIT_ID, + std::string( "incorrect dependency specification " ) + m_dependency ); dep = &framework::get( next_id, TUT_ANY ); ++tit; diff --git a/include/boost/test/impl/execution_monitor.ipp b/include/boost/test/impl/execution_monitor.ipp index 57bb8268..9929f74b 100644 --- a/include/boost/test/impl/execution_monitor.ipp +++ b/include/boost/test/impl/execution_monitor.ipp @@ -27,6 +27,7 @@ // Boost.Test #include #include +#include #include #include @@ -34,8 +35,10 @@ #include // for exit codes #include // for workarounds #include // for ignore_unused +#ifndef BOOST_NO_EXCEPTION #include // for get_error_info #include // for current_exception_cast +#endif // STL #include // for std::string @@ -189,6 +192,14 @@ namespace { void _set_se_translator( void* ) {} } namespace boost { +// ************************************************************************** // +// ************** throw_exception ************** // +// ************************************************************************** // + +#ifdef BOOST_NO_EXCEPTION +void throw_exception( std::exception const & e ) { abort(); } +#endif + // ************************************************************************** // // ************** report_error ************** // // ************************************************************************** // @@ -205,6 +216,8 @@ namespace detail { # define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) vsnprintf( (a1), (a2), (a3), (a4) ) #endif +#ifndef BOOST_NO_EXCEPTION + template typename ErrorInfo::value_type extract( boost::exception const* ex ) @@ -237,17 +250,6 @@ report_error( execution_exception::error_code ec, boost::exception const* be, ch //____________________________________________________________________________// -static void -report_error( execution_exception::error_code ec, char const* format, ... ) -{ - va_list args; - va_start( args, format ); - - report_error( ec, 0, format, &args ); -} - -//____________________________________________________________________________// - static void report_error( execution_exception::error_code ec, boost::exception const* be, char const* format, ... ) { @@ -257,6 +259,19 @@ report_error( execution_exception::error_code ec, boost::exception const* be, ch report_error( ec, be, format, &args ); } +#endif + +//____________________________________________________________________________// + +static void +report_error( execution_exception::error_code ec, char const* format, ... ) +{ + va_list args; + va_start( args, format ); + + report_error( ec, 0, format, &args ); +} + //____________________________________________________________________________// template @@ -854,7 +869,7 @@ execution_monitor::catch_signals( boost::function const& F ) if( !sigsetjmp( signal_handler::jump_buffer(), 1 ) ) return detail::do_invoke( m_custom_translators , F ); else - throw local_signal_handler.sys_sig(); + return BOOST_TEST_IMPL_THROW( local_signal_handler.sys_sig() ); } //____________________________________________________________________________// @@ -1185,13 +1200,15 @@ execution_monitor::execute( boost::function const& F ) if( debug::under_debugger() ) p_catch_system_errors.value = false; - try { + BOOST_TEST_IMPL_TRY { detail::fpe_except_guard G( p_detect_fp_exceptions ); unit_test::ut_detail::ignore_unused_variable_warning( G ); return catch_signals( F ); } +#ifndef BOOST_NO_EXCEPTION + // Catch-clause reference arguments are a bit different from function // arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't // required. Programmers ask for const anyhow, so we supply it. That's @@ -1272,6 +1289,8 @@ execution_monitor::execute( boost::function const& F ) catch( ... ) { detail::report_error( execution_exception::cpp_exception_error, "unknown type" ); } +#endif // !BOOST_NO_EXCEPTION + return 0; // never reached; supplied to quiet compiler warnings } // execute diff --git a/include/boost/test/impl/framework.ipp b/include/boost/test/impl/framework.ipp index f51424e1..a69d95cd 100644 --- a/include/boost/test/impl/framework.ipp +++ b/include/boost/test/impl/framework.ipp @@ -19,6 +19,8 @@ #include #include #include +#include + #include #include #include @@ -35,12 +37,12 @@ #include #endif -#include -#include - #include #include +#include +#include + // Boost #include #include @@ -140,8 +142,8 @@ assign_sibling_rank( test_unit_id tu_id, order_info_per_tu& tuoi ) { test_unit& tu = framework::get( tu_id, TUT_ANY ); - if( tu.p_sibling_rank == (std::numeric_limits::max)() ) - throw framework::setup_error( "Cyclic dependency detected involving test unit \"" + tu.full_name() + "\""); + BOOST_TEST_SETUP_ASSERT( tu.p_sibling_rank != (std::numeric_limits::max)(), + "Cyclic dependency detected involving test unit \"" + tu.full_name() + "\"" ); if( tu.p_sibling_rank != 0 ) return tu.p_sibling_rank; @@ -169,7 +171,7 @@ invoke_init_func( init_unit_test_func init_func ) { #ifdef BOOST_TEST_ALTERNATIVE_INIT_API if( !(*init_func)() ) - throw std::runtime_error( "test module initialization failed" ); + BOOST_TEST_IMPL_THROW( std::runtime_error( "test module initialization failed" ) ); #else test_suite* manual_test_units = (*init_func)( framework::master_test_suite().argc, framework::master_test_suite().argv ); @@ -831,11 +833,11 @@ init( init_unit_test_func init_func, int argc, char* argv[] ) using namespace impl; // 70. Invoke test module initialization routine - try { + BOOST_TEST_IMPL_TRY { s_frk_state().m_aux_em.vexecute( boost::bind( &impl::invoke_init_func, init_func ) ); } - catch( execution_exception const& ex ) { - throw setup_error( ex.what() ); + BOOST_TEST_IMPL_CATCH( execution_exception, ex ) { + BOOST_TEST_SETUP_ASSERT( false, ex.what() ); } } @@ -1156,7 +1158,7 @@ get( test_unit_id id, test_unit_type t ) test_unit* res = impl::s_frk_state().m_test_units[id]; if( (res->p_type & t) == 0 ) - throw internal_error( "Invalid test unit type" ); + BOOST_TEST_IMPL_THROW( internal_error( "Invalid test unit type" ) ); return *res; } @@ -1190,11 +1192,11 @@ run( test_unit_id id, bool continue_test ) if( call_start_finish ) { BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers ) { - try { + BOOST_TEST_IMPL_TRY { impl::s_frk_state().m_aux_em.vexecute( boost::bind( &test_observer::test_start, to, tcc.p_count ) ); } - catch( execution_exception const& ex ) { - throw setup_error( ex.what() ); + BOOST_TEST_IMPL_CATCH( execution_exception, ex ) { + BOOST_TEST_SETUP_ASSERT( false, ex.what() ); } } } diff --git a/include/boost/test/impl/progress_monitor.ipp b/include/boost/test/impl/progress_monitor.ipp index 6ff5f91a..ebdd7e93 100644 --- a/include/boost/test/impl/progress_monitor.ipp +++ b/include/boost/test/impl/progress_monitor.ipp @@ -26,7 +26,6 @@ #include // Boost -#include #include #include @@ -40,6 +39,64 @@ namespace unit_test { // ************** progress_monitor ************** // // ************************************************************************** // +struct progress_display { + progress_display( counter_t expected_count, std::ostream& os ) + : m_os(os) + , m_count( 0 ) + , m_expected_count( expected_count ) + , m_next_tic_count( 0 ) + , m_tic( 0 ) + { + + m_os << "\n0% 10 20 30 40 50 60 70 80 90 100%" + << "\n|----|----|----|----|----|----|----|----|----|----|" + << std::endl; + + if( !m_expected_count ) + m_expected_count = 1; // prevent divide by zero + } + + unsigned long operator+=( unsigned long increment ) + { + if( (m_count += increment) < m_next_tic_count ) + return m_count; + + // use of floating point ensures that both large and small counts + // work correctly. static_cast<>() is also used several places + // to suppress spurious compiler warnings. + unsigned int tics_needed = static_cast( + (static_cast(m_count)/m_expected_count)*50.0 ); + + do { + m_os << '*' << std::flush; + } while( ++m_tic < tics_needed ); + + m_next_tic_count = static_cast((m_tic/50.0) * m_expected_count); + + if( m_count == m_expected_count ) { + if( m_tic < 51 ) + m_os << '*'; + + m_os << std::endl; + } + + return m_count; + } + unsigned long operator++() { return operator+=( 1 ); } + unsigned long count() const { return m_count; } + +private: + BOOST_DELETED_FUNCTION(progress_display(progress_display const&)) + BOOST_DELETED_FUNCTION(progress_display& operator=(progress_display const&)) + + std::ostream& m_os; // may not be present in all imps + + unsigned long m_count; + unsigned long m_expected_count; + unsigned long m_next_tic_count; + unsigned int m_tic; +}; + namespace { struct progress_monitor_impl { diff --git a/include/boost/test/impl/test_tools.ipp b/include/boost/test/impl/test_tools.ipp index f0ed0f2c..03fea916 100644 --- a/include/boost/test/impl/test_tools.ipp +++ b/include/boost/test/impl/test_tools.ipp @@ -27,6 +27,8 @@ #include #include // execution_aborted +#include + // Boost #include @@ -293,7 +295,8 @@ report_assertion( assertion_result const& ar, using namespace unit_test; if( framework::current_test_case_id() == INV_TEST_UNIT_ID ) - throw std::runtime_error( "can't use testing tools outside of test case implementation" ); + BOOST_TEST_IMPL_THROW( + std::runtime_error( "can't use testing tools outside of test case implementation" ) ); if( !!ar ) tl = PASS; @@ -354,7 +357,7 @@ report_assertion( assertion_result const& ar, framework::test_unit_aborted( framework::current_test_case() ); - throw execution_aborted(); + BOOST_TEST_IMPL_THROW( execution_aborted() ); } return true; diff --git a/include/boost/test/impl/test_tree.ipp b/include/boost/test/impl/test_tree.ipp index 1bfaeea8..712cb9ee 100644 --- a/include/boost/test/impl/test_tree.ipp +++ b/include/boost/test/impl/test_tree.ipp @@ -97,7 +97,8 @@ test_unit::~test_unit() void test_unit::depends_on( test_unit* tu ) { - BOOST_TEST_SETUP_ASSERT( p_id != framework::master_test_suite().p_id, "Can't add dependency to the master test suite" ); + BOOST_TEST_SETUP_ASSERT( p_id != framework::master_test_suite().p_id, + "Can't add dependency to the master test suite" ); p_dependencies.value.push_back( tu->p_id ); } diff --git a/include/boost/test/impl/unit_test_main.ipp b/include/boost/test/impl/unit_test_main.ipp index e28e2ee2..327e14de 100644 --- a/include/boost/test/impl/unit_test_main.ipp +++ b/include/boost/test/impl/unit_test_main.ipp @@ -185,7 +185,7 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ) { int result_code = 0; - try { + BOOST_TEST_IMPL_TRY { framework::init( init_func, argc, argv ); if( runtime_config::wait_for_debugger() ) { @@ -233,20 +233,20 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ) ? boost::exit_success : results_collector.results( framework::master_test_suite().p_id ).result_code(); } - catch( framework::nothing_to_test const& ) { + BOOST_TEST_IMPL_CATCH0( framework::nothing_to_test ) { result_code = boost::exit_success; } - catch( framework::internal_error const& ex ) { + BOOST_TEST_IMPL_CATCH( framework::internal_error, ex ) { results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl; result_code = boost::exit_exception_failure; } - catch( framework::setup_error const& ex ) { + BOOST_TEST_IMPL_CATCH( framework::setup_error, ex ) { results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl; result_code = boost::exit_exception_failure; } - catch( ... ) { + BOOST_TEST_IMPL_CATCHALL() { results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl; result_code = boost::exit_exception_failure; diff --git a/include/boost/test/impl/unit_test_monitor.ipp b/include/boost/test/impl/unit_test_monitor.ipp index 80182fa6..8c931f20 100644 --- a/include/boost/test/impl/unit_test_monitor.ipp +++ b/include/boost/test/impl/unit_test_monitor.ipp @@ -36,7 +36,7 @@ namespace unit_test { unit_test_monitor_t::error_level unit_test_monitor_t::execute_and_translate( boost::function const& func, unsigned timeout ) { - try { + BOOST_TEST_IMPL_TRY { p_catch_system_errors.value = runtime_config::catch_sys_errors(); p_timeout.value = timeout; p_auto_start_dbg.value = runtime_config::auto_start_dbg(); @@ -45,7 +45,7 @@ unit_test_monitor_t::execute_and_translate( boost::function const& func vexecute( func ); } - catch( execution_exception const& ex ) { + BOOST_TEST_IMPL_CATCH( execution_exception, ex ) { framework::exception_caught( ex ); framework::test_unit_aborted( framework::current_test_case() ); diff --git a/include/boost/test/impl/unit_test_parameters.ipp b/include/boost/test/impl/unit_test_parameters.ipp index 84b8adf2..2ffa495e 100644 --- a/include/boost/test/impl/unit_test_parameters.ipp +++ b/include/boost/test/impl/unit_test_parameters.ipp @@ -19,7 +19,6 @@ #define BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER // Boost.Test - #include #include #include @@ -28,6 +27,8 @@ #include #include +#include + // Boost.Runtime.Param #include #include @@ -273,7 +274,7 @@ init( int& argc, char** argv ) { using namespace cla; - try { + BOOST_TEST_IMPL_TRY { if( s_cla_parser.num_params() != 0 ) s_cla_parser.reset(); else @@ -359,7 +360,7 @@ init( int& argc, char** argv ) if( s_cla_parser["help"] ) { s_cla_parser.help( std::cout ); - throw framework::nothing_to_test(); + BOOST_TEST_IMPL_THROW( framework::nothing_to_test() ); } s_report_format = retrieve_parameter( REPORT_FORMAT, s_cla_parser, unit_test::OF_CLF ); @@ -372,13 +373,13 @@ init( int& argc, char** argv ) s_test_to_run = retrieve_parameter >( TESTS_TO_RUN, s_cla_parser ); } - catch( rt::logic_error const& ex ) { + BOOST_TEST_IMPL_CATCH( rt::logic_error, ex ) { std::ostringstream err; err << "Fail to process runtime parameters: " << ex.msg() << std::endl; s_cla_parser.usage( err ); - throw framework::setup_error( err.str() ); + BOOST_TEST_SETUP_ASSERT( false, err.str() ); } } @@ -586,11 +587,11 @@ detect_memory_leaks() if( runtime::interpret_argument_value_impl::_( value, bool_val ) ) s_value = *bool_val ? 1L : 0L; else { - try { + BOOST_TEST_IMPL_TRY { // if representable as long - this is leak number s_value = boost::lexical_cast( value ); } - catch( boost::bad_lexical_cast const& ) { + BOOST_TEST_IMPL_CATCH0( boost::bad_lexical_cast ) { // value is leak report file and detection is enabled s_value = 1L; } diff --git a/include/boost/test/tools/assertion.hpp b/include/boost/test/tools/assertion.hpp index 28e38fa4..b46b6760 100644 --- a/include/boost/test/tools/assertion.hpp +++ b/include/boost/test/tools/assertion.hpp @@ -405,4 +405,3 @@ public: #include #endif // BOOST_TEST_TOOLS_ASSERTION_HPP_100911GER - diff --git a/include/boost/test/utils/named_params.hpp b/include/boost/test/utils/named_params.hpp index bcdaff59..0e66dc39 100644 --- a/include/boost/test/utils/named_params.hpp +++ b/include/boost/test/utils/named_params.hpp @@ -27,6 +27,8 @@ #include #include +#include + #include //____________________________________________________________________________// @@ -57,7 +59,7 @@ inline void report_access_to_invalid_parameter(bool v) { if(v) - throw access_to_invalid_parameter(); + BOOST_TEST_IMPL_THROW( access_to_invalid_parameter() ); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/cla/argument_factory.hpp b/include/boost/test/utils/runtime/cla/argument_factory.hpp index e6983996..66835406 100644 --- a/include/boost/test/utils/runtime/cla/argument_factory.hpp +++ b/include/boost/test/utils/runtime/cla/argument_factory.hpp @@ -123,14 +123,14 @@ typed_argument_factory::produce_using( parameter& p, argv_traverser& tr ) { boost::optional value; - try { + BOOST_TEST_IMPL_TRY { m_value_interpreter( tr, value ); } - catch( ... ) { // !! should we do that? + BOOST_TEST_IMPL_CATCHALL() { // !! should we do that? BOOST_TEST_UTILS_RUNTIME_PARAM_TRACE( "Fail to parse argument value" ); if( !p.p_optional_value ) - throw; + BOOST_TEST_IMPL_RETHROW; } argument_ptr actual_arg = p.actual_argument(); diff --git a/include/boost/test/utils/runtime/cla/parser.ipp b/include/boost/test/utils/runtime/cla/parser.ipp index d2427012..b8a4ca46 100644 --- a/include/boost/test/utils/runtime/cla/parser.ipp +++ b/include/boost/test/utils/runtime/cla/parser.ipp @@ -108,7 +108,7 @@ parser::parse( int& argc, char_type** argv ) m_traverser.init( argc, argv ); - try { + BOOST_TEST_IMPL_TRY { while( !m_traverser.eoi() ) { parameter_ptr found_param; @@ -151,10 +151,10 @@ parser::parse( int& argc, char_type** argv ) } } } - catch( bad_lexical_cast const& ) { + BOOST_TEST_IMPL_CATCH0( bad_lexical_cast ) { BOOST_TEST_UTILS_RUNTIME_PARAM_REPORT_LOGIC_ERROR( BOOST_TEST_UTILS_RUNTIME_PARAM_LITERAL( "String to value convertion error during input parsing" ) ); - } + }; m_traverser.remainder( argc, argv ); } diff --git a/include/boost/test/utils/runtime/cla/validation.ipp b/include/boost/test/utils/runtime/cla/validation.ipp index 9cd375ae..9d8cd27b 100644 --- a/include/boost/test/utils/runtime/cla/validation.ipp +++ b/include/boost/test/utils/runtime/cla/validation.ipp @@ -19,10 +19,9 @@ #include #include // BOOST_TEST_UTILS_RUNTIME_PARAM_NAMESPACE::logic_error -// Boost +// Boost.Test #include - -// STL +#include namespace boost { @@ -48,7 +47,7 @@ report_input_error( argv_traverser const& tr, format_stream& msg ) msg << tr.input(); } - throw BOOST_TEST_UTILS_RUNTIME_PARAM_NAMESPACE::logic_error( msg.str() ); + BOOST_TEST_IMPL_THROW( BOOST_TEST_UTILS_RUNTIME_PARAM_NAMESPACE::logic_error( msg.str() ) ); } //____________________________________________________________________________// diff --git a/include/boost/test/utils/runtime/env/environment.hpp b/include/boost/test/utils/runtime/env/environment.hpp index fff70bf8..62b2ae6d 100644 --- a/include/boost/test/utils/runtime/env/environment.hpp +++ b/include/boost/test/utils/runtime/env/environment.hpp @@ -53,7 +53,7 @@ init_new_var( cstring var_name, Modifiers m = nfp::no_params ) cstring str_value = sys_read_var( new_vd.m_var_name ); if( !str_value.is_empty() ) { - try { + BOOST_TEST_IMPL_TRY { boost::optional value; if( m.has( interpreter ) ) @@ -67,7 +67,7 @@ init_new_var( cstring var_name, Modifiers m = nfp::no_params ) arg_value( *new_vd.m_value ) = *value; } } - catch( ... ) { // !! could we do that + BOOST_TEST_IMPL_CATCHALL() { // !! could we do that // !! should we report an error? } } diff --git a/include/boost/test/utils/runtime/validation.hpp b/include/boost/test/utils/runtime/validation.hpp index aa05858e..54163dc6 100644 --- a/include/boost/test/utils/runtime/validation.hpp +++ b/include/boost/test/utils/runtime/validation.hpp @@ -20,6 +20,7 @@ // Boost.Test #include +#include // Boost #include @@ -64,7 +65,7 @@ private: inline void report_logic_error( format_stream& msg ) { - throw BOOST_TEST_UTILS_RUNTIME_PARAM_NAMESPACE::logic_error( msg.str() ); + BOOST_TEST_IMPL_THROW( BOOST_TEST_UTILS_RUNTIME_PARAM_NAMESPACE::logic_error( msg.str() ) ); } //____________________________________________________________________________// diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d763977d..d688b3c2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -33,6 +33,11 @@ rule boost.test-self-test ( test-rule : test-suite : test-name : usage-variant ? clang:-std=c++11 # clang:-Wconversion # clang:-Wno-sign-conversion +# gcc:-E +# gcc:-fno-exceptions +# gcc:-DBOOST_NO_EXCEPTION +# clang:-fno-exceptions +# clang:-DBOOST_NO_EXCEPTION all $(extra-options) : $(test-name)