summaryrefslogtreecommitdiff
path: root/boost/test/impl
diff options
context:
space:
mode:
Diffstat (limited to 'boost/test/impl')
-rw-r--r--boost/test/impl/compiler_log_formatter.ipp4
-rw-r--r--boost/test/impl/execution_monitor.ipp49
-rw-r--r--boost/test/impl/framework.ipp248
-rw-r--r--boost/test/impl/test_tree.ipp3
-rw-r--r--boost/test/impl/unit_test_parameters.ipp18
5 files changed, 177 insertions, 145 deletions
diff --git a/boost/test/impl/compiler_log_formatter.ipp b/boost/test/impl/compiler_log_formatter.ipp
index c5aa6afe93..8c76788109 100644
--- a/boost/test/impl/compiler_log_formatter.ipp
+++ b/boost/test/impl/compiler_log_formatter.ipp
@@ -146,7 +146,7 @@ compiler_log_formatter::log_exception_start( std::ostream& output, log_checkpoin
print_prefix( output, loc.m_file_name, loc.m_line_num );
{
- BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::BLINK, term_color::RED );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::UNDERLINE, term_color::RED );
output << "fatal error: in \"" << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function ) << "\": "
<< ex.what();
@@ -205,7 +205,7 @@ compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data co
case BOOST_UTL_ET_FATAL_ERROR:
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
if( m_color_output )
- output << setcolor( term_attr::BLINK, term_color::RED );
+ output << setcolor( term_attr::UNDERLINE, term_color::RED );
output << "fatal error: in \"" << test_phase_identifier() << "\": ";
break;
}
diff --git a/boost/test/impl/execution_monitor.ipp b/boost/test/impl/execution_monitor.ipp
index ce6c6c7eb9..3ddcf67137 100644
--- a/boost/test/impl/execution_monitor.ipp
+++ b/boost/test/impl/execution_monitor.ipp
@@ -6,19 +6,16 @@
// See http://www.boost.org/libs/test for the library home page.
//
-// File : $RCSfile$
-//
-// Version : $Revision$
-//
-// Description : provides execution monitor implementation for all supported
-// configurations, including Microsoft structured exception based, unix signals
-// based and special workarounds for borland
-//
-// Note that when testing requirements or user wishes preclude use of this
-// file as a separate compilation unit, it may be included as a header file.
-//
-// Header dependencies are deliberately restricted to reduce coupling to other
-// boost libraries.
+/// @file
+/// Provides execution monitor implementation for all supported
+/// configurations, including Microsoft structured exception based, unix signals
+/// based and special workarounds for borland
+///
+/// Note that when testing requirements or user wishes preclude use of this
+/// file as a separate compilation unit, it may be included as a header file.
+///
+/// Header dependencies are deliberately restricted to reduce coupling to other
+/// boost libraries.
// ***************************************************************************
#ifndef BOOST_TEST_EXECUTION_MONITOR_IPP_012205GER
@@ -291,20 +288,20 @@ struct fpe_except_guard {
: m_detect_fpe( detect_fpe )
{
// prepare fp exceptions control
- m_previosly_enabled = fpe::disable( fpe::BOOST_FPE_ALL );
- if( m_previosly_enabled != fpe::BOOST_FPE_INV && detect_fpe != fpe::BOOST_FPE_OFF )
+ m_previously_enabled = fpe::disable( fpe::BOOST_FPE_ALL );
+ if( m_previously_enabled != fpe::BOOST_FPE_INV && detect_fpe != fpe::BOOST_FPE_OFF )
fpe::enable( detect_fpe );
}
~fpe_except_guard()
{
if( m_detect_fpe != fpe::BOOST_FPE_OFF )
fpe::disable( m_detect_fpe );
- if( m_previosly_enabled != fpe::BOOST_FPE_INV )
- fpe::enable( m_previosly_enabled );
+ if( m_previously_enabled != fpe::BOOST_FPE_INV )
+ fpe::enable( m_previously_enabled );
}
unsigned m_detect_fpe;
- unsigned m_previosly_enabled;
+ unsigned m_previously_enabled;
};
@@ -1360,7 +1357,7 @@ enable( unsigned mask )
#if defined(UNDER_CE)
/* Not Implemented in Windows CE */
- return 0;
+ return BOOST_FPE_OFF;
#elif defined(BOOST_SEH_BASED_SIGNAL_HANDLING)
_clearfp();
@@ -1378,13 +1375,16 @@ enable( unsigned mask )
#endif
return ~old_cw & BOOST_FPE_ALL;
-#elif defined(__GLIBC__) && defined(__USE_GNU) && !defined(BOOST_CLANG) && !defined(BOOST_NO_FENV_H)
+#elif defined(__GLIBC__) && defined(__USE_GNU)
+ if (BOOST_FPE_ALL == BOOST_FPE_OFF)
+ /* Not Implemented */
+ return BOOST_FPE_OFF;
feclearexcept(BOOST_FPE_ALL);
int res = feenableexcept( mask );
return res == -1 ? (unsigned)BOOST_FPE_INV : (unsigned)res;
#else
/* Not Implemented */
- return 0;
+ return BOOST_FPE_OFF;
#endif
}
@@ -1397,7 +1397,7 @@ disable( unsigned mask )
#if defined(UNDER_CE)
/* Not Implemented in Windows CE */
- return 0;
+ return BOOST_FPE_INV;
#elif defined(BOOST_SEH_BASED_SIGNAL_HANDLING)
_clearfp();
@@ -1415,7 +1415,10 @@ disable( unsigned mask )
#endif
return ~old_cw & BOOST_FPE_ALL;
-#elif defined(__GLIBC__) && defined(__USE_GNU) && !defined(BOOST_CLANG) && !defined(BOOST_NO_FENV_H)
+#elif defined(__GLIBC__) && defined(__USE_GNU)
+ if (BOOST_FPE_ALL == BOOST_FPE_OFF)
+ /* Not Implemented */
+ return BOOST_FPE_INV;
feclearexcept(BOOST_FPE_ALL);
int res = fedisableexcept( mask );
return res == -1 ? (unsigned)BOOST_FPE_INV : (unsigned)res;
diff --git a/boost/test/impl/framework.ipp b/boost/test/impl/framework.ipp
index a513c612e1..298dde92ea 100644
--- a/boost/test/impl/framework.ipp
+++ b/boost/test/impl/framework.ipp
@@ -844,145 +844,161 @@ setup_loggers()
BOOST_TEST_I_TRY {
-
-
#ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
- bool has_combined_logger = runtime_config::has( runtime_config::COMBINED_LOGGER )
- && !runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ).empty();
+ bool has_combined_logger = runtime_config::has( runtime_config::COMBINED_LOGGER )
+ && !runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ).empty();
#else
- bool has_combined_logger = false;
+ bool has_combined_logger = false;
#endif
- if( !has_combined_logger ) {
- unit_test_log.set_threshold_level( runtime_config::get<log_level>( runtime_config::LOG_LEVEL ) );
- const output_format format = runtime_config::get<output_format>( runtime_config::LOG_FORMAT );
- unit_test_log.set_format( format );
-
- runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
- if( runtime_config::has( runtime_config::LOG_SINK ) )
- stream_logger.setup( runtime_config::get<const_string>( runtime_config::LOG_SINK ) );
- unit_test_log.set_stream( stream_logger.ref() );
- }
- else
- {
-
- const std::vector<std::string>& v_output_format = runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ) ;
-
- static const std::pair<const char*, log_level> all_log_levels[] = {
- std::make_pair( "all" , log_successful_tests ),
- std::make_pair( "success" , log_successful_tests ),
- std::make_pair( "test_suite" , log_test_units ),
- std::make_pair( "unit_scope" , log_test_units ),
- std::make_pair( "message" , log_messages ),
- std::make_pair( "warning" , log_warnings ),
- std::make_pair( "error" , log_all_errors ),
- std::make_pair( "cpp_exception" , log_cpp_exception_errors ),
- std::make_pair( "system_error" , log_system_errors ),
- std::make_pair( "fatal_error" , log_fatal_errors ),
- std::make_pair( "nothing" , log_nothing )
- };
-
- static const std::pair<const char*, output_format> all_formats[] = {
- std::make_pair( "HRF" , OF_CLF ),
- std::make_pair( "CLF" , OF_CLF ),
- std::make_pair( "XML" , OF_XML ),
- std::make_pair( "JUNIT", OF_JUNIT )
- };
-
-
- bool is_first = true;
+ if( !has_combined_logger ) {
+ unit_test_log.set_threshold_level( runtime_config::get<log_level>( runtime_config::LOG_LEVEL ) );
+ const output_format format = runtime_config::get<output_format>( runtime_config::LOG_FORMAT );
+ unit_test_log.set_format( format );
- BOOST_TEST_FOREACH( const_string, current_multi_config, v_output_format ) {
+ runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
+ if( runtime_config::has( runtime_config::LOG_SINK ) )
+ stream_logger.setup( runtime_config::get<std::string>( runtime_config::LOG_SINK ) );
+ unit_test_log.set_stream( stream_logger.ref() );
+ }
+ else
+ {
-#ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
- utils::string_token_iterator current_config( current_multi_config, (utils::dropped_delimeters = ":",
- utils::kept_delimeters = utils::dt_none) );
+ const std::vector<std::string>& v_output_format = runtime_config::get< std::vector<std::string> >( runtime_config::COMBINED_LOGGER ) ;
+
+ static const std::pair<const char*, log_level> all_log_levels[] = {
+ std::make_pair( "all" , log_successful_tests ),
+ std::make_pair( "success" , log_successful_tests ),
+ std::make_pair( "test_suite" , log_test_units ),
+ std::make_pair( "unit_scope" , log_test_units ),
+ std::make_pair( "message" , log_messages ),
+ std::make_pair( "warning" , log_warnings ),
+ std::make_pair( "error" , log_all_errors ),
+ std::make_pair( "cpp_exception" , log_cpp_exception_errors ),
+ std::make_pair( "system_error" , log_system_errors ),
+ std::make_pair( "fatal_error" , log_fatal_errors ),
+ std::make_pair( "nothing" , log_nothing )
+ };
+
+ static const std::pair<const char*, output_format> all_formats[] = {
+ std::make_pair( "HRF" , OF_CLF ),
+ std::make_pair( "CLF" , OF_CLF ),
+ std::make_pair( "XML" , OF_XML ),
+ std::make_pair( "JUNIT", OF_JUNIT )
+ };
+
+
+ bool is_first = true;
+
+ BOOST_TEST_FOREACH( const_string, current_multi_config, v_output_format ) {
+
+ #ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
+
+ // ':' may be used for file names: C:/tmp/mylogsink.xml
+ // we merge the tokens that start with / or \ with the previous one.
+ std::vector<std::string> v_processed_tokens;
+
+ {
+ utils::string_token_iterator current_config( current_multi_config, (utils::dropped_delimeters = ":",
+ utils::kept_delimeters = utils::dt_none) );
+
+ for( ; current_config != utils::string_token_iterator() ; ++current_config) {
+ std::string str_copy(current_config->begin(), current_config->end());
+ if( ( str_copy[0] == '\\' || str_copy[0] == '/' )
+ && v_processed_tokens.size() > 0) {
+ v_processed_tokens.back() += ":" + str_copy; // ':' has been eaten up
+ }
+ else {
+ v_processed_tokens.push_back(str_copy);
+ }
+ }
+ }
- for( ; current_config != utils::string_token_iterator() ; ++current_config) {
+ BOOST_TEST_FOREACH( std::string const&, current_config, v_processed_tokens ) {
- utils::string_token_iterator current_format_specs( *current_config, (utils::keep_empty_tokens,
- utils::dropped_delimeters = ",",
- utils::kept_delimeters = utils::dt_none) );
+ utils::string_token_iterator current_format_specs( current_config, (utils::keep_empty_tokens,
+ utils::dropped_delimeters = ",",
+ utils::kept_delimeters = utils::dt_none) );
- output_format format = OF_INVALID ; // default
- if( current_format_specs != utils::string_token_iterator() &&
- current_format_specs->size() ) {
+ output_format format = OF_INVALID ; // default
+ if( current_format_specs != utils::string_token_iterator() &&
+ current_format_specs->size() ) {
- for(size_t elem=0; elem < sizeof(all_formats)/sizeof(all_formats[0]); elem++) {
- if(const_string(all_formats[elem].first) == *current_format_specs) {
- format = all_formats[elem].second;
- break;
+ for(size_t elem=0; elem < sizeof(all_formats)/sizeof(all_formats[0]); elem++) {
+ if(const_string(all_formats[elem].first) == *current_format_specs) {
+ format = all_formats[elem].second;
+ break;
+ }
}
}
- }
- BOOST_TEST_I_ASSRT( format != OF_INVALID,
- boost::runtime::access_to_missing_argument()
- << "Unable to determine the logger type from '"
- << *current_config
- << "'. Possible choices are: "
- << std::accumulate(all_formats,
- all_formats + sizeof(all_formats)/sizeof(all_formats[0]),
- std::string(""),
- sum_to_first_only())
- );
-
- // activates this format
- if( is_first ) {
- unit_test_log.set_format( format );
- }
- else {
- unit_test_log.add_format( format );
- }
- is_first = false;
+ BOOST_TEST_I_ASSRT( format != OF_INVALID,
+ boost::runtime::access_to_missing_argument()
+ << "Unable to determine the logger type from '"
+ << current_config
+ << "'. Possible choices are: "
+ << std::accumulate(all_formats,
+ all_formats + sizeof(all_formats)/sizeof(all_formats[0]),
+ std::string(""),
+ sum_to_first_only())
+ );
+
+ // activates this format
+ if( is_first ) {
+ unit_test_log.set_format( format );
+ }
+ else {
+ unit_test_log.add_format( format );
+ }
+ is_first = false;
- unit_test_log_formatter * const formatter = unit_test_log.get_formatter(format);
- BOOST_TEST_SETUP_ASSERT( formatter, "Logger setup error" );
+ unit_test_log_formatter * const formatter = unit_test_log.get_formatter(format);
+ BOOST_TEST_SETUP_ASSERT( formatter, "Logger setup error" );
- log_level formatter_log_level = invalid_log_level;
- if( !current_format_specs->size() ) {
- formatter_log_level = formatter->get_log_level(); // default log level given by the formatter
- }
- else if( ++current_format_specs != utils::string_token_iterator() ) {
+ log_level formatter_log_level = invalid_log_level;
+ ++current_format_specs ;
+ if( !current_format_specs->size() ) {
+ formatter_log_level = formatter->get_log_level(); // default log level given by the formatter
+ }
+ else if( current_format_specs != utils::string_token_iterator() ) {
- for(size_t elem=0; elem < sizeof(all_log_levels)/sizeof(all_log_levels[0]); elem++) {
- if(const_string(all_log_levels[elem].first) == *current_format_specs) {
- formatter_log_level = all_log_levels[elem].second;
- break;
+ for(size_t elem=0; elem < sizeof(all_log_levels)/sizeof(all_log_levels[0]); elem++) {
+ if(const_string(all_log_levels[elem].first) == *current_format_specs) {
+ formatter_log_level = all_log_levels[elem].second;
+ break;
+ }
}
}
- }
- BOOST_TEST_I_ASSRT( formatter_log_level != invalid_log_level,
- boost::runtime::access_to_missing_argument()
- << "Unable to determine the log level from '"
- << *current_config
- << "'. Possible choices are: "
- << std::accumulate(all_log_levels,
- all_log_levels + sizeof(all_log_levels)/sizeof(all_log_levels[0]),
- std::string(""),
- sum_to_first_only())
- );
+ BOOST_TEST_I_ASSRT( formatter_log_level != invalid_log_level,
+ boost::runtime::access_to_missing_argument()
+ << "Unable to determine the log level from '"
+ << current_config
+ << "'. Possible choices are: "
+ << std::accumulate(all_log_levels,
+ all_log_levels + sizeof(all_log_levels)/sizeof(all_log_levels[0]),
+ std::string(""),
+ sum_to_first_only())
+ );
- unit_test_log.set_threshold_level( format, formatter_log_level );
+ unit_test_log.set_threshold_level( format, formatter_log_level );
- runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
- if( ++current_format_specs != utils::string_token_iterator() &&
- current_format_specs->size() ) {
- stream_logger.setup( *current_format_specs );
- }
- else {
- stream_logger.setup( formatter->get_default_stream_description() );
+ runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
+ if( ++current_format_specs != utils::string_token_iterator() &&
+ current_format_specs->size() ) {
+ stream_logger.setup( *current_format_specs );
+ }
+ else {
+ stream_logger.setup( formatter->get_default_stream_description() );
+ }
+ unit_test_log.set_stream( format, stream_logger.ref() );
}
- unit_test_log.set_stream( format, stream_logger.ref() );
-
- }
-#endif
- }
+ #endif
+ } // for each logger
- }
- }
+ } // if/else new logger API
+ } // BOOST_TEST_I_TRY
BOOST_TEST_I_CATCH( boost::runtime::init_error, ex ) {
BOOST_TEST_SETUP_ASSERT( false, ex.msg );
}
@@ -1021,7 +1037,7 @@ init( init_unit_test_func init_func, int argc, char* argv[] )
results_reporter::set_format( runtime_config::get<output_format>( runtime_config::REPORT_FORMAT ) );
if( runtime_config::has( runtime_config::REPORT_SINK ) )
- s_frk_state().m_report_sink.setup( runtime_config::get<const_string>( runtime_config::REPORT_SINK ) );
+ s_frk_state().m_report_sink.setup( runtime_config::get<std::string>( runtime_config::REPORT_SINK ) );
results_reporter::set_stream( s_frk_state().m_report_sink.ref() );
// 40. Register default test observers
diff --git a/boost/test/impl/test_tree.ipp b/boost/test/impl/test_tree.ipp
index d45f7b32b5..08bdad3360 100644
--- a/boost/test/impl/test_tree.ipp
+++ b/boost/test/impl/test_tree.ipp
@@ -381,7 +381,8 @@ normalize_test_case_name( const_string name )
if( name[0] == '&' )
norm_name = norm_name.substr( 1 );
- std::replace(norm_name.begin(), norm_name.end(), ' ', '_');
+ std::replace(norm_name.begin(), norm_name.end(), ' ', '_');
+ std::replace(norm_name.begin(), norm_name.end(), ':', '_');
return norm_name;
}
diff --git a/boost/test/impl/unit_test_parameters.ipp b/boost/test/impl/unit_test_parameters.ipp
index f49079ea3e..315942e6c0 100644
--- a/boost/test/impl/unit_test_parameters.ipp
+++ b/boost/test/impl/unit_test_parameters.ipp
@@ -99,6 +99,7 @@ std::string WAIT_FOR_DEBUGGER = "wait_for_debugger";
std::string HELP = "help";
std::string USAGE = "usage";
+std::string VERSION = "version";
//____________________________________________________________________________//
@@ -148,12 +149,11 @@ register_parameters( rt::parameters_store& store )
"compiler, STL version and Boost version."
));
- ///////////////////////////////////////////////
-
build_info.add_cla_id( "--", BUILD_INFO, "=" );
build_info.add_cla_id( "-", "i", " " );
store.add( build_info );
+ ///////////////////////////////////////////////
rt::option catch_sys_errors( CATCH_SYS_ERRORS, (
rt::description = "Allows to switch between catching and ignoring system errors (signals).",
@@ -635,6 +635,14 @@ register_parameters( rt::parameters_store& store )
));
usage.add_cla_id( "-", "?", " " );
store.add( usage );
+
+ ///////////////////////////////////////////////
+
+ rt::option version( VERSION, (
+ rt::description = "Prints Boost.Test version and exits."
+ ));
+ version.add_cla_id( "--", VERSION, " " );
+ store.add( version );
}
static rt::arguments_store s_arguments_store;
@@ -668,7 +676,11 @@ init( int& argc, char** argv )
rt::finalize_arguments( s_parameters_store, s_arguments_store );
// Report help if requested
- if( runtime_config::get<bool>( USAGE ) ) {
+ if( runtime_config::get<bool>( VERSION ) ) {
+ parser->version( std::cerr );
+ BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
+ }
+ else if( runtime_config::get<bool>( USAGE ) ) {
parser->usage( std::cerr );
BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
}