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.ipp41
-rw-r--r--boost/test/impl/cpp_main.ipp8
-rw-r--r--boost/test/impl/debug.ipp6
-rw-r--r--boost/test/impl/decorator.ipp6
-rw-r--r--boost/test/impl/execution_monitor.ipp16
-rw-r--r--boost/test/impl/framework.ipp98
-rw-r--r--boost/test/impl/plain_report_formatter.ipp14
-rw-r--r--boost/test/impl/progress_monitor.ipp30
-rw-r--r--boost/test/impl/results_collector.ipp2
-rw-r--r--boost/test/impl/results_reporter.ipp31
-rw-r--r--boost/test/impl/test_main.ipp2
-rw-r--r--boost/test/impl/test_tools.ipp9
-rw-r--r--boost/test/impl/test_tree.ipp15
-rw-r--r--boost/test/impl/unit_test_log.ipp16
-rw-r--r--boost/test/impl/unit_test_main.ipp27
-rw-r--r--boost/test/impl/unit_test_monitor.ipp14
-rw-r--r--boost/test/impl/unit_test_parameters.ipp1085
-rw-r--r--boost/test/impl/xml_log_formatter.ipp45
-rw-r--r--boost/test/impl/xml_report_formatter.ipp25
19 files changed, 804 insertions, 686 deletions
diff --git a/boost/test/impl/compiler_log_formatter.ipp b/boost/test/impl/compiler_log_formatter.ipp
index c1ed944ab1..c5aa6afe93 100644
--- a/boost/test/impl/compiler_log_formatter.ipp
+++ b/boost/test/impl/compiler_log_formatter.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -16,14 +16,18 @@
#define BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
// Boost.Test
+#include <boost/test/output/compiler_log_formatter.hpp>
+
#include <boost/test/framework.hpp>
#include <boost/test/execution_monitor.hpp>
+#include <boost/test/unit_test_parameters.hpp>
+
#include <boost/test/tree/test_unit.hpp>
+
#include <boost/test/utils/basic_cstring/io.hpp>
#include <boost/test/utils/lazy_ostream.hpp>
#include <boost/test/utils/setcolor.hpp>
-#include <boost/test/output/compiler_log_formatter.hpp>
-#include <boost/test/unit_test_parameters.hpp>
+
// Boost
#include <boost/version.hpp>
@@ -58,6 +62,8 @@ test_phase_identifier()
void
compiler_log_formatter::log_start( std::ostream& output, counter_t test_cases_amount )
{
+ m_color_output = runtime_config::get<bool>( runtime_config::COLOR_OUTPUT );
+
if( test_cases_amount > 0 )
output << "Running " << test_cases_amount << " test "
<< (test_cases_amount > 1 ? "cases" : "case") << "...\n";
@@ -89,7 +95,7 @@ compiler_log_formatter::log_build_info( std::ostream& output )
void
compiler_log_formatter::test_unit_start( std::ostream& output, test_unit const& tu )
{
- BOOST_TEST_SCOPE_SETCOLOR( output, term_attr::BRIGHT, term_color::BLUE );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::BRIGHT, term_color::BLUE );
print_prefix( output, tu.p_file_name, tu.p_line_num );
@@ -101,7 +107,7 @@ compiler_log_formatter::test_unit_start( std::ostream& output, test_unit const&
void
compiler_log_formatter::test_unit_finish( std::ostream& output, test_unit const& tu, unsigned long elapsed )
{
- BOOST_TEST_SCOPE_SETCOLOR( output, term_attr::BRIGHT, term_color::BLUE );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::BRIGHT, term_color::BLUE );
print_prefix( output, tu.p_file_name, tu.p_line_num );
@@ -123,7 +129,7 @@ compiler_log_formatter::test_unit_finish( std::ostream& output, test_unit const&
void
compiler_log_formatter::test_unit_skipped( std::ostream& output, test_unit const& tu, const_string reason )
{
- BOOST_TEST_SCOPE_SETCOLOR( output, term_attr::BRIGHT, term_color::YELLOW );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::BRIGHT, term_color::YELLOW );
print_prefix( output, tu.p_file_name, tu.p_line_num );
@@ -140,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( output, term_attr::BLINK, term_color::RED );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::BLINK, term_color::RED );
output << "fatal error: in \"" << (loc.m_function.is_empty() ? test_phase_identifier() : loc.m_function ) << "\": "
<< ex.what();
@@ -150,7 +156,7 @@ compiler_log_formatter::log_exception_start( std::ostream& output, log_checkpoin
output << '\n';
print_prefix( output, checkpoint_data.m_file_name, checkpoint_data.m_line_num );
- BOOST_TEST_SCOPE_SETCOLOR( output, term_attr::BRIGHT, term_color::CYAN );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, output, term_attr::BRIGHT, term_color::CYAN );
output << "last checkpoint";
if( !checkpoint_data.m_message.empty() )
@@ -171,32 +177,34 @@ compiler_log_formatter::log_exception_finish( std::ostream& output )
void
compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data const& entry_data, log_entry_types let )
{
+ using namespace utils;
+
switch( let ) {
case BOOST_UTL_ET_INFO:
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
- if( runtime_config::color_output() )
+ if( m_color_output )
output << setcolor( term_attr::BRIGHT, term_color::GREEN );
output << "info: ";
break;
case BOOST_UTL_ET_MESSAGE:
- if( runtime_config::color_output() )
+ if( m_color_output )
output << setcolor( term_attr::BRIGHT, term_color::CYAN );
break;
case BOOST_UTL_ET_WARNING:
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
- if( runtime_config::color_output() )
+ if( m_color_output )
output << setcolor( term_attr::BRIGHT, term_color::YELLOW );
output << "warning: in \"" << test_phase_identifier() << "\": ";
break;
case BOOST_UTL_ET_ERROR:
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
- if( runtime_config::color_output() )
+ if( m_color_output )
output << setcolor( term_attr::BRIGHT, term_color::RED );
output << "error: in \"" << test_phase_identifier() << "\": ";
break;
case BOOST_UTL_ET_FATAL_ERROR:
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
- if( runtime_config::color_output() )
+ if( m_color_output )
output << setcolor( term_attr::BLINK, term_color::RED );
output << "fatal error: in \"" << test_phase_identifier() << "\": ";
break;
@@ -224,8 +232,8 @@ compiler_log_formatter::log_entry_value( std::ostream& output, lazy_ostream cons
void
compiler_log_formatter::log_entry_finish( std::ostream& output )
{
- if( runtime_config::color_output() )
- output << setcolor();
+ if( m_color_output )
+ output << utils::setcolor();
output << std::endl;
}
@@ -236,8 +244,7 @@ compiler_log_formatter::log_entry_finish( std::ostream& output )
void
compiler_log_formatter::print_prefix( std::ostream& output, const_string file_name, std::size_t line_num )
{
- if( !file_name.empty() )
- {
+ if( !file_name.empty() ) {
#ifdef __APPLE_CC__
// Xcode-compatible logging format, idea by Richard Dingwall at
// <http://richarddingwall.name/2008/06/01/using-the-boost-unit-test-framework-with-xcode-3/>.
diff --git a/boost/test/impl/cpp_main.ipp b/boost/test/impl/cpp_main.ipp
index 5cab0f4274..aaa5cabfc5 100644
--- a/boost/test/impl/cpp_main.ipp
+++ b/boost/test/impl/cpp_main.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2001-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// (C) Copyright Beman Dawes 1995-2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -68,7 +68,7 @@ prg_exec_monitor_main( int (*cpp_main)( int argc, char* argv[] ), int argc, char
{
int result = 0;
- BOOST_TEST_IMPL_TRY {
+ BOOST_TEST_I_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;
}
}
- BOOST_TEST_IMPL_CATCH( ::boost::execution_exception, exex ) {
+ BOOST_TEST_I_CATCH( ::boost::execution_exception, exex ) {
std::cout << "\n**** exception(" << exex.code() << "): " << exex.what() << std::endl;
result = ::boost::exit_exception_failure;
}
- BOOST_TEST_IMPL_CATCH( ::boost::system_error, ex ) {
+ BOOST_TEST_I_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/boost/test/impl/debug.ipp b/boost/test/impl/debug.ipp
index 90e9d7ff2f..f4ee4971ce 100644
--- a/boost/test/impl/debug.ipp
+++ b/boost/test/impl/debug.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2006-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Use, modification, and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
// http://www.boost.org/LICENSE_1_0.txt)
@@ -305,8 +305,8 @@ prepare_window_title( dbg_startup_info const& dsi )
str_t path_sep( "\\/" );
- str_t::iterator it = unit_test::find_last_of( dsi.binary_path.begin(), dsi.binary_path.end(),
- path_sep.begin(), path_sep.end() );
+ str_t::iterator it = unit_test::utils::find_last_of( dsi.binary_path.begin(), dsi.binary_path.end(),
+ path_sep.begin(), path_sep.end() );
if( it == dsi.binary_path.end() )
it = dsi.binary_path.begin();
diff --git a/boost/test/impl/decorator.ipp b/boost/test/impl/decorator.ipp
index bf17907881..74d42b22a2 100644
--- a/boost/test/impl/decorator.ipp
+++ b/boost/test/impl/decorator.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2011-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -132,10 +132,10 @@ depends_on::apply( test_unit& tu )
#if !BOOST_TEST_SUPPORT_TOKEN_ITERATOR
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) );
+ utils::string_token_iterator tit( m_dependency, (utils::dropped_delimeters = "/", utils::kept_delimeters = utils::dt_none) );
test_unit* dep = &framework::master_test_suite();
- while( tit != string_token_iterator() ) {
+ while( tit != utils::string_token_iterator() ) {
BOOST_TEST_SETUP_ASSERT( dep->p_type == TUT_SUITE, std::string( "incorrect dependency specification " ) + m_dependency );
test_unit_id next_id = static_cast<test_suite*>(dep)->get( *tit );
diff --git a/boost/test/impl/execution_monitor.ipp b/boost/test/impl/execution_monitor.ipp
index 9929f74b53..b3e873efbe 100644
--- a/boost/test/impl/execution_monitor.ipp
+++ b/boost/test/impl/execution_monitor.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2001-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// (C) Copyright Beman Dawes and Ullrich Koethe 1995-2001.
// Use, modification, and distribution are subject to the
// Boost Software License, Version 1.0. (See accompanying file
@@ -243,9 +243,9 @@ report_error( execution_exception::error_code ec, boost::exception const* be, ch
va_end( *args );
- throw execution_exception( ec, buf, execution_exception::location( extract<throw_file>( be ),
- (size_t)extract<throw_line>( be ),
- extract<throw_function>( be ) ) );
+ BOOST_TEST_I_THROW(execution_exception( ec, buf, execution_exception::location( extract<throw_file>( be ),
+ (size_t)extract<throw_line>( be ),
+ extract<throw_function>( be ) ) ));
}
//____________________________________________________________________________//
@@ -869,7 +869,7 @@ execution_monitor::catch_signals( boost::function<int ()> const& F )
if( !sigsetjmp( signal_handler::jump_buffer(), 1 ) )
return detail::do_invoke( m_custom_translators , F );
else
- return BOOST_TEST_IMPL_THROW( local_signal_handler.sys_sig() );
+ BOOST_TEST_I_THROW( local_signal_handler.sys_sig() );
}
//____________________________________________________________________________//
@@ -1200,14 +1200,14 @@ execution_monitor::execute( boost::function<int ()> const& F )
if( debug::under_debugger() )
p_catch_system_errors.value = false;
- BOOST_TEST_IMPL_TRY {
+ BOOST_TEST_I_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
+#ifndef BOOST_NO_EXCEPTIONS
// Catch-clause reference arguments are a bit different from function
// arguments (ISO 15.3 paragraphs 18 & 19). Apparently const isn't
@@ -1273,7 +1273,7 @@ execution_monitor::execute( boost::function<int ()> const& F )
// system errors
catch( system_error const& ex )
{ detail::report_error( execution_exception::cpp_exception_error,
- "system_error produced by: %s: %s", ex.p_failed_exp.get(), std::strerror( ex.p_errno ) ); }
+ "system_error produced by: %s: %s", ex.p_failed_exp, std::strerror( ex.p_errno ) ); }
catch( detail::system_signal_exception const& ex )
{ ex.report(); }
diff --git a/boost/test/impl/framework.ipp b/boost/test/impl/framework.ipp
index a69d95cd2d..f710828051 100644
--- a/boost/test/impl/framework.ipp
+++ b/boost/test/impl/framework.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -170,8 +170,7 @@ static void
invoke_init_func( init_unit_test_func init_func )
{
#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
- if( !(*init_func)() )
- BOOST_TEST_IMPL_THROW( std::runtime_error( "test module initialization failed" ) );
+ BOOST_TEST_I_ASSRT( (*init_func)(), 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 );
@@ -237,11 +236,14 @@ public:
name_filter( test_unit_id_list& targ_list, const_string filter_expr ) : m_targ_list( targ_list ), m_depth( 0 )
{
#ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
- string_token_iterator tit( filter_expr, (dropped_delimeters = "/", kept_delimeters = dt_none) );
+ utils::string_token_iterator tit( filter_expr, (utils::dropped_delimeters = "/",
+ utils::kept_delimeters = utils::dt_none) );
- while( tit != string_token_iterator() ) {
- m_components.push_back( std::vector<component>( string_token_iterator( *tit, (dropped_delimeters = ",", kept_delimeters = dt_none) ),
- string_token_iterator() ) );
+ while( tit != utils::string_token_iterator() ) {
+ m_components.push_back(
+ std::vector<component>( utils::string_token_iterator( *tit, (utils::dropped_delimeters = ",",
+ utils::kept_delimeters = utils::dt_none) ),
+ utils::string_token_iterator() ) );
++tit;
}
@@ -390,7 +392,9 @@ parse_filters( test_unit_id master_tu_id, test_unit_id_list& tu_to_enable, test_
// 10. collect tu to enable and disable based on filters
bool had_selector_filter = false;
- BOOST_TEST_FOREACH( const_string, filter, runtime_config::test_to_run() ) {
+ std::vector<std::string> const& filters = runtime_config::get<std::vector<std::string> >( runtime_config::RUN_FILTERS );
+
+ BOOST_TEST_FOREACH( const_string, filter, filters ) {
BOOST_TEST_SETUP_ASSERT( !filter.is_empty(), "Invalid filter specification" );
enum { SELECTOR, ENABLER, DISABLER } filter_type = SELECTOR;
@@ -433,6 +437,8 @@ public:
, m_next_test_suite_id( MIN_TEST_SUITE_ID )
, m_test_in_progress( false )
, m_context_idx( 0 )
+ , m_log_sink( std::cout )
+ , m_report_sink( std::cerr )
{
}
@@ -531,12 +537,12 @@ public:
test_unit_id_list tu_to_disable;
// 10. If there are any filters supplied, figure out lists of test units to enable/disable
- bool had_selector_filter = !runtime_config::test_to_run().empty() &&
+ bool had_selector_filter = !runtime_config::get<std::vector<std::string> >( runtime_config::RUN_FILTERS ).empty() &&
parse_filters( master_tu_id, tu_to_enable, tu_to_disable );
// 20. Set the stage: either use default run status or disable all test units
- set_run_status setter( had_selector_filter ? test_unit::RS_DISABLED : test_unit::RS_INVALID );
- traverse_test_tree( master_tu_id, setter, true );
+ set_run_status initial_setter( had_selector_filter ? test_unit::RS_DISABLED : test_unit::RS_INVALID );
+ traverse_test_tree( master_tu_id, initial_setter, true );
// 30. Apply all selectors and enablers.
while( !tu_to_enable.empty() ) {
@@ -549,8 +555,8 @@ public:
continue;
// set new status and add all dependencies into tu_to_enable
- set_run_status setter( test_unit::RS_ENABLED, &tu_to_enable );
- traverse_test_tree( tu.p_id, setter, true );
+ set_run_status enabler( test_unit::RS_ENABLED, &tu_to_enable );
+ traverse_test_tree( tu.p_id, enabler, true );
}
// 40. Apply all disablers
@@ -563,8 +569,8 @@ public:
if( !tu.is_enabled() )
continue;
- set_run_status setter( test_unit::RS_DISABLED );
- traverse_test_tree( tu.p_id, setter, true );
+ set_run_status disabler( test_unit::RS_DISABLED );
+ traverse_test_tree( tu.p_id, disabler, true );
}
// 50. Make sure parents of enabled test units are also enabled
@@ -627,7 +633,7 @@ public:
if( tu.p_type == TUT_SUITE ) {
test_suite const& ts = static_cast<test_suite const&>( tu );
- if( runtime_config::random_seed() == 0 ) {
+ if( runtime_config::get<unsigned>( runtime_config::RANDOM_SEED ) == 0 ) {
typedef std::pair<counter_t,test_unit_id> value_type;
BOOST_TEST_FOREACH( value_type, chld, ts.m_ranked_children ) {
@@ -768,6 +774,9 @@ public:
int m_context_idx;
boost::execution_monitor m_aux_em;
+
+ runtime_config::stream_holder m_log_sink;
+ runtime_config::stream_holder m_report_sink;
};
//____________________________________________________________________________//
@@ -802,41 +811,48 @@ setup_for_execution( test_unit const& tu )
void
init( init_unit_test_func init_func, int argc, char* argv[] )
{
+ using namespace impl;
+
// 10. Set up runtime parameters
runtime_config::init( argc, argv );
- // 20. Set the desired log level and format
- unit_test_log.set_threshold_level( runtime_config::log_level() );
- unit_test_log.set_format( runtime_config::log_format() );
+ // 20. Set the desired log level, format and sink
+ unit_test_log.set_threshold_level( runtime_config::get<log_level>( runtime_config::LOG_LEVEL ) );
+ unit_test_log.set_format( runtime_config::get<output_format>( runtime_config::LOG_FORMAT ) );
+ s_frk_state().m_log_sink.setup( runtime_config::LOG_SINK );
+ unit_test_log.set_stream( s_frk_state().m_log_sink.ref() );
- // 30. Set the desired report level and format
- results_reporter::set_level( runtime_config::report_level() );
- results_reporter::set_format( runtime_config::report_format() );
+ // 30. Set the desired report level, format and sink
+ results_reporter::set_level( runtime_config::get<report_level>( runtime_config::REPORT_LEVEL ) );
+ results_reporter::set_format( runtime_config::get<output_format>( runtime_config::REPORT_FORMAT ) );
+ s_frk_state().m_report_sink.setup( runtime_config::REPORT_SINK );
+ results_reporter::set_stream( s_frk_state().m_report_sink.ref() );
// 40. Register default test observers
register_observer( results_collector );
register_observer( unit_test_log );
- if( runtime_config::show_progress() )
+ if( runtime_config::get<bool>( runtime_config::SHOW_PROGRESS ) ) {
+ progress_monitor.set_stream( s_frk_state().m_log_sink.ref() );
register_observer( progress_monitor );
+ }
// 50. Set up memory leak detection
- if( runtime_config::detect_memory_leaks() > 0 ) {
- debug::detect_memory_leaks( true, runtime_config::memory_leaks_report_file() );
- debug::break_memory_alloc( runtime_config::detect_memory_leaks() );
+ unsigned long detect_mem_leak = runtime_config::get<unsigned long>( runtime_config::DETECT_MEM_LEAKS );
+ if( detect_mem_leak > 0 ) {
+ debug::detect_memory_leaks( true, runtime_config::get<std::string>( runtime_config::REPORT_MEM_LEAKS ) );
+ debug::break_memory_alloc( (long)detect_mem_leak );
}
// 60. Initialize master unit test suite
master_test_suite().argc = argc;
master_test_suite().argv = argv;
- using namespace impl;
-
// 70. Invoke test module initialization routine
- BOOST_TEST_IMPL_TRY {
+ BOOST_TEST_I_TRY {
s_frk_state().m_aux_em.vexecute( boost::bind( &impl::invoke_init_func, init_func ) );
}
- BOOST_TEST_IMPL_CATCH( execution_exception, ex ) {
+ BOOST_TEST_I_CATCH( execution_exception, ex ) {
BOOST_TEST_SETUP_ASSERT( false, ex.what() );
}
}
@@ -1157,8 +1173,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 )
- BOOST_TEST_IMPL_THROW( internal_error( "Invalid test unit type" ) );
+ BOOST_TEST_I_ASSRT( (res->p_type & t) != 0, internal_error( "Invalid test unit type" ) );
return *res;
}
@@ -1181,7 +1196,7 @@ run( test_unit_id id, bool continue_test )
test_case_counter tcc;
traverse_test_tree( id, tcc );
- BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().empty()
+ BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::get<std::vector<std::string> >( runtime_config::RUN_FILTERS ).empty()
? BOOST_TEST_L( "test tree is empty" )
: BOOST_TEST_L( "no test cases matching filter or all test cases were disabled" ) );
@@ -1192,27 +1207,24 @@ run( test_unit_id id, bool continue_test )
if( call_start_finish ) {
BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers ) {
- BOOST_TEST_IMPL_TRY {
+ BOOST_TEST_I_TRY {
impl::s_frk_state().m_aux_em.vexecute( boost::bind( &test_observer::test_start, to, tcc.p_count ) );
}
- BOOST_TEST_IMPL_CATCH( execution_exception, ex ) {
+ BOOST_TEST_I_CATCH( execution_exception, ex ) {
BOOST_TEST_SETUP_ASSERT( false, ex.what() );
}
}
}
- switch( runtime_config::random_seed() ) {
+ unsigned seed = runtime_config::get<unsigned>( runtime_config::RANDOM_SEED );
+ switch( seed ) {
case 0:
break;
- case 1: {
- unsigned seed = static_cast<unsigned>( std::time( 0 ) );
+ case 1:
+ seed = static_cast<unsigned>( std::time( 0 ) );
+ default:
BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << seed );
std::srand( seed );
- break;
- }
- default:
- BOOST_TEST_MESSAGE( "Test cases order is shuffled using seed: " << runtime_config::random_seed() );
- std::srand( runtime_config::random_seed() );
}
impl::s_frk_state().execute_test_tree( id );
diff --git a/boost/test/impl/plain_report_formatter.ipp b/boost/test/impl/plain_report_formatter.ipp
index f9e7db772a..262083eeaa 100644
--- a/boost/test/impl/plain_report_formatter.ipp
+++ b/boost/test/impl/plain_report_formatter.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -19,14 +19,13 @@
#include <boost/test/output/plain_report_formatter.hpp>
#include <boost/test/utils/custom_manip.hpp>
#include <boost/test/results_collector.hpp>
+#include <boost/test/unit_test_parameters.hpp>
#include <boost/test/tree/test_unit.hpp>
#include <boost/test/utils/basic_cstring/io.hpp>
#include <boost/test/utils/setcolor.hpp>
-#include <boost/test/unit_test_parameters.hpp>
-
// STL
#include <iomanip>
#include <boost/config/no_tr1/cmath.hpp>
@@ -46,11 +45,11 @@ namespace output {
namespace {
-typedef custom_manip<struct quote_t> quote;
+typedef utils::custom_manip<struct quote_t> quote;
template<typename T>
inline std::ostream&
-operator<<( custom_printer<quote> const& p, T const& value )
+operator<<( utils::custom_printer<quote> const& p, T const& value )
{
*p << '"' << value << '"';
@@ -84,6 +83,7 @@ void
plain_report_formatter::results_report_start( std::ostream& ostr )
{
m_indent = 0;
+ m_color_output = runtime_config::get<bool>( runtime_config::COLOR_OUTPUT );
ostr << '\n';
}
@@ -160,13 +160,13 @@ plain_report_formatter::do_confirmation_report( test_unit const& tu, std::ostrea
test_results const& tr = results_collector.results( tu.p_id );
if( tr.passed() ) {
- BOOST_TEST_SCOPE_SETCOLOR( ostr, term_attr::BRIGHT, term_color::GREEN );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, ostr, term_attr::BRIGHT, term_color::GREEN );
ostr << "*** No errors detected\n";
return;
}
- BOOST_TEST_SCOPE_SETCOLOR( ostr, term_attr::BRIGHT, term_color::RED );
+ BOOST_TEST_SCOPE_SETCOLOR( m_color_output, ostr, term_attr::BRIGHT, term_color::RED );
if( tr.p_skipped ) {
ostr << "*** The test " << tu.p_type_name << ' ' << quote() << tu.full_name() << " was skipped"
diff --git a/boost/test/impl/progress_monitor.ipp b/boost/test/impl/progress_monitor.ipp
index ebdd7e9320..7fb3baf8f0 100644
--- a/boost/test/impl/progress_monitor.ipp
+++ b/boost/test/impl/progress_monitor.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -17,8 +17,8 @@
// Boost.Test
#include <boost/test/progress_monitor.hpp>
-
#include <boost/test/unit_test_parameters.hpp>
+
#include <boost/test/utils/setcolor.hpp>
#include <boost/test/tree/test_unit.hpp>
@@ -102,15 +102,21 @@ namespace {
struct progress_monitor_impl {
// Constructor
progress_monitor_impl()
- : m_stream( runtime_config::log_sink() )
- {}
+ : m_stream( &std::cout )
+ , m_color_output( false )
+ {
+ }
- std::ostream* m_stream;
- scoped_ptr<progress_display> m_progress_display;
+ std::ostream* m_stream;
+ scoped_ptr<progress_display> m_progress_display;
+ bool m_color_output;
};
progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; return the_inst; }
+#define PM_SCOPED_COLOR() \
+ BOOST_TEST_SCOPE_SETCOLOR( s_pm_impl().m_color_output, *s_pm_impl().m_stream, term_attr::BRIGHT, term_color::MAGENTA )
+
} // local namespace
//____________________________________________________________________________//
@@ -118,7 +124,9 @@ progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; retu
void
progress_monitor_t::test_start( counter_t test_cases_amount )
{
- BOOST_TEST_SCOPE_SETCOLOR( *s_pm_impl().m_stream, term_attr::BRIGHT, term_color::MAGENTA );
+ s_pm_impl().m_color_output = runtime_config::get<bool>( runtime_config::COLOR_OUTPUT );
+
+ PM_SCOPED_COLOR();
s_pm_impl().m_progress_display.reset( new progress_display( test_cases_amount, *s_pm_impl().m_stream ) );
}
@@ -128,7 +136,7 @@ progress_monitor_t::test_start( counter_t test_cases_amount )
void
progress_monitor_t::test_aborted()
{
- BOOST_TEST_SCOPE_SETCOLOR( *s_pm_impl().m_stream, term_attr::BRIGHT, term_color::MAGENTA );
+ PM_SCOPED_COLOR();
(*s_pm_impl().m_progress_display) += s_pm_impl().m_progress_display->count();
}
@@ -138,7 +146,7 @@ progress_monitor_t::test_aborted()
void
progress_monitor_t::test_unit_finish( test_unit const& tu, unsigned long )
{
- BOOST_TEST_SCOPE_SETCOLOR( *s_pm_impl().m_stream, term_attr::BRIGHT, term_color::MAGENTA );
+ PM_SCOPED_COLOR();
if( tu.p_type == TUT_CASE )
++(*s_pm_impl().m_progress_display);
@@ -149,7 +157,7 @@ progress_monitor_t::test_unit_finish( test_unit const& tu, unsigned long )
void
progress_monitor_t::test_unit_skipped( test_unit const& tu, const_string /*reason*/ )
{
- BOOST_TEST_SCOPE_SETCOLOR( *s_pm_impl().m_stream, term_attr::BRIGHT, term_color::MAGENTA );
+ PM_SCOPED_COLOR();
test_case_counter tcc;
traverse_test_tree( tu, tcc );
@@ -167,6 +175,8 @@ progress_monitor_t::set_stream( std::ostream& ostr )
//____________________________________________________________________________//
+#undef PM_SCOPED_COLOR
+
} // namespace unit_test
} // namespace boost
diff --git a/boost/test/impl/results_collector.ipp b/boost/test/impl/results_collector.ipp
index d04d64fd6d..17a31955ea 100644
--- a/boost/test/impl/results_collector.ipp
+++ b/boost/test/impl/results_collector.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
diff --git a/boost/test/impl/results_reporter.ipp b/boost/test/impl/results_reporter.ipp
index 885295c928..87c1172e12 100644
--- a/boost/test/impl/results_reporter.ipp
+++ b/boost/test/impl/results_reporter.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -19,6 +19,7 @@
#include <boost/test/results_reporter.hpp>
#include <boost/test/results_collector.hpp>
#include <boost/test/framework.hpp>
+
#include <boost/test/output/plain_report_formatter.hpp>
#include <boost/test/output/xml_report_formatter.hpp>
@@ -26,8 +27,6 @@
#include <boost/test/tree/test_unit.hpp>
#include <boost/test/tree/traverse.hpp>
-#include <boost/test/unit_test_parameters.hpp>
-
// Boost
#include <boost/scoped_ptr.hpp>
#include <boost/io/ios_state.hpp>
@@ -53,8 +52,8 @@ namespace {
struct results_reporter_impl : test_tree_visitor {
// Constructor
results_reporter_impl()
- : m_output( runtime_config::report_sink() )
- , m_stream_state_saver( new io_saver_type( *m_output ) )
+ : m_stream( &std::cerr )
+ , m_stream_state_saver( new io_saver_type( std::cerr ) )
, m_report_level( CONFIRMATION_REPORT )
, m_formatter( new output::plain_report_formatter )
{}
@@ -62,28 +61,28 @@ struct results_reporter_impl : test_tree_visitor {
// test tree visitor interface implementation
void visit( test_case const& tc )
{
- m_formatter->test_unit_report_start( tc, *m_output );
- m_formatter->test_unit_report_finish( tc, *m_output );
+ m_formatter->test_unit_report_start( tc, *m_stream );
+ m_formatter->test_unit_report_finish( tc, *m_stream );
}
bool test_suite_start( test_suite const& ts )
{
- m_formatter->test_unit_report_start( ts, *m_output );
+ m_formatter->test_unit_report_start( ts, *m_stream );
if( m_report_level == DETAILED_REPORT && !results_collector.results( ts.p_id ).p_skipped )
return true;
- m_formatter->test_unit_report_finish( ts, *m_output );
+ m_formatter->test_unit_report_finish( ts, *m_stream );
return false;
}
void test_suite_finish( test_suite const& ts )
{
- m_formatter->test_unit_report_finish( ts, *m_output );
+ m_formatter->test_unit_report_finish( ts, *m_stream );
}
typedef scoped_ptr<io_saver_type> saver_ptr;
// Data members
- std::ostream* m_output;
+ std::ostream* m_stream;
saver_ptr m_stream_state_saver;
report_level m_report_level;
scoped_ptr<format> m_formatter;
@@ -109,7 +108,7 @@ set_level( report_level l )
void
set_stream( std::ostream& ostr )
{
- s_rr_impl().m_output = &ostr;
+ s_rr_impl().m_stream = &ostr;
s_rr_impl().m_stream_state_saver.reset( new io_saver_type( ostr ) );
}
@@ -118,7 +117,7 @@ set_stream( std::ostream& ostr )
std::ostream&
get_stream()
{
- return *s_rr_impl().m_output;
+ return *s_rr_impl().m_stream;
}
//____________________________________________________________________________//
@@ -169,11 +168,11 @@ make_report( report_level l, test_unit_id id )
report_level bkup = s_rr_impl().m_report_level;
s_rr_impl().m_report_level = l;
- s_rr_impl().m_formatter->results_report_start( *s_rr_impl().m_output );
+ s_rr_impl().m_formatter->results_report_start( *s_rr_impl().m_stream );
switch( l ) {
case CONFIRMATION_REPORT:
- s_rr_impl().m_formatter->do_confirmation_report( framework::get<test_unit>( id ), *s_rr_impl().m_output );
+ s_rr_impl().m_formatter->do_confirmation_report( framework::get<test_unit>( id ), *s_rr_impl().m_stream );
break;
case SHORT_REPORT:
case DETAILED_REPORT:
@@ -183,7 +182,7 @@ make_report( report_level l, test_unit_id id )
break;
}
- s_rr_impl().m_formatter->results_report_finish( *s_rr_impl().m_output );
+ s_rr_impl().m_formatter->results_report_finish( *s_rr_impl().m_stream );
s_rr_impl().m_report_level = bkup;
}
diff --git a/boost/test/impl/test_main.ipp b/boost/test/impl/test_main.ipp
index c95c91e88b..6adc5bb9c2 100644
--- a/boost/test/impl/test_main.ipp
+++ b/boost/test/impl/test_main.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2001-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// (C) Copyright Beman Dawes 1995-2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
diff --git a/boost/test/impl/test_tools.ipp b/boost/test/impl/test_tools.ipp
index 03fea91605..ed94da3a5b 100644
--- a/boost/test/impl/test_tools.ipp
+++ b/boost/test/impl/test_tools.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -294,9 +294,8 @@ report_assertion( assertion_result const& ar,
{
using namespace unit_test;
- if( framework::current_test_case_id() == INV_TEST_UNIT_ID )
- BOOST_TEST_IMPL_THROW(
- std::runtime_error( "can't use testing tools outside of test case implementation" ) );
+ BOOST_TEST_I_ASSRT( framework::current_test_case_id() != INV_TEST_UNIT_ID,
+ std::runtime_error( "Can't use testing tools outside of test case implementation." ) );
if( !!ar )
tl = PASS;
@@ -357,7 +356,7 @@ report_assertion( assertion_result const& ar,
framework::test_unit_aborted( framework::current_test_case() );
- BOOST_TEST_IMPL_THROW( execution_aborted() );
+ BOOST_TEST_I_THROW( execution_aborted() );
}
return true;
diff --git a/boost/test/impl/test_tree.ipp b/boost/test/impl/test_tree.ipp
index 712cb9ee42..d45f7b32b5 100644
--- a/boost/test/impl/test_tree.ipp
+++ b/boost/test/impl/test_tree.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -39,10 +39,6 @@
#include <boost/test/detail/suppress_warnings.hpp>
-#if BOOST_WORKAROUND(__BORLANDC__, < 0x600) && BOOST_WORKAROUND(_STLPORT_VERSION, <= 0x450)
- using std::rand; // rand is in std and random_shuffle is in _STL
-#endif
-
//____________________________________________________________________________//
namespace boost {
@@ -141,8 +137,13 @@ test_unit::check_preconditions() const
BOOST_TEST_FOREACH( precondition_t, precondition, p_preconditions.get() ) {
test_tools::assertion_result res = precondition( p_id );
- if( !res )
- return res;
+ if( !res ) {
+ test_tools::assertion_result res_out(false);
+ res_out.message() << "precondition failed";
+ if( !res.has_empty_message() )
+ res_out.message() << ": " << res.message();
+ return res_out;
+ }
}
return true;
diff --git a/boost/test/impl/unit_test_log.ipp b/boost/test/impl/unit_test_log.ipp
index f202f5027d..4c9ac40691 100644
--- a/boost/test/impl/unit_test_log.ipp
+++ b/boost/test/impl/unit_test_log.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -20,7 +20,6 @@
#include <boost/test/unit_test_log_formatter.hpp>
#include <boost/test/execution_monitor.hpp>
#include <boost/test/framework.hpp>
-
#include <boost/test/unit_test_parameters.hpp>
#include <boost/test/utils/basic_cstring/compare.hpp>
@@ -85,8 +84,8 @@ namespace {
struct unit_test_log_impl {
// Constructor
unit_test_log_impl()
- : m_stream( runtime_config::log_sink() )
- , m_stream_state_saver( new io_saver_type( *m_stream ) )
+ : m_stream( &std::cout )
+ , m_stream_state_saver( new io_saver_type( std::cout ) )
, m_threshold_level( log_all_errors )
, m_log_formatter( new output::compiler_log_formatter )
{
@@ -110,11 +109,14 @@ struct unit_test_log_impl {
log_checkpoint_data m_checkpoint_data;
// helper functions
- std::ostream& stream() { return *m_stream; }
+ std::ostream& stream()
+ {
+ return *m_stream;
+ }
void set_checkpoint( const_string file, std::size_t line_num, const_string msg )
{
assign_op( m_checkpoint_data.m_message, msg, 0 );
- m_checkpoint_data.m_file_name = file;
+ m_checkpoint_data.m_file_name = file;
m_checkpoint_data.m_line_num = line_num;
}
};
@@ -133,7 +135,7 @@ unit_test_log_t::test_start( counter_t test_cases_amount )
s_log_impl().m_log_formatter->log_start( s_log_impl().stream(), test_cases_amount );
- if( runtime_config::show_build_info() )
+ if( runtime_config::get<bool>( runtime_config::BUILD_INFO ) )
s_log_impl().m_log_formatter->log_build_info( s_log_impl().stream() );
s_log_impl().m_entry_in_progress = false;
diff --git a/boost/test/impl/unit_test_main.ipp b/boost/test/impl/unit_test_main.ipp
index 327e14de30..1f30c0213e 100644
--- a/boost/test/impl/unit_test_main.ipp
+++ b/boost/test/impl/unit_test_main.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2001-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -102,7 +102,7 @@ private:
m_os << ",fontname=Helvetica";
- m_os << (tu.is_enabled() ? ",color=green" : ",color=yellow");
+ m_os << (tu.p_default_status == test_unit::RS_ENABLED ? ",color=green" : ",color=yellow");
if( master_ts )
m_os << ",label=\"" << tu.p_name << "\"];\n";
@@ -185,10 +185,10 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
{
int result_code = 0;
- BOOST_TEST_IMPL_TRY {
+ BOOST_TEST_I_TRY {
framework::init( init_func, argc, argv );
- if( runtime_config::wait_for_debugger() ) {
+ if( runtime_config::get<bool>( runtime_config::WAIT_FOR_DEBUGGER ) ) {
results_reporter::get_stream() << "Press any key to continue..." << std::endl;
std::getchar();
@@ -197,8 +197,9 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
framework::finalize_setup_phase();
- if( runtime_config::list_content() != unit_test::OF_INVALID ) {
- if( runtime_config::list_content() == unit_test::OF_DOT ) {
+ output_format list_cont = runtime_config::get<output_format>( runtime_config::LIST_CONTENT );
+ if( list_cont != unit_test::OF_INVALID ) {
+ if( list_cont == unit_test::OF_DOT ) {
ut_detail::dot_content_reporter reporter( results_reporter::get_stream() );
traverse_test_tree( framework::master_test_suite().p_id, reporter, true );
@@ -212,7 +213,7 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
return boost::exit_success;
}
- if( runtime_config::list_labels() ) {
+ if( runtime_config::get<bool>( runtime_config::LIST_LABELS ) ) {
ut_detail::labels_collector collector;
traverse_test_tree( framework::master_test_suite().p_id, collector, true );
@@ -229,24 +230,24 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] )
results_reporter::make_report();
- result_code = runtime_config::no_result_code()
+ result_code = !runtime_config::get<bool>( runtime_config::RESULT_CODE )
? boost::exit_success
: results_collector.results( framework::master_test_suite().p_id ).result_code();
}
- BOOST_TEST_IMPL_CATCH0( framework::nothing_to_test ) {
- result_code = boost::exit_success;
+ BOOST_TEST_I_CATCH( framework::nothing_to_test, ex ) {
+ result_code = ex.m_result_code;
}
- BOOST_TEST_IMPL_CATCH( framework::internal_error, ex ) {
+ BOOST_TEST_I_CATCH( framework::internal_error, ex ) {
results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
result_code = boost::exit_exception_failure;
}
- BOOST_TEST_IMPL_CATCH( framework::setup_error, ex ) {
+ BOOST_TEST_I_CATCH( framework::setup_error, ex ) {
results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl;
result_code = boost::exit_exception_failure;
}
- BOOST_TEST_IMPL_CATCHALL() {
+ BOOST_TEST_I_CATCHALL() {
results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl;
result_code = boost::exit_exception_failure;
diff --git a/boost/test/impl/unit_test_monitor.ipp b/boost/test/impl/unit_test_monitor.ipp
index 8c931f203f..304c8f1c04 100644
--- a/boost/test/impl/unit_test_monitor.ipp
+++ b/boost/test/impl/unit_test_monitor.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -36,16 +36,16 @@ namespace unit_test {
unit_test_monitor_t::error_level
unit_test_monitor_t::execute_and_translate( boost::function<void ()> const& func, unsigned timeout )
{
- BOOST_TEST_IMPL_TRY {
- p_catch_system_errors.value = runtime_config::catch_sys_errors();
+ BOOST_TEST_I_TRY {
+ p_catch_system_errors.value = runtime_config::get<bool>( runtime_config::CATCH_SYS_ERRORS );
p_timeout.value = timeout;
- p_auto_start_dbg.value = runtime_config::auto_start_dbg();
- p_use_alt_stack.value = runtime_config::use_alt_stack();
- p_detect_fp_exceptions.value = runtime_config::detect_fp_exceptions();
+ p_auto_start_dbg.value = runtime_config::get<bool>( runtime_config::AUTO_START_DBG );
+ p_use_alt_stack.value = runtime_config::get<bool>( runtime_config::USE_ALT_STACK );
+ p_detect_fp_exceptions.value = runtime_config::get<bool>( runtime_config::DETECT_FP_EXCEPT );
vexecute( func );
}
- BOOST_TEST_IMPL_CATCH( execution_exception, ex ) {
+ BOOST_TEST_I_CATCH( execution_exception, ex ) {
framework::exception_caught( ex );
framework::test_unit_aborted( framework::current_test_case() );
diff --git a/boost/test/impl/unit_test_parameters.ipp b/boost/test/impl/unit_test_parameters.ipp
index 2ffa495e67..3ca183e400 100644
--- a/boost/test/impl/unit_test_parameters.ipp
+++ b/boost/test/impl/unit_test_parameters.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2001-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -20,36 +20,32 @@
// Boost.Test
#include <boost/test/unit_test_parameters.hpp>
+
#include <boost/test/utils/basic_cstring/basic_cstring.hpp>
#include <boost/test/utils/basic_cstring/compare.hpp>
#include <boost/test/utils/basic_cstring/io.hpp>
-#include <boost/test/utils/fixed_mapping.hpp>
+
#include <boost/test/debug.hpp>
#include <boost/test/framework.hpp>
+#include <boost/test/detail/log_level.hpp>
#include <boost/test/detail/throw_exception.hpp>
// Boost.Runtime.Param
-#include <boost/test/utils/runtime/cla/dual_name_parameter.hpp>
+#include <boost/test/utils/runtime/parameter.hpp>
+#include <boost/test/utils/runtime/argument.hpp>
+#include <boost/test/utils/runtime/finalize.hpp>
#include <boost/test/utils/runtime/cla/parser.hpp>
-
-namespace rt = boost::runtime;
-namespace cla = rt::cla;
-
-#ifndef UNDER_CE
-#include <boost/test/utils/runtime/env/variable.hpp>
-
-namespace env = rt::env;
-#endif
+#include <boost/test/utils/runtime/env/fetch.hpp>
// Boost
#include <boost/config.hpp>
#include <boost/test/detail/suppress_warnings.hpp>
-#include <boost/lexical_cast.hpp>
#include <boost/test/detail/enable_warnings.hpp>
+#include <boost/optional.hpp>
+#include <boost/cstdlib.hpp>
// STL
-#include <map>
#include <cstdlib>
#include <iostream>
#include <fstream>
@@ -65,85 +61,7 @@ namespace std { using ::getenv; using ::strncmp; using ::strcmp; }
namespace boost {
namespace unit_test {
-// ************************************************************************** //
-// ************** input operations for unit_test's enums ************** //
-// ************************************************************************** //
-
-std::istream&
-operator>>( std::istream& in, unit_test::log_level& ll )
-{
- static fixed_mapping<const_string,unit_test::log_level,case_ins_less<char const> > log_level_name(
- "all" , log_successful_tests,
- "success" , log_successful_tests,
- "test_suite" , log_test_units,
- "unit_scope" , log_test_units,
- "message" , log_messages,
- "warning" , log_warnings,
- "error" , log_all_errors,
- "cpp_exception" , log_cpp_exception_errors,
- "system_error" , log_system_errors,
- "fatal_error" , log_fatal_errors,
- "nothing" , log_nothing,
-
- invalid_log_level
- );
-
- std::string val;
- in >> val;
-
- ll = log_level_name[val];
- BOOST_TEST_SETUP_ASSERT( ll != unit_test::invalid_log_level, "invalid log level " + val );
-
- return in;
-}
-
-//____________________________________________________________________________//
-
-std::istream&
-operator>>( std::istream& in, unit_test::report_level& rl )
-{
- fixed_mapping<const_string,unit_test::report_level,case_ins_less<char const> > report_level_name (
- "confirm", CONFIRMATION_REPORT,
- "short", SHORT_REPORT,
- "detailed", DETAILED_REPORT,
- "no", NO_REPORT,
-
- INV_REPORT_LEVEL
- );
-
- std::string val;
- in >> val;
-
- rl = report_level_name[val];
- BOOST_TEST_SETUP_ASSERT( rl != INV_REPORT_LEVEL, "invalid report level " + val );
-
- return in;
-}
-
-//____________________________________________________________________________//
-
-std::istream&
-operator>>( std::istream& in, unit_test::output_format& of )
-{
- fixed_mapping<const_string,unit_test::output_format,case_ins_less<char const> > output_format_name (
- "HRF", unit_test::OF_CLF,
- "CLF", unit_test::OF_CLF,
- "XML", unit_test::OF_XML,
- "DOT", unit_test::OF_DOT,
-
- unit_test::OF_INVALID
- );
-
- std::string val;
- in >> val;
-
- of = output_format_name[val];
- BOOST_TEST_SETUP_ASSERT( of != unit_test::OF_INVALID, "invalid output format " + val );
-
- return in;
-}
-
-//____________________________________________________________________________//
+namespace rt = boost::runtime;
// ************************************************************************** //
// ************** runtime_config ************** //
@@ -151,9 +69,7 @@ operator>>( std::istream& in, unit_test::output_format& of )
namespace runtime_config {
-namespace {
-
-// framework parameters and corresponding command-line arguments
+// UTF parameters
std::string AUTO_START_DBG = "auto_start_dbg";
std::string BREAK_EXEC_PATH = "break_exec_path";
std::string BUILD_INFO = "build_info";
@@ -170,463 +86,636 @@ std::string OUTPUT_FORMAT = "output_format";
std::string RANDOM_SEED = "random";
std::string REPORT_FORMAT = "report_format";
std::string REPORT_LEVEL = "report_level";
+std::string REPORT_MEM_LEAKS = "report_memory_leaks_to";
std::string REPORT_SINK = "report_sink";
std::string RESULT_CODE = "result_code";
-std::string TESTS_TO_RUN = "run_test";
+std::string RUN_FILTERS = "run_test";
std::string SAVE_TEST_PATTERN = "save_pattern";
std::string SHOW_PROGRESS = "show_progress";
std::string USE_ALT_STACK = "use_alt_stack";
std::string WAIT_FOR_DEBUGGER = "wait_for_debugger";
-static const_string
-parameter_2_env_var( const_string param_name )
-{
- typedef std::map<const_string,const_string> mtype;
- static mtype s_mapping;
-
- if( s_mapping.empty() ) {
- s_mapping[AUTO_START_DBG] = "BOOST_TEST_AUTO_START_DBG";
- s_mapping[BREAK_EXEC_PATH] = "BOOST_TEST_BREAK_EXEC_PATH";
- s_mapping[BUILD_INFO] = "BOOST_TEST_BUILD_INFO";
- s_mapping[CATCH_SYS_ERRORS] = "BOOST_TEST_CATCH_SYSTEM_ERRORS";
- s_mapping[COLOR_OUTPUT] = "BOOST_TEST_COLOR_OUTPUT";
- s_mapping[DETECT_FP_EXCEPT] = "BOOST_TEST_DETECT_FP_EXCEPTIONS";
- s_mapping[DETECT_MEM_LEAKS] = "BOOST_TEST_DETECT_MEMORY_LEAK";
- s_mapping[LIST_CONTENT] = "BOOST_TEST_LIST_CONTENT";
- s_mapping[LIST_CONTENT] = "BOOST_TEST_LIST_LABELS";
- s_mapping[LOG_FORMAT] = "BOOST_TEST_LOG_FORMAT";
- s_mapping[LOG_LEVEL] = "BOOST_TEST_LOG_LEVEL";
- s_mapping[LOG_SINK] = "BOOST_TEST_LOG_SINK";
- s_mapping[OUTPUT_FORMAT] = "BOOST_TEST_OUTPUT_FORMAT";
- s_mapping[RANDOM_SEED] = "BOOST_TEST_RANDOM";
- s_mapping[REPORT_FORMAT] = "BOOST_TEST_REPORT_FORMAT";
- s_mapping[REPORT_LEVEL] = "BOOST_TEST_REPORT_LEVEL";
- s_mapping[REPORT_SINK] = "BOOST_TEST_REPORT_SINK";
- s_mapping[RESULT_CODE] = "BOOST_TEST_RESULT_CODE";
- s_mapping[TESTS_TO_RUN] = "BOOST_TESTS_TO_RUN";
- s_mapping[SAVE_TEST_PATTERN] = "BOOST_TEST_SAVE_PATTERN";
- s_mapping[SHOW_PROGRESS] = "BOOST_TEST_SHOW_PROGRESS";
- s_mapping[USE_ALT_STACK] = "BOOST_TEST_USE_ALT_STACK";
- s_mapping[WAIT_FOR_DEBUGGER] = "BOOST_TEST_WAIT_FOR_DEBUGGER";
- }
-
- mtype::const_iterator it = s_mapping.find( param_name );
-
- return it == s_mapping.end() ? const_string() : it->second;
-}
-
-//____________________________________________________________________________//
-
-// storage for the CLAs
-cla::parser s_cla_parser;
-std::string s_empty;
-
-output_format s_report_format;
-output_format s_log_format;
-
-std::list<std::string> s_test_to_run;
+std::string HELP = "help";
+std::string USAGE = "usage";
//____________________________________________________________________________//
-template<typename T>
-T
-retrieve_parameter( const_string parameter_name, cla::parser const& s_cla_parser, T const& default_value = T(), T const& optional_value = T() )
-{
- rt::const_argument_ptr arg = s_cla_parser[parameter_name];
- if( arg ) {
- if( rtti::type_id<T>() == rtti::type_id<bool>() ||
- !static_cast<cla::parameter const&>( arg->p_formal_parameter.get() ).p_optional_value )
- return s_cla_parser.get<T>( parameter_name );
-
- optional<T> val = s_cla_parser.get<optional<T> >( parameter_name );
- if( val )
- return *val;
- else
- return optional_value;
- }
-
- boost::optional<T> v;
-
-#ifndef UNDER_CE
- env::get( parameter_2_env_var(parameter_name), v );
-#endif
-
- if( v )
- return *v;
- else
- return default_value;
-}
-
-//____________________________________________________________________________//
-
-void
-disable_use( cla::parameter const&, std::string const& )
-{
- BOOST_TEST_SETUP_ASSERT( false, "parameter break_exec_path is disabled in this release" );
-}
-
-//____________________________________________________________________________//
-
-} // local namespace
+namespace {
void
-init( int& argc, char** argv )
+register_parameters( rt::parameters_store& store )
{
- using namespace cla;
-
- BOOST_TEST_IMPL_TRY {
- if( s_cla_parser.num_params() != 0 )
- s_cla_parser.reset();
- else
- s_cla_parser - cla::ignore_mismatch
- << cla::dual_name_parameter<bool>( AUTO_START_DBG + "|d" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Automatically starts debugger if system level error (signal) occurs")
- << cla::named_parameter<std::string>( BREAK_EXEC_PATH )
- - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
- cla::description = "For the exception safety testing allows to break at specific execution path",
- cla::handler = &disable_use)
- << cla::dual_name_parameter<bool>( BUILD_INFO + "|i" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Shows library build information" )
- << cla::dual_name_parameter<bool>( CATCH_SYS_ERRORS + "|s" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Allows to switch between catching and ignoring system errors (signals)")
- << cla::dual_name_parameter<bool>( COLOR_OUTPUT + "|x" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Allows to switch between catching and ignoring system errors (signals)")
- << cla::named_parameter<bool>( DETECT_FP_EXCEPT )
- - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
- cla::description = "Allows to switch between catching and ignoring floating point exceptions")
- << cla::named_parameter<std::string>( DETECT_MEM_LEAKS )
- - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,cla::optional_value,
- cla::description = "Allows to switch between catching and ignoring memory leaks")
- << cla::dual_name_parameter<unit_test::output_format>( LOG_FORMAT + "|f" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Specifies log format")
- << cla::dual_name_parameter<unit_test::log_level>( LOG_LEVEL + "|l" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Specifies log level")
- << cla::dual_name_parameter<std::string>( LOG_SINK + "|k" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Specifies log sink:stdout(default),stderr or file name")
- << cla::dual_name_parameter<unit_test::output_format>( OUTPUT_FORMAT + "|o" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Specifies output format (both log and report)")
- << cla::dual_name_parameter<unsigned>( RANDOM_SEED + "|a" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,cla::optional_value,
- cla::description = "Allows to switch between sequential and random order of test units execution.\n"
- "Optionally allows to specify concrete seed for random number generator")
- << cla::dual_name_parameter<unit_test::output_format>( REPORT_FORMAT + "|m" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Specifies report format")
- << cla::dual_name_parameter<unit_test::report_level>(REPORT_LEVEL + "|r")
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Specifies report level")
- << cla::dual_name_parameter<std::string>( REPORT_SINK + "|e" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Specifies report sink:stderr(default),stdout or file name")
- << cla::dual_name_parameter<bool>( RESULT_CODE + "|c" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Allows to disable test modules's result code generation")
- << cla::dual_name_parameter<std::string>( TESTS_TO_RUN + "|t" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,cla::multiplicable,
- cla::description = "Allows to filter which test units to run")
- << cla::named_parameter<bool>( SAVE_TEST_PATTERN )
- - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
- cla::description = "Allows to switch between saving and matching against test pattern file")
- << cla::dual_name_parameter<bool>( SHOW_PROGRESS + "|p" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
- cla::description = "Turns on progress display")
- << cla::dual_name_parameter<unit_test::output_format>( LIST_CONTENT + "|j" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,cla::optional_value,
- cla::description = "Lists the content of test tree - names of all test suites and test cases")
- << cla::named_parameter<bool>( LIST_LABELS )
- - (cla::prefix = "--",cla::separator = "= ",cla::guess_name,cla::optional,
- cla::description = "Lists all available labels")
- << cla::named_parameter<bool>( USE_ALT_STACK )
- - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
- cla::description = "Turns on/off usage of an alternative stack for signal handling")
- << cla::dual_name_parameter<bool>( WAIT_FOR_DEBUGGER + "|w" )
- - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,cla::optional_value,
- cla::description = "Forces test module to wait for button to be pressed before starting test run")
-
- << cla::dual_name_parameter<bool>( "help|?" )
- - (cla::prefix = "--|-",cla::separator = "=",cla::guess_name,cla::optional,
- cla::description = "this help message")
- ;
-
- s_cla_parser.parse( argc, argv );
-
- if( s_cla_parser["help"] ) {
- s_cla_parser.help( std::cout );
- BOOST_TEST_IMPL_THROW( framework::nothing_to_test() );
+ rt::option auto_start_dbg( AUTO_START_DBG, (
+ rt::description = "Automatically attaches debugger in case of system level failure (signal).",
+ rt::env_var = "BOOST_TEST_AUTO_START_DBG",
+
+ rt::help = "Option " + AUTO_START_DBG + " specifies whether Boost.Test should attempt "
+ "to attach a debugger when fatal system error occurs. At the moment this feature "
+ "is only available on a few selected platforms: Win32 and *nix. There is a "
+ "default debugger configured for these platforms. You can manually configure "
+ "different debugger. For more details on how to configure the debugger see the "
+ "Boost.Test debug API, specifically the function boost::debug::set_debugger."
+ ));
+
+ auto_start_dbg.add_cla_id( "--", AUTO_START_DBG, "=" );
+ auto_start_dbg.add_cla_id( "-", "d", " " );
+ store.add( auto_start_dbg );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<std::string> break_exec_path( BREAK_EXEC_PATH, (
+ rt::description = "For the exception safety testing allows to break at specific execution path.",
+ rt::env_var = "BOOST_TEST_BREAK_EXEC_PATH"
+#ifndef BOOST_NO_CXX11_LAMBDAS
+ ,
+ rt::callback = [](rt::cstring) {
+ BOOST_TEST_SETUP_ASSERT( false, "parameter break_exec_path is disabled in this release" );
}
+#endif
+ ));
- s_report_format = retrieve_parameter( REPORT_FORMAT, s_cla_parser, unit_test::OF_CLF );
- s_log_format = retrieve_parameter( LOG_FORMAT, s_cla_parser, unit_test::OF_CLF );
-
- unit_test::output_format of = retrieve_parameter( OUTPUT_FORMAT, s_cla_parser, unit_test::OF_INVALID );
-
- if( of != unit_test::OF_INVALID )
- s_report_format = s_log_format = of;
-
- s_test_to_run = retrieve_parameter<std::list<std::string> >( TESTS_TO_RUN, s_cla_parser );
- }
- 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 );
-
- BOOST_TEST_SETUP_ASSERT( false, err.str() );
- }
-}
-
-//____________________________________________________________________________//
-
-unit_test::log_level
-log_level()
-{
- return retrieve_parameter( LOG_LEVEL, s_cla_parser, unit_test::log_all_errors );
-}
-
-//____________________________________________________________________________//
-
-bool
-no_result_code()
-{
- return !retrieve_parameter( RESULT_CODE, s_cla_parser, true );
-}
-
-//____________________________________________________________________________//
-
-unit_test::report_level
-report_level()
-{
- return retrieve_parameter( REPORT_LEVEL, s_cla_parser, unit_test::CONFIRMATION_REPORT );
-}
-
-//____________________________________________________________________________//
-
-std::list<std::string> const&
-test_to_run()
-{
- return s_test_to_run;
-}
-
-//____________________________________________________________________________//
-
-const_string
-break_exec_path()
-{
- static std::string s_break_exec_path = retrieve_parameter( BREAK_EXEC_PATH, s_cla_parser, s_empty );
-
- return s_break_exec_path;
-}
-
-//____________________________________________________________________________//
-
-bool
-save_pattern()
-{
- return retrieve_parameter( SAVE_TEST_PATTERN, s_cla_parser, false );
-}
-
-//____________________________________________________________________________//
-
-bool
-show_progress()
-{
- return retrieve_parameter( SHOW_PROGRESS, s_cla_parser, false );
-}
-
-//____________________________________________________________________________//
-
-bool
-show_build_info()
-{
- return retrieve_parameter( BUILD_INFO, s_cla_parser, false );
-}
-
-//____________________________________________________________________________//
+ break_exec_path.add_cla_id( "--", BREAK_EXEC_PATH, "=" );
+ store.add( break_exec_path );
-output_format
-list_content()
-{
- return retrieve_parameter( LIST_CONTENT, s_cla_parser, unit_test::OF_INVALID, unit_test::OF_CLF );
-}
+ rt::option build_info( BUILD_INFO, (
+ rt::description = "Displays library build information.",
+ rt::env_var = "BOOST_TEST_BUILD_INFO",
+ rt::help = "Option " + BUILD_INFO + " displays library build information, including: platform, "
+ "compiler, STL version and Boost version."
+ ));
-//____________________________________________________________________________//
+ ///////////////////////////////////////////////
-bool
-list_labels()
-{
- return retrieve_parameter( LIST_LABELS, s_cla_parser, false );
-}
+ build_info.add_cla_id( "--", BUILD_INFO, "=" );
+ build_info.add_cla_id( "-", "i", " " );
+ store.add( build_info );
-//____________________________________________________________________________//
-bool
-catch_sys_errors()
-{
- return retrieve_parameter( CATCH_SYS_ERRORS, s_cla_parser,
+ rt::option catch_sys_errors( CATCH_SYS_ERRORS, (
+ rt::description = "Allows to switch between catching and ignoring system errors (signals).",
+ rt::env_var = "BOOST_TEST_CATCH_SYSTEM_ERRORS",
+ rt::default_value =
#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
- false
+ false,
#else
- true
+ true,
#endif
- );
-}
-
-//____________________________________________________________________________//
-
-bool
-color_output()
-{
- return retrieve_parameter( COLOR_OUTPUT, s_cla_parser, false );
-}
-
-//____________________________________________________________________________//
-
-bool
-auto_start_dbg()
-{
- // !! ?? set debugger as an option
- return retrieve_parameter( AUTO_START_DBG, s_cla_parser, false );
-;
-}
-
-//____________________________________________________________________________//
-
-bool
-wait_for_debugger()
-{
- return retrieve_parameter( WAIT_FOR_DEBUGGER, s_cla_parser, false );
-}
-
-//____________________________________________________________________________//
-
-bool
-use_alt_stack()
-{
- return retrieve_parameter( USE_ALT_STACK, s_cla_parser, true );
-}
-
-//____________________________________________________________________________//
-
-bool
-detect_fp_exceptions()
-{
- return retrieve_parameter( DETECT_FP_EXCEPT, s_cla_parser, false );
+ rt::help = "If option " + CATCH_SYS_ERRORS + " has value no the frameworks does not attempt to catch "
+ "asynchronous system failure events (signals on *NIX platforms or structured exceptions on Windows). "
+ " Default value is "
+#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
+ "no."
+#else
+ "true."
+#endif
+ ));
+
+ catch_sys_errors.add_cla_id( "--", CATCH_SYS_ERRORS, "=", true );
+ catch_sys_errors.add_cla_id( "-", "s", " " );
+ store.add( catch_sys_errors );
+
+ ///////////////////////////////////////////////
+
+ rt::option color_output( COLOR_OUTPUT, (
+ rt::description = "Enables color output of the framework log and report messages.",
+ rt::env_var = "BOOST_TEST_COLOR_OUTPUT",
+ rt::help = "The framework is able to produce color output on systems which supports it. "
+ "To enable this behavior set this option to yes. By default the framework "
+ "does not produces color output."
+ ));
+
+ color_output.add_cla_id( "--", COLOR_OUTPUT, "=", true );
+ color_output.add_cla_id( "-", "x", " " );
+ store.add( color_output );
+
+ ///////////////////////////////////////////////
+
+ rt::option detect_fp_except( DETECT_FP_EXCEPT, (
+ rt::description = "Enables/disables floating point exceptions traps.",
+ rt::env_var = "BOOST_TEST_DETECT_FP_EXCEPTIONS",
+ rt::help = "Option " + DETECT_FP_EXCEPT + " enables/disables hardware traps for the floating "
+ "point exceptions (if supported on your platfrom)."
+ ));
+
+ detect_fp_except.add_cla_id( "--", DETECT_FP_EXCEPT, "=", true );
+ store.add( detect_fp_except );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<unsigned long> detect_mem_leaks( DETECT_MEM_LEAKS, (
+ rt::description = "Turns on/off memory leaks detection (optionally breaking on specified alloc order number).",
+ rt::env_var = "BOOST_TEST_DETECT_MEMORY_LEAK",
+ rt::default_value = 1L,
+ rt::optional_value = 1L,
+ rt::value_hint = "<alloc order number>",
+ rt::help = "Parameter " + DETECT_MEM_LEAKS + " enables/disables memory leaks detection. "
+ "This parameter has optional long integer value. The default value is 1, which "
+ "enables the memory leak detection. The value 0 disables memory leak detection. "
+ "Any value N greater than 1 is treated as leak allocation number and tells the "
+ "framework to setup runtime breakpoint at Nth heap allocation. If value is "
+ "omitted the default value is assumed."
+ ));
+
+ detect_mem_leaks.add_cla_id( "--", DETECT_MEM_LEAKS, "=" );
+ store.add( detect_mem_leaks );
+
+ ///////////////////////////////////////////////
+
+ rt::enum_parameter<unit_test::output_format> list_content( LIST_CONTENT, (
+ rt::description = "Lists the content of test tree - names of all test suites and test cases.",
+ rt::env_var = "BOOST_TEST_LIST_CONTENT",
+ rt::default_value = OF_INVALID,
+ rt::optional_value = OF_CLF,
+ rt::enum_values<unit_test::output_format>::value =
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ { "HRF", OF_CLF },
+ { "DOT", OF_DOT }
+ },
+#else
+ rt::enum_values_list<unit_test::output_format>()
+ ( "HRF", OF_CLF )
+ ( "DOT", OF_DOT )
+ ,
+#endif
+ rt::help = "Parameter " + LIST_CONTENT + " instructs the framework to list the content "
+ "of the test module instead of executing the test cases. Parameter accepts "
+ "optional string value indicating the format of the output. Currently the "
+ "framework supports two formats: human readable format (HRF) and dot graph "
+ "format (DOT). If value is omitted HRF value is assumed."
+ ));
+ list_content.add_cla_id( "--", LIST_CONTENT, "=" );
+ store.add( list_content );
+
+ ///////////////////////////////////////////////
+
+ rt::option list_labels( LIST_LABELS, (
+ rt::description = "Lists all available labels.",
+ rt::env_var = "BOOST_TEST_LIST_LABELS",
+ rt::help = "Option " + LIST_LABELS + " instructs the framework to list all the the labels "
+ "defined in the test module instead of executing the test cases."
+ ));
+
+ list_labels.add_cla_id( "--", LIST_LABELS, "=" );
+ store.add( list_labels );
+
+ ///////////////////////////////////////////////
+
+ rt::enum_parameter<unit_test::output_format> log_format( LOG_FORMAT, (
+ rt::description = "Specifies log format.",
+ rt::env_var = "BOOST_TEST_LOG_FORMAT",
+ rt::default_value = OF_CLF,
+ rt::enum_values<unit_test::output_format>::value =
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ { "HRF", OF_CLF },
+ { "CLF", OF_CLF },
+ { "XML", OF_XML }
+ },
+#else
+ rt::enum_values_list<unit_test::output_format>()
+ ( "HRF", OF_CLF )
+ ( "CLF", OF_CLF )
+ ( "XML", OF_XML )
+ ,
+#endif
+ rt::help = "Parameter " + LOG_FORMAT + " allows to set the frameowrk's log format to one "
+ "of the formats supplied by the framework. The only acceptable values for this "
+ "parameter are the names of the output formats supplied by the framework. By "
+ "default the framework uses human readable format (HRF) for testing log. This "
+ "format is similar to compiler error format. Alternatively you can specify XML "
+ "as log format. This format is easier to process by testing automation tools."
+ ));
+
+ log_format.add_cla_id( "--", LOG_FORMAT, "=" );
+ log_format.add_cla_id( "-", "f", " " );
+ store.add( log_format );
+
+ ///////////////////////////////////////////////
+
+ rt::enum_parameter<unit_test::log_level> log_level( LOG_LEVEL, (
+ rt::description = "Specifies log level.",
+ rt::env_var = "BOOST_TEST_LOG_LEVEL",
+ rt::default_value = log_all_errors,
+ rt::enum_values<unit_test::log_level>::value =
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ { "all" , log_successful_tests },
+ { "success" , log_successful_tests },
+ { "test_suite" , log_test_units },
+ { "unit_scope" , log_test_units },
+ { "message" , log_messages },
+ { "warning" , log_warnings },
+ { "error" , log_all_errors },
+ { "cpp_exception" , log_cpp_exception_errors },
+ { "system_error" , log_system_errors },
+ { "fatal_error" , log_fatal_errors },
+ { "nothing" , log_nothing }
+ },
+#else
+ rt::enum_values_list<unit_test::log_level>()
+ ( "all" , log_successful_tests )
+ ( "success" , log_successful_tests )
+ ( "test_suite" , log_test_units )
+ ( "unit_scope" , log_test_units )
+ ( "message" , log_messages )
+ ( "warning" , log_warnings )
+ ( "error" , log_all_errors )
+ ( "cpp_exception" , log_cpp_exception_errors )
+ ( "system_error" , log_system_errors )
+ ( "fatal_error" , log_fatal_errors )
+ ( "nothing" , log_nothing )
+ ,
+#endif
+ rt::help = "Parameter " + LOG_LEVEL + " allows to set the framework's log level. "
+ "Log level defines the verbosity of testing log produced by a testing "
+ "module. The verbosity ranges from a complete log, when all assertions "
+ "(both successful and failing) are reported, all notifications about "
+ "test units start and finish are included, to an empty log when nothing "
+ "is reported to a testing log stream."
+ ));
+
+ log_level.add_cla_id( "--", LOG_LEVEL, "=" );
+ log_level.add_cla_id( "-", "l", " " );
+ store.add( log_level );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<std::string> log_sink( LOG_SINK, (
+ rt::description = "Specifies log sink: stdout(default), stderr or file name.",
+ rt::env_var = "BOOST_TEST_LOG_SINK",
+ rt::value_hint = "<stderr|stdout|file name>",
+ rt::help = "Parameter " + LOG_SINK + " allows to set the log sink - location "
+ "where we report the log to, thus it allows to easily redirect the "
+ "test logs to file or standard streams. By default testing log is "
+ "directed to standard output."
+ ));
+
+ log_sink.add_cla_id( "--", LOG_SINK, "=" );
+ log_sink.add_cla_id( "-", "k", " " );
+ store.add( log_sink );
+
+ ///////////////////////////////////////////////
+
+ rt::enum_parameter<unit_test::output_format> output_format( OUTPUT_FORMAT, (
+ rt::description = "Specifies output format (both log and report).",
+ rt::env_var = "BOOST_TEST_OUTPUT_FORMAT",
+ rt::enum_values<unit_test::output_format>::value =
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ { "HRF", OF_CLF },
+ { "CLF", OF_CLF },
+ { "XML", OF_XML }
+ },
+#else
+ rt::enum_values_list<unit_test::output_format>()
+ ( "HRF", OF_CLF )
+ ( "CLF", OF_CLF )
+ ( "XML", OF_XML )
+ ,
+#endif
+ rt::help = "Parameter " + OUTPUT_FORMAT + " combines an effect of " + REPORT_FORMAT +
+ " and " + LOG_FORMAT + " parameters. This parameter has higher priority "
+ "than either one of them. In other words if this parameter is specified "
+ "it overrides the value of other two parameters. This parameter does not "
+ "have a default value. The only acceptable values are string names of "
+ "output formats: HRF - human readable format and XML - XML formats for "
+ "automation tools processing."
+ ));
+
+ output_format.add_cla_id( "--", OUTPUT_FORMAT, "=" );
+ output_format.add_cla_id( "-", "o", " " );
+ store.add( output_format );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<unsigned> random_seed( RANDOM_SEED, (
+ rt::description = "Allows to switch between sequential and random order of test units execution."
+ " Optionally allows to specify concrete seed for random number generator.",
+ rt::env_var = "BOOST_TEST_RANDOM",
+ rt::default_value = 0U,
+ rt::optional_value = 1U,
+ rt::value_hint = "<seed>",
+ rt::help = "Parameter " + RANDOM_SEED + " instructs the framework to execute the "
+ "test cases in random order. This parameter accepts optional unsigned "
+ "integer argument. By default test cases are executed in some specific "
+ "order defined by order of test units in test files and dependency between "
+ "test units. If parameter is specified without the argument value testing "
+ "order is randomized based on current time. Alternatively you can specify "
+ "any positive value greater than 1 and it will be used as random seed for "
+ "the run."
+ ));
+
+ random_seed.add_cla_id( "--", RANDOM_SEED, "=" );
+ store.add( random_seed );
+
+ ///////////////////////////////////////////////
+
+ rt::enum_parameter<unit_test::output_format> report_format( REPORT_FORMAT, (
+ rt::description = "Specifies report format.",
+ rt::env_var = "BOOST_TEST_REPORT_FORMAT",
+ rt::default_value = OF_CLF,
+ rt::enum_values<unit_test::output_format>::value =
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ { "HRF", OF_CLF },
+ { "CLF", OF_CLF },
+ { "XML", OF_XML }
+ },
+#else
+ rt::enum_values_list<unit_test::output_format>()
+ ( "HRF", OF_CLF )
+ ( "CLF", OF_CLF )
+ ( "XML", OF_XML )
+ ,
+#endif
+ rt::help = "Parameter " + REPORT_FORMAT + " allows to set the framework's report format "
+ "to one of the formats supplied by the framework. The only acceptable values "
+ "for this parameter are the names of the output formats. By default the framework "
+ "uses human readable format (HRF) for results reporting. Alternatively you can "
+ "specify XML as report format. This format is easier to process by testing "
+ "automation tools."
+ ));
+
+ report_format.add_cla_id( "--", REPORT_FORMAT, "=" );
+ report_format.add_cla_id( "-", "m", " " );
+ store.add( report_format );
+
+ ///////////////////////////////////////////////
+
+ rt::enum_parameter<unit_test::report_level> report_level( REPORT_LEVEL, (
+ rt::description = "Specifies report level.",
+ rt::env_var = "BOOST_TEST_REPORT_LEVEL",
+ rt::default_value = CONFIRMATION_REPORT,
+ rt::enum_values<unit_test::report_level>::value =
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ {
+ { "confirm", CONFIRMATION_REPORT },
+ { "short", SHORT_REPORT },
+ { "detailed", DETAILED_REPORT },
+ { "no", NO_REPORT }
+ },
+#else
+ rt::enum_values_list<unit_test::report_level>()
+ ( "confirm", CONFIRMATION_REPORT )
+ ( "short", SHORT_REPORT )
+ ( "detailed", DETAILED_REPORT )
+ ( "no", NO_REPORT )
+ ,
+#endif
+ rt::help = "Parameter " + REPORT_LEVEL + " allows to set the verbosity level of the "
+ "testing result report generated by the framework. Use value 'no' to "
+ "eliminate the results report completely."
+ ));
+
+ report_level.add_cla_id( "--", REPORT_LEVEL, "=" );
+ report_level.add_cla_id( "-", "r", " " );
+ store.add( report_level );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<std::string> report_mem_leaks( REPORT_MEM_LEAKS, (
+ rt::description = "File where to report memory leaks to.",
+ rt::env_var = "BOOST_TEST_REPORT_MEMORY_LEAKS_TO",
+ rt::default_value = std::string(),
+ rt::value_hint = "<file name>",
+ rt::help = "Parameter " + REPORT_MEM_LEAKS + " allows to specify a file where to report "
+ "memory leaks to. The parameter does not have default value. If it is not specified, "
+ "memory leaks (if any) are reported to the standard error stream."
+ ));
+
+ report_mem_leaks.add_cla_id( "--", REPORT_MEM_LEAKS, "=" );
+ store.add( report_mem_leaks );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<std::string> report_sink( REPORT_SINK, (
+ rt::description = "Specifies report sink: stderr(default), stdout or file name.",
+ rt::env_var = "BOOST_TEST_REPORT_SINK",
+ rt::value_hint = "<stderr|stdout|file name>",
+ rt::help = "Parameter " + REPORT_SINK + " allows to set the result report sink - "
+ "the location where the framework writes the result report to, thus it "
+ "allows to easily redirect the result report to a file or a standard "
+ "stream. By default the testing result report is directed to the "
+ "standard error stream."
+ ));
+
+ report_sink.add_cla_id( "--", REPORT_SINK, "=" );
+ report_sink.add_cla_id( "-", "e", " " );
+ store.add( report_sink );
+
+ ///////////////////////////////////////////////
+
+ rt::option result_code( RESULT_CODE, (
+ rt::description = "Disables test modules's result code generation.",
+ rt::env_var = "BOOST_TEST_RESULT_CODE",
+ rt::default_value = true,
+ rt::help = "The 'no' argument value for the parameter " + RESULT_CODE + " instructs the "
+ "framework to always return zero result code. This can be used for test programs "
+ "executed within IDE. By default this parameter has value 'yes'."
+ ));
+
+ result_code.add_cla_id( "--", RESULT_CODE, "=", true );
+ result_code.add_cla_id( "-", "c", " " );
+ store.add( result_code );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<std::string,rt::REPEATABLE_PARAM> tests_to_run( RUN_FILTERS, (
+ rt::description = "Filters, which test units to include or exclude from test module execution.",
+ rt::env_var = "BOOST_TEST_RUN_FILTERS",
+ rt::value_hint = "<test unit filter>",
+ rt::help = "Parameter " + RUN_FILTERS + " allows to filter which test units to execute during "
+ "testing. The framework supports both 'selection filters', which allow to select "
+ "which test units to enable from the set of available test units, and 'disabler "
+ "filters', which allow to disable some test units. The __UTF__ also supports "
+ "enabling/disabling test units at compile time. These settings identify the default "
+ "set of test units to run. Parameter " + RUN_FILTERS + " is used to change this default. "
+ "This parameter is repeatable, so you can specify more than one filter if necessary."
+ ));
+
+ tests_to_run.add_cla_id( "--", RUN_FILTERS, "=" );
+ tests_to_run.add_cla_id( "-", "t", " " );
+ store.add( tests_to_run );
+
+ ///////////////////////////////////////////////
+
+ rt::option save_test_pattern( SAVE_TEST_PATTERN, (
+ rt::description = "Allows to switch between saving or matching test pattern file.",
+ rt::env_var = "BOOST_TEST_SAVE_PATTERN",
+ rt::help = "Parameter " + SAVE_TEST_PATTERN + " facilitates switching mode of operation for "
+ "testing output streams.\n\nThis parameter serves no particular purpose within the "
+ "framework itself. It can be used by test modules relying on output_test_stream to "
+ "implement testing logic. Default mode is 'match' (false)."
+ ));
+
+ save_test_pattern.add_cla_id( "--", SAVE_TEST_PATTERN, "=" );
+ store.add( save_test_pattern );
+
+ ///////////////////////////////////////////////
+
+ rt::option show_progress( SHOW_PROGRESS, (
+ rt::description = "Turns on progress display.",
+ rt::env_var = "BOOST_TEST_SHOW_PROGRESS",
+ rt::help = "Parameter " + SHOW_PROGRESS + " instructs the framework to display test progress "
+ "information. By default the test progress is not shown."
+ ));
+
+ show_progress.add_cla_id( "--", SHOW_PROGRESS, "=" );
+ show_progress.add_cla_id( "-", "p", " " );
+ store.add( show_progress );
+
+ ///////////////////////////////////////////////
+
+ rt::option use_alt_stack( USE_ALT_STACK, (
+ rt::description = "Turns on/off usage of an alternative stack for signal handling.",
+ rt::env_var = "BOOST_TEST_USE_ALT_STACK",
+ rt::default_value = true,
+ rt::help = "Parameter " + USE_ALT_STACK + " instructs the framework to use alternative "
+ "stack for signals processing, on platforms where they are supported. The feature "
+ "is enabled by default, but can be disabled using this parameter."
+ ));
+
+ use_alt_stack.add_cla_id( "--", USE_ALT_STACK, "=", true );
+ store.add( use_alt_stack );
+
+ ///////////////////////////////////////////////
+
+ rt::option wait_for_debugger( WAIT_FOR_DEBUGGER, (
+ rt::description = "Forces test module to wait for button to be pressed before starting test run.",
+ rt::env_var = "BOOST_TEST_WAIT_FOR_DEBUGGER",
+ rt::help = "Parameter " + WAIT_FOR_DEBUGGER + " instructs the framework to pause before starting "
+ "test units execution, so that you can attach a debugger to running test module. By "
+ "default this parameters turned off."
+ ));
+
+ wait_for_debugger.add_cla_id( "--", WAIT_FOR_DEBUGGER, "=" );
+ wait_for_debugger.add_cla_id( "-", "w", " " );
+ store.add( wait_for_debugger );
+
+ ///////////////////////////////////////////////
+
+ rt::parameter<std::string> help( HELP, (
+ rt::description = "Help for framework parameters.",
+ rt::optional_value = std::string(),
+ rt::value_hint = "<parameter name>",
+ rt::help = "Parameter " + HELP + " displays help on the framework's parameters. "
+ "The parameter accepts an optional argument value. If present, an argument value is "
+ "interpreted as a parameter name (name guessing works as well, so for example "
+ "--help=rand displays help on the parameter random). If the parameter name is unknown "
+ "or ambiguous error is reported. If argument value is absent, a summary of all "
+ "framework's parameter is displayed."
+ ));
+ help.add_cla_id( "--", HELP, "=" );
+ store.add( help );
+
+ ///////////////////////////////////////////////
+
+ rt::option usage( USAGE, (
+ rt::description = "Short message explaining usage of Boost.Test parameters."
+ ));
+ usage.add_cla_id( "-", "?", " " );
+ store.add( usage );
}
-//____________________________________________________________________________//
-
-output_format
-report_format()
-{
- return s_report_format;
-}
+static rt::arguments_store s_arguments_store;
+static rt::parameters_store s_parameters_store;
//____________________________________________________________________________//
-output_format
-log_format()
-{
- return s_log_format;
-}
-
-//____________________________________________________________________________//
+} // local namespace
-std::ostream*
-report_sink()
+void
+init( int& argc, char** argv )
{
- std::string sink_name = retrieve_parameter( REPORT_SINK, s_cla_parser, s_empty );
+ shared_ptr<rt::cla::parser> parser;
- if( sink_name.empty() || sink_name == "stderr" )
- return &std::cerr;
+ BOOST_TEST_I_TRY {
+ // Initialize parameters list
+ if( s_parameters_store.is_empty() )
+ register_parameters( s_parameters_store );
- if( sink_name == "stdout" )
- return &std::cout;
+ // Clear up arguments store just in case (of multiple init invocations)
+ s_arguments_store.clear();
- static std::ofstream report_file( sink_name.c_str() );
- return &report_file;
-}
+ // Parse CLA they take precedence over environment
+ parser.reset( new rt::cla::parser( s_parameters_store, (rt::end_of_params = "--", rt::negation_prefix = "no_") ) );
+ argc = parser->parse( argc, argv, s_arguments_store );
-//____________________________________________________________________________//
-
-std::ostream*
-log_sink()
-{
- std::string sink_name = retrieve_parameter( LOG_SINK, s_cla_parser, s_empty );
+ // Try to fetch missing arguments from environment
+ rt::env::fetch_absent( s_parameters_store, s_arguments_store );
- if( sink_name.empty() || sink_name == "stdout" )
- return &std::cout;
+ // Set arguments to default values if defined and perform all the validations
+ rt::finalize_arguments( s_parameters_store, s_arguments_store );
- if( sink_name == "stderr" )
- return &std::cerr;
-
- static std::ofstream log_file( sink_name.c_str() );
- return &log_file;
-}
+ // Report help if requested
+ if( runtime_config::get<bool>( USAGE ) ) {
+ parser->usage( std::cerr );
+ BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
+ }
+ else if( s_arguments_store.has( HELP ) ) {
+ parser->help( std::cerr, s_parameters_store, runtime_config::get<std::string>( HELP ) );
+ BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_success ) );
+ }
-//____________________________________________________________________________//
+ // A bit of business logic: output_format takes precedence over log/report formats
+ if( s_arguments_store.has( OUTPUT_FORMAT ) ) {
+ unit_test::output_format of = s_arguments_store.get<unit_test::output_format>( OUTPUT_FORMAT );
+ s_arguments_store.set( REPORT_FORMAT, of );
+ s_arguments_store.set( LOG_FORMAT, of );
+ }
+ }
+ BOOST_TEST_I_CATCH( rt::init_error, ex ) {
+ BOOST_TEST_SETUP_ASSERT( false, ex.msg );
+ }
+ BOOST_TEST_I_CATCH( rt::ambiguous_param, ex ) {
+ std::cerr << ex.msg << "\n Did you mean one of these?\n";
-long
-detect_memory_leaks()
-{
- static long s_value = -1;
+ BOOST_TEST_FOREACH( rt::cstring, name, ex.m_amb_candidates )
+ std::cerr << " " << name << "\n";
- if( s_value >= 0 )
- return s_value;
+ BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_exception_failure ) );
+ }
+ BOOST_TEST_I_CATCH( rt::unrecognized_param, ex ) {
+ std::cerr << ex.msg << "\n";
- std::string value = retrieve_parameter( DETECT_MEM_LEAKS, s_cla_parser, s_empty );
+ if( !ex.m_typo_candidates.empty() ) {
+ std::cerr << " Did you mean one of these?\n";
- optional<bool> bool_val;
- if( runtime::interpret_argument_value_impl<bool>::_( value, bool_val ) )
- s_value = *bool_val ? 1L : 0L;
- else {
- BOOST_TEST_IMPL_TRY {
- // if representable as long - this is leak number
- s_value = boost::lexical_cast<long>( value );
+ BOOST_TEST_FOREACH( rt::cstring, name, ex.m_typo_candidates )
+ std::cerr << " " << name << "\n";
}
- BOOST_TEST_IMPL_CATCH0( boost::bad_lexical_cast ) {
- // value is leak report file and detection is enabled
- s_value = 1L;
+ else if( parser ) {
+ std::cerr << "\n";
+ parser->usage( std::cerr );
}
+
+ BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_exception_failure ) );
}
+ BOOST_TEST_I_CATCH( rt::input_error, ex ) {
+ std::cerr << ex.msg << "\n\n";
- return s_value;
+ if( parser )
+ parser->usage( std::cerr, ex.param_name );
+
+ BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_exception_failure ) );
+ }
}
//____________________________________________________________________________//
-const_string
-memory_leaks_report_file()
+rt::arguments_store const&
+argument_store()
{
- if( detect_memory_leaks() != 1 )
- return const_string();
-
- static std::string s_value;
-
- if( s_value.empty() ) {
- s_value = retrieve_parameter<std::string>( DETECT_MEM_LEAKS, s_cla_parser );
-
- optional<bool> bool_val;
- if( runtime::interpret_argument_value_impl<bool>::_( s_value, bool_val ) )
- s_value.clear();
- }
-
- return s_value;
+ return s_arguments_store;
}
//____________________________________________________________________________//
-unsigned
-random_seed()
+bool
+save_pattern()
{
- return retrieve_parameter( RANDOM_SEED, s_cla_parser, 0U, 1U );
+ return runtime_config::get<bool>( SAVE_TEST_PATTERN );
}
//____________________________________________________________________________//
diff --git a/boost/test/impl/xml_log_formatter.ipp b/boost/test/impl/xml_log_formatter.ipp
index 286cd60005..81284020dd 100644
--- a/boost/test/impl/xml_log_formatter.ipp
+++ b/boost/test/impl/xml_log_formatter.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -66,9 +66,9 @@ void
xml_log_formatter::log_build_info( std::ostream& ostr )
{
ostr << "<BuildInfo"
- << " platform" << attr_value() << BOOST_PLATFORM
- << " compiler" << attr_value() << BOOST_COMPILER
- << " stl" << attr_value() << BOOST_STDLIB
+ << " platform" << utils::attr_value() << BOOST_PLATFORM
+ << " compiler" << utils::attr_value() << BOOST_COMPILER
+ << " stl" << utils::attr_value() << BOOST_STDLIB
<< " boost=\"" << BOOST_VERSION/100000 << "."
<< BOOST_VERSION/100 % 1000 << "."
<< BOOST_VERSION % 100 << '\"'
@@ -80,11 +80,11 @@ xml_log_formatter::log_build_info( std::ostream& ostr )
void
xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu )
{
- ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get();
+ ostr << "<" << tu_type_name( tu ) << " name" << utils::attr_value() << tu.p_name.get();
- if( !tu.p_file_name.get().empty() )
- ostr << BOOST_TEST_L( " file" ) << attr_value() << tu.p_file_name
- << BOOST_TEST_L( " line" ) << attr_value() << tu.p_line_num;
+ if( !tu.p_file_name.empty() )
+ ostr << BOOST_TEST_L( " file" ) << utils::attr_value() << tu.p_file_name
+ << BOOST_TEST_L( " line" ) << utils::attr_value() << tu.p_line_num;
ostr << ">";
}
@@ -106,9 +106,9 @@ void
xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu, const_string reason )
{
ostr << "<" << tu_type_name( tu )
- << " name" << attr_value() << tu.p_name.get()
- << " skipped" << attr_value() << "yes"
- << " reason" << attr_value() << reason
+ << " name" << utils::attr_value() << tu.p_name
+ << " skipped" << utils::attr_value() << "yes"
+ << " reason" << utils::attr_value() << reason
<< "/>";
}
@@ -119,19 +119,19 @@ xml_log_formatter::log_exception_start( std::ostream& ostr, log_checkpoint_data
{
execution_exception::location const& loc = ex.where();
- ostr << "<Exception file" << attr_value() << loc.m_file_name
- << " line" << attr_value() << loc.m_line_num;
+ ostr << "<Exception file" << utils::attr_value() << loc.m_file_name
+ << " line" << utils::attr_value() << loc.m_line_num;
if( !loc.m_function.is_empty() )
- ostr << " function" << attr_value() << loc.m_function;
+ ostr << " function" << utils::attr_value() << loc.m_function;
- ostr << ">" << cdata() << ex.what();
+ ostr << ">" << utils::cdata() << ex.what();
if( !checkpoint_data.m_file_name.is_empty() ) {
- ostr << "<LastCheckpoint file" << attr_value() << checkpoint_data.m_file_name
- << " line" << attr_value() << checkpoint_data.m_line_num
+ ostr << "<LastCheckpoint file" << utils::attr_value() << checkpoint_data.m_file_name
+ << " line" << utils::attr_value() << checkpoint_data.m_line_num
<< ">"
- << cdata() << checkpoint_data.m_message
+ << utils::cdata() << checkpoint_data.m_message
<< "</LastCheckpoint>";
}
}
@@ -153,8 +153,8 @@ xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& en
m_curr_tag = xml_tags[let];
ostr << '<' << m_curr_tag
- << BOOST_TEST_L( " file" ) << attr_value() << entry_data.m_file_name
- << BOOST_TEST_L( " line" ) << attr_value() << entry_data.m_line_num
+ << BOOST_TEST_L( " file" ) << utils::attr_value() << entry_data.m_file_name
+ << BOOST_TEST_L( " line" ) << utils::attr_value() << entry_data.m_line_num
<< BOOST_TEST_L( "><![CDATA[" );
m_value_closed = false;
@@ -165,7 +165,7 @@ xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& en
void
xml_log_formatter::log_entry_value( std::ostream& ostr, const_string value )
{
- print_escaped_cdata( ostr, value );
+ utils::print_escaped_cdata( ostr, value );
}
//____________________________________________________________________________//
@@ -194,7 +194,6 @@ xml_log_formatter::entry_context_start( std::ostream& ostr, log_level )
}
ostr << BOOST_TEST_L( "<Context>" );
-
}
//____________________________________________________________________________//
@@ -210,7 +209,7 @@ xml_log_formatter::entry_context_finish( std::ostream& ostr )
void
xml_log_formatter::log_entry_context( std::ostream& ostr, const_string context_descr )
{
- ostr << BOOST_TEST_L( "<Frame>" ) << cdata() << context_descr << BOOST_TEST_L( "</Frame>" );
+ ostr << BOOST_TEST_L( "<Frame>" ) << utils::cdata() << context_descr << BOOST_TEST_L( "</Frame>" );
}
//____________________________________________________________________________//
diff --git a/boost/test/impl/xml_report_formatter.ipp b/boost/test/impl/xml_report_formatter.ipp
index 5606fdc0b1..08af9a3427 100644
--- a/boost/test/impl/xml_report_formatter.ipp
+++ b/boost/test/impl/xml_report_formatter.ipp
@@ -1,4 +1,4 @@
-// (C) Copyright Gennadiy Rozental 2005-2014.
+// (C) Copyright Gennadiy Rozental 2001.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
@@ -65,22 +65,21 @@ xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream&
descr = "failed";
ostr << '<' << ( tu.p_type == TUT_CASE ? "TestCase" : "TestSuite" )
- << " name" << attr_value() << tu.p_name.get()
- << " result" << attr_value() << descr
- << " assertions_passed" << attr_value() << tr.p_assertions_passed
- << " assertions_failed" << attr_value() << tr.p_assertions_failed
- << " warnings_failed" << attr_value() << tr.p_warnings_failed
- << " expected_failures" << attr_value() << tr.p_expected_failures;
+ << " name" << utils::attr_value() << tu.p_name
+ << " result" << utils::attr_value() << descr
+ << " assertions_passed" << utils::attr_value() << tr.p_assertions_passed
+ << " assertions_failed" << utils::attr_value() << tr.p_assertions_failed
+ << " warnings_failed" << utils::attr_value() << tr.p_warnings_failed
+ << " expected_failures" << utils::attr_value() << tr.p_expected_failures;
if( tu.p_type == TUT_SUITE ) {
- ostr << " test_cases_passed" << attr_value() << tr.p_test_cases_passed
- << " test_cases_passed_with_warnings" << attr_value() << tr.p_test_cases_warned
- << " test_cases_failed" << attr_value() << tr.p_test_cases_failed
- << " test_cases_skipped" << attr_value() << tr.p_test_cases_skipped
- << " test_cases_aborted" << attr_value() << tr.p_test_cases_aborted;
+ ostr << " test_cases_passed" << utils::attr_value() << tr.p_test_cases_passed
+ << " test_cases_passed_with_warnings" << utils::attr_value() << tr.p_test_cases_warned
+ << " test_cases_failed" << utils::attr_value() << tr.p_test_cases_failed
+ << " test_cases_skipped" << utils::attr_value() << tr.p_test_cases_skipped
+ << " test_cases_aborted" << utils::attr_value() << tr.p_test_cases_aborted;
}
-
ostr << '>';
}