|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50358 - in trunk/boost/test: . detail impl
From: gennadiy.rozental_at_[hidden]
Date: 2008-12-22 03:00:16
Author: rogeeff
Date: 2008-12-22 03:00:15 EST (Mon, 22 Dec 2008)
New Revision: 50358
URL: http://svn.boost.org/trac/boost/changeset/50358
Log:
Major update to the runtime parameters handling code
Text files modified:
trunk/boost/test/detail/global_typedef.hpp | 4
trunk/boost/test/detail/unit_test_parameters.hpp | 2
trunk/boost/test/framework.hpp | 4
trunk/boost/test/impl/framework.ipp | 21 -
trunk/boost/test/impl/unit_test_main.ipp | 5
trunk/boost/test/impl/unit_test_parameters.ipp | 432 +++++++++++++++++++++++----------------
6 files changed, 271 insertions(+), 197 deletions(-)
Modified: trunk/boost/test/detail/global_typedef.hpp
==============================================================================
--- trunk/boost/test/detail/global_typedef.hpp (original)
+++ trunk/boost/test/detail/global_typedef.hpp 2008-12-22 03:00:15 EST (Mon, 22 Dec 2008)
@@ -32,11 +32,11 @@
//____________________________________________________________________________//
-enum report_level { CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT, INV_REPORT_LEVEL };
+enum report_level { INV_REPORT_LEVEL, CONFIRMATION_REPORT, SHORT_REPORT, DETAILED_REPORT, NO_REPORT };
//____________________________________________________________________________//
-enum output_format { CLF /* compiler log format */, XML /* XML */ };
+enum output_format { INV_OF, CLF /* compiler log format */, XML /* XML */ };
//____________________________________________________________________________//
Modified: trunk/boost/test/detail/unit_test_parameters.hpp
==============================================================================
--- trunk/boost/test/detail/unit_test_parameters.hpp (original)
+++ trunk/boost/test/detail/unit_test_parameters.hpp 2008-12-22 03:00:15 EST (Mon, 22 Dec 2008)
@@ -32,7 +32,7 @@
namespace runtime_config {
-void BOOST_TEST_DECL init( int* argc, char** argv );
+void BOOST_TEST_DECL init( int& argc, char** argv );
unit_test::log_level BOOST_TEST_DECL log_level();
bool BOOST_TEST_DECL no_result_code();
Modified: trunk/boost/test/framework.hpp
==============================================================================
--- trunk/boost/test/framework.hpp (original)
+++ trunk/boost/test/framework.hpp 2008-12-22 03:00:15 EST (Mon, 22 Dec 2008)
@@ -94,6 +94,10 @@
setup_error( const_string m ) : std::runtime_error( std::string( m.begin(), m.size() ) ) {}
};
+#define BOOST_TEST_SETUP_ASSERT( cond, msg ) if( cond ) {} else throw unit_test::framework::setup_error( msg )
+
+struct nothing_to_test {}; // not really an error
+
} // namespace framework
} // unit_test
Modified: trunk/boost/test/impl/framework.ipp
==============================================================================
--- trunk/boost/test/impl/framework.ipp (original)
+++ trunk/boost/test/impl/framework.ipp 2008-12-22 03:00:15 EST (Mon, 22 Dec 2008)
@@ -230,7 +230,7 @@
void
init( init_unit_test_func init_func, int argc, char* argv[] )
{
- runtime_config::init( &argc, argv );
+ runtime_config::init( argc, argv );
// set the log level and format
unit_test_log.set_threshold_level( runtime_config::log_level() );
@@ -282,13 +282,11 @@
void
register_test_unit( test_case* tc )
{
- if( tc->p_id != INV_TEST_UNIT_ID )
- throw setup_error( BOOST_TEST_L( "test case already registered" ) );
+ BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) );
test_unit_id new_id = s_frk_impl().m_next_test_case_id;
- if( new_id == MAX_TEST_CASE_ID )
- throw setup_error( BOOST_TEST_L( "too many test cases" ) );
+ BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) );
typedef framework_impl::test_unit_store::value_type map_value_type;
@@ -303,13 +301,11 @@
void
register_test_unit( test_suite* ts )
{
- if( ts->p_id != INV_TEST_UNIT_ID )
- throw setup_error( BOOST_TEST_L( "test suite already registered" ) );
+ BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) );
test_unit_id new_id = s_frk_impl().m_next_test_suite_id;
- if( new_id == MAX_TEST_SUITE_ID )
- throw setup_error( BOOST_TEST_L( "too many test suites" ) );
+ BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) );
typedef framework_impl::test_unit_store::value_type map_value_type;
s_frk_impl().m_test_units.insert( map_value_type( new_id, ts ) );
@@ -401,10 +397,9 @@
test_case_counter tcc;
traverse_test_tree( id, tcc );
- if( tcc.p_count == 0 )
- throw setup_error( runtime_config::test_to_run().is_empty()
- ? BOOST_TEST_L( "test tree is empty" )
- : BOOST_TEST_L( "no test cases matching filter" ) );
+ BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::test_to_run().is_empty()
+ ? BOOST_TEST_L( "test tree is empty" )
+ : BOOST_TEST_L( "no test cases matching filter" ) );
bool call_start_finish = !continue_test || !s_frk_impl().m_test_in_progress;
bool was_in_progress = s_frk_impl().m_test_in_progress;
Modified: trunk/boost/test/impl/unit_test_main.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_main.ipp (original)
+++ trunk/boost/test/impl/unit_test_main.ipp 2008-12-22 03:00:15 EST (Mon, 22 Dec 2008)
@@ -186,9 +186,12 @@
results_reporter::make_report();
return runtime_config::no_result_code()
- ? boost::exit_success
+ ? boost::exit_success
: results_collector.results( framework::master_test_suite().p_id ).result_code();
}
+ catch( framework::nothing_to_test const& ) {
+ return boost::exit_success;
+ }
catch( framework::internal_error const& ex ) {
results_reporter::get_stream() << "Boost.Test framework internal error: " << ex.what() << std::endl;
Modified: trunk/boost/test/impl/unit_test_parameters.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_parameters.ipp (original)
+++ trunk/boost/test/impl/unit_test_parameters.ipp 2008-12-22 03:00:15 EST (Mon, 22 Dec 2008)
@@ -25,6 +25,16 @@
#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>
+
+// Boost.Runtime.Param
+#include <boost/test/utils/runtime/cla/dual_name_parameter.hpp>
+#include <boost/test/utils/runtime/cla/parser.hpp>
+#include <boost/test/utils/runtime/env/variable.hpp>
+
+namespace rt = boost::runtime;
+namespace cla = rt::cla;
+namespace env = rt::env;
// Boost
#include <boost/config.hpp>
@@ -35,9 +45,11 @@
// STL
#include <map>
#include <cstdlib>
+#include <iostream>
#include <boost/test/detail/suppress_warnings.hpp>
+#include <Windows.h>
//____________________________________________________________________________//
# ifdef BOOST_NO_STDC_NAMESPACE
@@ -48,130 +60,14 @@
namespace unit_test {
-namespace {
-
-// framework parameters and there corresponding command-line arguments
-literal_string LOG_LEVEL = "BOOST_TEST_LOG_LEVEL";
-literal_string NO_RESULT_CODE = "BOOST_TEST_RESULT_CODE";
-literal_string REPORT_LEVEL = "BOOST_TEST_REPORT_LEVEL";
-literal_string TESTS_TO_RUN = "BOOST_TESTS_TO_RUN";
-literal_string SAVE_TEST_PATTERN = "BOOST_TEST_SAVE_PATTERN";
-literal_string BUILD_INFO = "BOOST_TEST_BUILD_INFO";
-literal_string SHOW_PROGRESS = "BOOST_TEST_SHOW_PROGRESS";
-literal_string CATCH_SYS_ERRORS = "BOOST_TEST_CATCH_SYSTEM_ERRORS";
-literal_string AUTO_START_DBG = "BOOST_TEST_AUTO_START_DBG";
-literal_string USE_ALT_STACK = "BOOST_TEST_USE_ALT_STACK";
-literal_string DETECT_FP_EXCEPT = "BOOST_TEST_DETECT_FP_EXCEPTIONS";
-literal_string REPORT_FORMAT = "BOOST_TEST_REPORT_FORMAT";
-literal_string LOG_FORMAT = "BOOST_TEST_LOG_FORMAT";
-literal_string OUTPUT_FORMAT = "BOOST_TEST_OUTPUT_FORMAT";
-literal_string DETECT_MEM_LEAK = "BOOST_TEST_DETECT_MEMORY_LEAK";
-literal_string RANDOM_SEED = "BOOST_TEST_RANDOM";
-literal_string BREAK_EXEC_PATH = "BOOST_TEST_BREAK_EXEC_PATH";
-
-unit_test::log_level s_log_level;
-bool s_no_result_code;
-unit_test::report_level s_report_level;
-const_string s_tests_to_run;
-const_string s_exec_path_to_break;
-bool s_save_pattern;
-bool s_show_build_info;
-bool s_show_progress;
-bool s_catch_sys_errors;
-bool s_auto_start_dbg;
-bool s_use_alt_stack;
-bool s_detect_fp_except;
-output_format s_report_format;
-output_format s_log_format;
-long s_detect_mem_leaks;
-unsigned int s_random_seed;
-
// ************************************************************************** //
-// ************** runtime_config ************** //
+// ************** input operations for unit_test's enums ************** //
// ************************************************************************** //
-const_string
-retrieve_framework_parameter( const_string parameter_name, int* argc, char** argv )
-{
- static fixed_mapping<const_string,const_string> parameter_2_cla_name_map(
- LOG_LEVEL , "--log_level",
- NO_RESULT_CODE , "--result_code",
- REPORT_LEVEL , "--report_level",
- TESTS_TO_RUN , "--run_test",
- SAVE_TEST_PATTERN , "--save_pattern",
- BUILD_INFO , "--build_info",
- SHOW_PROGRESS , "--show_progress",
- CATCH_SYS_ERRORS , "--catch_system_errors",
- AUTO_START_DBG , "--auto_start_dbg",
- USE_ALT_STACK , "--use_alt_stack",
- DETECT_FP_EXCEPT , "--detect_fp_exceptions",
- REPORT_FORMAT , "--report_format",
- LOG_FORMAT , "--log_format",
- OUTPUT_FORMAT , "--output_format",
- DETECT_MEM_LEAK , "--detect_memory_leaks",
- RANDOM_SEED , "--random",
- BREAK_EXEC_PATH , "--break_exec_path",
-
- ""
- );
-
- // first try to find parameter among command line arguments if present
- if( argc ) {
- // locate corresponding cla name
- const_string cla_name = parameter_2_cla_name_map[parameter_name];
-
- if( !cla_name.is_empty() ) {
- for( int i = 1; i < *argc; ++i ) {
- if( cla_name == const_string( argv[i], cla_name.size() ) && argv[i][cla_name.size()] == '=' ) {
- const_string result = argv[i] + cla_name.size() + 1;
-
- for( int j = i; j < *argc; ++j ) {
- argv[j] = argv[j+1];
- }
- --(*argc);
-
- return result;
- }
- }
- }
- }
-
- return std::getenv( parameter_name.begin() );
-}
-
-long interpret_long( const_string from )
-{
- bool negative = false;
- long res = 0;
-
- if( first_char( from ) == '-' ) {
- negative = true;
- from.trim_left( 1 );
- }
-
- const_string::iterator it = from.begin();
- for( ;it != from.end(); ++it ) {
- int d = *it - '0';
-
- res = 10 * res + d;
- }
-
- if( negative )
- res = -res;
-
- return res;
-}
-
-} // local namespace
-
-//____________________________________________________________________________//
-
-namespace runtime_config {
-
-void
-init( int* argc, char** argv )
+std::istream&
+operator>>( std::istream& in, unit_test::log_level& ll )
{
- fixed_mapping<const_string,unit_test::log_level,case_ins_less<char const> > log_level_name(
+ 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,
@@ -185,8 +81,22 @@
"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,
@@ -194,57 +104,211 @@
"no", NO_REPORT,
INV_REPORT_LEVEL
- );
+ );
- fixed_mapping<const_string,output_format,case_ins_less<char const> > output_format_name (
- "HRF", CLF,
- "CLF", CLF,
- "XML", XML,
-
- CLF
- );
-
- s_no_result_code = retrieve_framework_parameter( NO_RESULT_CODE, argc, argv ) == "no";
- s_save_pattern = retrieve_framework_parameter( SAVE_TEST_PATTERN, argc, argv ) == "yes";
- s_show_build_info = retrieve_framework_parameter( BUILD_INFO, argc, argv ) == "yes";
- s_show_progress = retrieve_framework_parameter( SHOW_PROGRESS, argc, argv ) == "yes";
-#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
- s_catch_sys_errors = retrieve_framework_parameter( CATCH_SYS_ERRORS, argc, argv ) == "yes";
-#else
- s_catch_sys_errors = retrieve_framework_parameter( CATCH_SYS_ERRORS, argc, argv ) != "no";
-#endif
- s_use_alt_stack = retrieve_framework_parameter( USE_ALT_STACK, argc, argv ) != "no";
- s_detect_fp_except = retrieve_framework_parameter( DETECT_FP_EXCEPT, argc, argv ) == "yes";
- s_tests_to_run = retrieve_framework_parameter( TESTS_TO_RUN, argc, argv );
- s_exec_path_to_break= retrieve_framework_parameter( BREAK_EXEC_PATH, argc, argv );
-
- const_string rs_str = retrieve_framework_parameter( RANDOM_SEED, argc, argv );
- s_random_seed = rs_str.is_empty() ? 0 : lexical_cast<unsigned int>( rs_str );
-
- s_log_level = log_level_name[retrieve_framework_parameter( LOG_LEVEL, argc, argv )];
- s_report_level = report_level_name[retrieve_framework_parameter( REPORT_LEVEL, argc, argv )];
-
- s_report_format = output_format_name[retrieve_framework_parameter( REPORT_FORMAT, argc, argv )];
- s_log_format = output_format_name[retrieve_framework_parameter( LOG_FORMAT, argc, argv )];
-
- const_string output_format = retrieve_framework_parameter( OUTPUT_FORMAT, argc, argv );
- if( !output_format.is_empty() ) {
- s_report_format = output_format_name[output_format];
- s_log_format = output_format_name[output_format];
+ 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::CLF,
+ "CLF", unit_test::CLF,
+ "XML", unit_test::XML,
+
+ unit_test::INV_OF
+ );
+
+ std::string val;
+ in >> val;
+
+ of = output_format_name[val];
+ BOOST_TEST_SETUP_ASSERT( of != unit_test::INV_OF, "invalid output format " + val );
+
+ return in;
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
+// ************** runtime_config ************** //
+// ************************************************************************** //
+
+namespace runtime_config {
+
+namespace {
+
+// framework parameters and corresponding command-line arguments
+std::string AUTO_START_DBG = "auto_start_dbg";
+std::string BREAK_EXEC_PATH = "break_exec_path";
+std::string BUILD_INFO = "build_info";
+std::string CATCH_SYS_ERRORS = "catch_system_errors";
+std::string DETECT_FP_EXCEPT = "detect_fp_exceptions";
+std::string DETECT_MEM_LEAKS = "detect_memory_leaks";
+std::string LOG_FORMAT = "log_format";
+std::string LOG_LEVEL = "log_level";
+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 RESULT_CODE = "result_code";
+std::string TESTS_TO_RUN = "run_test";
+std::string SAVE_TEST_PATTERN = "save_pattern";
+std::string SHOW_PROGRESS = "show_progress";
+std::string USE_ALT_STACK = "use_alt_stack";
+
+fixed_mapping<const_string,const_string> parameter_2_env_var(
+ AUTO_START_DBG , "BOOST_TEST_AUTO_START_DBG",
+ BREAK_EXEC_PATH , "BOOST_TEST_BREAK_EXEC_PATH",
+ BUILD_INFO , "BOOST_TEST_BUILD_INFO",
+ CATCH_SYS_ERRORS , "BOOST_TEST_CATCH_SYSTEM_ERRORS",
+ DETECT_FP_EXCEPT , "BOOST_TEST_DETECT_FP_EXCEPTIONS",
+ DETECT_MEM_LEAKS , "BOOST_TEST_DETECT_MEMORY_LEAK",
+ LOG_FORMAT , "BOOST_TEST_LOG_FORMAT",
+ LOG_LEVEL , "BOOST_TEST_LOG_LEVEL",
+ OUTPUT_FORMAT , "BOOST_TEST_OUTPUT_FORMAT",
+ RANDOM_SEED , "BOOST_TEST_RANDOM",
+ REPORT_FORMAT , "BOOST_TEST_REPORT_FORMAT",
+ REPORT_LEVEL , "BOOST_TEST_REPORT_LEVEL",
+ RESULT_CODE , "BOOST_TEST_RESULT_CODE",
+ TESTS_TO_RUN , "BOOST_TESTS_TO_RUN",
+ SAVE_TEST_PATTERN , "BOOST_TEST_SAVE_PATTERN",
+ SHOW_PROGRESS , "BOOST_TEST_SHOW_PROGRESS",
+ USE_ALT_STACK , "BOOST_TEST_USE_ALT_STACK",
+
+ ""
+);
+
+//____________________________________________________________________________//
+
+// storage for the CLAs
+cla::parser s_cla_parser;
+std::string s_empty;
+
+output_format s_report_format;
+output_format s_log_format;
+
+//____________________________________________________________________________//
+
+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 );
+ return val ? *val : optional_value;
}
- const_string ml_str = retrieve_framework_parameter( DETECT_MEM_LEAK, argc, argv );
- s_detect_mem_leaks = ml_str.is_empty() ? 1 : interpret_long( ml_str );
+ boost::optional<T> v;
+
+ env::get( parameter_2_env_var[parameter_name], v );
+
+ return v? *v : default_value;
+}
+
+//____________________________________________________________________________//
+
+} // local namespace
- const_string dbg = retrieve_framework_parameter( AUTO_START_DBG, argc, argv );
+void
+init( int& argc, char** argv )
+{
+ try {
+ 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::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::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<long>( DETECT_MEM_LEAKS )
+ - (cla::prefix = "--",cla::separator = "=",cla::guess_name,cla::optional,
+ 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<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<int>( 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<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::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::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>( "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 );
+ throw framework::nothing_to_test();
+ }
+
+ s_report_format = retrieve_parameter( REPORT_FORMAT, s_cla_parser, unit_test::CLF );
+ s_log_format = retrieve_parameter( LOG_FORMAT, s_cla_parser, unit_test::CLF );
+
+ unit_test::output_format of = retrieve_parameter( OUTPUT_FORMAT, s_cla_parser, unit_test::INV_OF );
- if( dbg.is_empty() || dbg == "no" )
- s_auto_start_dbg = false;
- else {
- s_auto_start_dbg = true;
+ if( of != unit_test::INV_OF )
+ s_report_format = s_log_format = of;
+ }
+ catch( rt::logic_error const& ex ) {
+ std::ostringstream err;
+
+ err << "Fail to process runtime parameters: " << ex.msg() << std::endl;
+ s_cla_parser.usage( err );
- if( dbg != "yes" )
- debug::set_debugger( dbg );
+ throw framework::setup_error( err.str() );
}
}
@@ -253,7 +317,7 @@
unit_test::log_level
log_level()
{
- return s_log_level;
+ return retrieve_parameter( LOG_LEVEL, s_cla_parser, unit_test::log_all_errors );
}
//____________________________________________________________________________//
@@ -261,7 +325,7 @@
bool
no_result_code()
{
- return s_no_result_code;
+ return !retrieve_parameter( RESULT_CODE, s_cla_parser, true );
}
//____________________________________________________________________________//
@@ -269,7 +333,7 @@
unit_test::report_level
report_level()
{
- return s_report_level;
+ return retrieve_parameter( REPORT_LEVEL, s_cla_parser, unit_test::CONFIRMATION_REPORT );
}
//____________________________________________________________________________//
@@ -277,7 +341,7 @@
const_string
test_to_run()
{
- return s_tests_to_run;
+ return retrieve_parameter( TESTS_TO_RUN, s_cla_parser, s_empty );
}
//____________________________________________________________________________//
@@ -285,7 +349,7 @@
const_string
break_exec_path()
{
- return s_exec_path_to_break;
+ return retrieve_parameter( BREAK_EXEC_PATH, s_cla_parser, s_empty );
}
//____________________________________________________________________________//
@@ -293,7 +357,7 @@
bool
save_pattern()
{
- return s_save_pattern;
+ return retrieve_parameter( SAVE_TEST_PATTERN, s_cla_parser, false );
}
//____________________________________________________________________________//
@@ -301,7 +365,7 @@
bool
show_progress()
{
- return s_show_progress;
+ return retrieve_parameter( SHOW_PROGRESS, s_cla_parser, false );
}
//____________________________________________________________________________//
@@ -309,7 +373,7 @@
bool
show_build_info()
{
- return s_show_build_info;
+ return retrieve_parameter( BUILD_INFO, s_cla_parser, false );
}
//____________________________________________________________________________//
@@ -317,7 +381,13 @@
bool
catch_sys_errors()
{
- return s_catch_sys_errors;
+ return retrieve_parameter( CATCH_SYS_ERRORS, s_cla_parser,
+#ifdef BOOST_TEST_DEFAULTS_TO_CORE_DUMP
+ false
+#else
+ true
+#endif
+ );
}
//____________________________________________________________________________//
@@ -325,7 +395,9 @@
bool
auto_start_dbg()
{
- return s_auto_start_dbg;
+ // !! set debugger as an option
+ return retrieve_parameter( AUTO_START_DBG, s_cla_parser, false );
+;
}
//____________________________________________________________________________//
@@ -333,7 +405,7 @@
bool
use_alt_stack()
{
- return s_use_alt_stack;
+ return retrieve_parameter( USE_ALT_STACK, s_cla_parser, true );
}
//____________________________________________________________________________//
@@ -341,7 +413,7 @@
bool
detect_fp_exceptions()
{
- return s_detect_fp_except;
+ return retrieve_parameter( DETECT_FP_EXCEPT, s_cla_parser, false );
}
//____________________________________________________________________________//
@@ -365,7 +437,7 @@
long
detect_memory_leaks()
{
- return s_detect_mem_leaks;
+ return retrieve_parameter( DETECT_MEM_LEAKS, s_cla_parser, (long)1 );
}
//____________________________________________________________________________//
@@ -373,7 +445,7 @@
int
random_seed()
{
- return s_random_seed;
+ return retrieve_parameter( RANDOM_SEED, s_cla_parser, 0, 1 );
}
//____________________________________________________________________________//
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk