Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74401 - in trunk/boost/test: detail impl
From: gennadiy.rozental_at_[hidden]
Date: 2011-09-15 23:22:38


Author: rogeeff
Date: 2011-09-15 23:22:37 EDT (Thu, 15 Sep 2011)
New Revision: 74401
URL: http://svn.boost.org/trac/boost/changeset/74401

Log:
made "run" argument multiplicable
facilitated CLA parser reuse for multiple parsing sessions (mostly for internal unit testing)
introduced list_context CLA

Text files modified:
   trunk/boost/test/detail/unit_test_parameters.hpp | 42 ++++----
   trunk/boost/test/impl/unit_test_parameters.ipp | 177 +++++++++++++++++++++------------------
   2 files changed, 119 insertions(+), 100 deletions(-)

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 2011-09-15 23:22:37 EDT (Thu, 15 Sep 2011)
@@ -22,6 +22,7 @@
 
 // STL
 #include <iosfwd>
+#include <list>
 
 //____________________________________________________________________________//
 
@@ -35,27 +36,28 @@
 
 namespace runtime_config {
 
-BOOST_TEST_DECL void init( int& argc, char** argv );
+BOOST_TEST_DECL void init( int& argc, char** argv );
 
-BOOST_TEST_DECL unit_test::log_level log_level();
-BOOST_TEST_DECL bool no_result_code();
-BOOST_TEST_DECL unit_test::report_level report_level();
-BOOST_TEST_DECL const_string test_to_run();
-BOOST_TEST_DECL const_string break_exec_path();
-BOOST_TEST_DECL bool save_pattern();
-BOOST_TEST_DECL bool show_build_info();
-BOOST_TEST_DECL bool show_progress();
-BOOST_TEST_DECL bool catch_sys_errors();
-BOOST_TEST_DECL bool color_output();
-BOOST_TEST_DECL bool auto_start_dbg();
-BOOST_TEST_DECL bool use_alt_stack();
-BOOST_TEST_DECL bool detect_fp_exceptions();
-BOOST_TEST_DECL output_format report_format();
-BOOST_TEST_DECL output_format log_format();
-BOOST_TEST_DECL std::ostream* report_sink();
-BOOST_TEST_DECL std::ostream* log_sink();
-BOOST_TEST_DECL long detect_memory_leaks();
-BOOST_TEST_DECL int random_seed();
+BOOST_TEST_DECL unit_test::log_level log_level();
+BOOST_TEST_DECL bool no_result_code();
+BOOST_TEST_DECL unit_test::report_level report_level();
+BOOST_TEST_DECL std::list<std::string> const& test_to_run();
+BOOST_TEST_DECL const_string break_exec_path();
+BOOST_TEST_DECL bool save_pattern();
+BOOST_TEST_DECL bool show_build_info();
+BOOST_TEST_DECL bool list_content();
+BOOST_TEST_DECL bool show_progress();
+BOOST_TEST_DECL bool catch_sys_errors();
+BOOST_TEST_DECL bool color_output();
+BOOST_TEST_DECL bool auto_start_dbg();
+BOOST_TEST_DECL bool use_alt_stack();
+BOOST_TEST_DECL bool detect_fp_exceptions();
+BOOST_TEST_DECL output_format report_format();
+BOOST_TEST_DECL output_format log_format();
+BOOST_TEST_DECL std::ostream* report_sink();
+BOOST_TEST_DECL std::ostream* log_sink();
+BOOST_TEST_DECL long detect_memory_leaks();
+BOOST_TEST_DECL int random_seed();
 
 } // namespace runtime_config
 

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 2011-09-15 23:22:37 EDT (Thu, 15 Sep 2011)
@@ -19,6 +19,7 @@
 #define BOOST_TEST_UNIT_TEST_PARAMETERS_IPP_012205GER
 
 // Boost.Test
+#define MAX_MAP_SIZE 25
 #include <boost/test/detail/unit_test_parameters.hpp>
 #include <boost/test/utils/basic_cstring/basic_cstring.hpp>
 #include <boost/test/utils/basic_cstring/compare.hpp>
@@ -34,14 +35,12 @@
 namespace rt = boost::runtime;
 namespace cla = rt::cla;
 
-
 #ifndef UNDER_CE
 #include <boost/test/utils/runtime/env/variable.hpp>
 
 namespace env = rt::env;
 #endif
 
-
 // Boost
 #include <boost/config.hpp>
 #include <boost/test/detail/suppress_warnings.hpp>
@@ -161,6 +160,7 @@
 std::string COLOR_OUTPUT = "color_output";
 std::string DETECT_FP_EXCEPT = "detect_fp_exceptions";
 std::string DETECT_MEM_LEAKS = "detect_memory_leaks";
+std::string LIST_CONTENT = "list_content";
 std::string LOG_FORMAT = "log_format";
 std::string LOG_LEVEL = "log_level";
 std::string LOG_SINK = "log_sink";
@@ -183,6 +183,7 @@
     COLOR_OUTPUT , "BOOST_TEST_COLOR_OUTPUT",
     DETECT_FP_EXCEPT , "BOOST_TEST_DETECT_FP_EXCEPTIONS",
     DETECT_MEM_LEAKS , "BOOST_TEST_DETECT_MEMORY_LEAK",
+ LIST_CONTENT , "BOOST_TEST_LIST_CONTENT",
     LOG_FORMAT , "BOOST_TEST_LOG_FORMAT",
     LOG_LEVEL , "BOOST_TEST_LOG_LEVEL",
     LOG_SINK , "BOOST_TEST_LOG_SINK",
@@ -203,11 +204,13 @@
 //____________________________________________________________________________//
 
 // storage for the CLAs
-cla::parser s_cla_parser;
-std::string s_empty;
+cla::parser s_cla_parser;
+std::string s_empty;
+
+output_format s_report_format;
+output_format s_log_format;
 
-output_format s_report_format;
-output_format s_log_format;
+std::list<std::string> s_test_to_run;
 
 //____________________________________________________________________________//
 
@@ -250,73 +253,79 @@
     using namespace cla;
 
     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::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<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<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<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<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::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")
- ;
+ 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::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<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<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<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<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<bool>( 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>( 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 );
 
@@ -332,6 +341,8 @@
 
         if( of != unit_test::INV_OF )
             s_report_format = s_log_format = of;
+
+ s_test_to_run = retrieve_parameter<std::list<std::string> >( TESTS_TO_RUN, s_cla_parser );
     }
     catch( rt::logic_error const& ex ) {
         std::ostringstream err;
@@ -369,11 +380,9 @@
 
 //____________________________________________________________________________//
 
-const_string
+std::list<std::string> const&
 test_to_run()
 {
- static std::string s_test_to_run = retrieve_parameter( TESTS_TO_RUN, s_cla_parser, s_empty );
-
     return s_test_to_run;
 }
 
@@ -414,6 +423,14 @@
 //____________________________________________________________________________//
 
 bool
+list_content()
+{
+ return retrieve_parameter( LIST_CONTENT, s_cla_parser, false );
+}
+
+//____________________________________________________________________________//
+
+bool
 catch_sys_errors()
 {
     return retrieve_parameter( CATCH_SYS_ERRORS, s_cla_parser,
@@ -488,8 +505,8 @@
     if( sink_name == "stdout" )
         return &std::cout;
 
- static std::ofstream log_file( sink_name.c_str() );
- return &log_file;
+ static std::ofstream report_file( sink_name.c_str() );
+ return &report_file;
 }
 
 //____________________________________________________________________________//
@@ -505,8 +522,8 @@
     if( sink_name == "stderr" )
         return &std::cerr;
 
- static std::ofstream report_file( sink_name.c_str() );
- return &report_file;
+ static std::ofstream log_file( sink_name.c_str() );
+ return &log_file;
 }
 
 //____________________________________________________________________________//


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