From b057ab20c33fa2827f77129c6d39164f7fa7f619 Mon Sep 17 00:00:00 2001 From: jamie Date: Sat, 18 Oct 2014 01:53:18 +0100 Subject: [PATCH 1/2] Fixes for #7419 --- include/boost/test/impl/framework.ipp | 22 +++++++++++++++ .../boost/test/impl/unit_test_parameters.ipp | 27 +++++++++++++++++++ .../boost/test/utils/runtime/cla/parser.hpp | 3 +++ .../boost/test/utils/runtime/cla/parser.ipp | 8 ++++++ 4 files changed, 60 insertions(+) diff --git a/include/boost/test/impl/framework.ipp b/include/boost/test/impl/framework.ipp index 517395ae5d..6f21bb22cf 100644 --- a/include/boost/test/impl/framework.ipp +++ b/include/boost/test/impl/framework.ipp @@ -333,6 +333,16 @@ public: ~framework_impl() { clear(); } + void reset() + { + clear(); + m_master_test_suite = 0; + m_curr_test_case = INV_TEST_UNIT_ID; + m_next_test_case_id = MIN_TEST_CASE_ID; + m_next_test_suite_id = MIN_TEST_SUITE_ID; + m_test_in_progress = false; + } + void clear() { while( !m_test_units.empty() ) { @@ -642,9 +652,21 @@ apply_filters( test_unit_id master_tu_id ) // ************** framework::init ************** // // ************************************************************************** // +void +reset() +{ + reset_observers(); + s_frk_impl().reset(); +} + void init( init_unit_test_func init_func, int argc, char* argv[] ) { + if( s_frk_impl().m_is_initialized ) + { + reset(); + } + runtime_config::init( argc, argv ); // set the log level and format diff --git a/include/boost/test/impl/unit_test_parameters.ipp b/include/boost/test/impl/unit_test_parameters.ipp index 8127278af5..4fc12f5f59 100644 --- a/include/boost/test/impl/unit_test_parameters.ipp +++ b/include/boost/test/impl/unit_test_parameters.ipp @@ -152,6 +152,30 @@ namespace runtime_config { namespace { // framework parameters and corresponding command-line arguments +#ifdef BOOST_TEST_USE_QUALIFIED_COMMANDLINE_ARGUMENTS +std::string AUTO_START_DBG = "boost.test.auto_start_dbg"; +std::string BREAK_EXEC_PATH = "boost.test.break_exec_path"; +std::string BUILD_INFO = "boost.test.build_info"; +std::string CATCH_SYS_ERRORS = "boost.test.catch_system_errors"; +std::string COLOR_OUTPUT = "boost.test.color_output"; +std::string DETECT_FP_EXCEPT = "boost.test.detect_fp_exceptions"; +std::string DETECT_MEM_LEAKS = "boost.test.detect_memory_leaks"; +std::string LIST_CONTENT = "boost.test.list_content"; +std::string LOG_FORMAT = "boost.test.log_format"; +std::string LOG_LEVEL = "boost.test.log_level"; +std::string LOG_SINK = "boost.test.log_sink"; +std::string OUTPUT_FORMAT = "boost.test.output_format"; +std::string RANDOM_SEED = "boost.test.random"; +std::string REPORT_FORMAT = "boost.test.report_format"; +std::string REPORT_LEVEL = "boost.test.report_level"; +std::string REPORT_SINK = "boost.test.report_sink"; +std::string RESULT_CODE = "boost.test.result_code"; +std::string TESTS_TO_RUN = "boost.test.run_test"; +std::string SAVE_TEST_PATTERN = "boost.test.save_pattern"; +std::string SHOW_PROGRESS = "boost.test.show_progress"; +std::string USE_ALT_STACK = "boost.test.use_alt_stack"; +std::string WAIT_FOR_DEBUGGER = "boost.test.wait_for_debugger"; +#else std::string AUTO_START_DBG = "auto_start_dbg"; std::string BREAK_EXEC_PATH = "break_exec_path"; std::string BUILD_INFO = "build_info"; @@ -174,6 +198,7 @@ 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"; +#endif static const_string parameter_2_env_var( const_string param_name ) @@ -262,6 +287,8 @@ init( int& argc, char** argv ) { using namespace cla; + s_cla_parser.clear(); + try { if( s_cla_parser.num_params() != 0 ) s_cla_parser.reset(); diff --git a/include/boost/test/utils/runtime/cla/parser.hpp b/include/boost/test/utils/runtime/cla/parser.hpp index d1b898e7f4..de5e09ad76 100644 --- a/include/boost/test/utils/runtime/cla/parser.hpp +++ b/include/boost/test/utils/runtime/cla/parser.hpp @@ -128,6 +128,9 @@ class parser { void usage( out_stream& ostr ); void help( out_stream& ostr ); + // clear + void clear(); + private: argument const& valid_argument( cstring string_id ) const; diff --git a/include/boost/test/utils/runtime/cla/parser.ipp b/include/boost/test/utils/runtime/cla/parser.ipp index b3b35c9f83..5eed6d553f 100644 --- a/include/boost/test/utils/runtime/cla/parser.ipp +++ b/include/boost/test/utils/runtime/cla/parser.ipp @@ -258,6 +258,14 @@ parser::reset() //____________________________________________________________________________// +BOOST_RT_PARAM_INLINE void +parser::clear() +{ + m_parameters.clear(); +} + +//____________________________________________________________________________// + } // namespace cla } // namespace BOOST_RT_PARAM_NAMESPACE From dca6033a402b0667c15eac974bb2b8c21099d4e7 Mon Sep 17 00:00:00 2001 From: ja11sop Date: Sun, 21 Oct 2018 20:34:44 +0100 Subject: [PATCH 2/2] Ensure parser code matches develop branch --- .../boost/test/utils/runtime/cla/parser.hpp | 6 - .../boost/test/utils/runtime/cla/parser.ipp | 275 ------------------ 2 files changed, 281 deletions(-) delete mode 100644 include/boost/test/utils/runtime/cla/parser.ipp diff --git a/include/boost/test/utils/runtime/cla/parser.hpp b/include/boost/test/utils/runtime/cla/parser.hpp index 5ac361bea3..bd3df7090c 100644 --- a/include/boost/test/utils/runtime/cla/parser.hpp +++ b/include/boost/test/utils/runtime/cla/parser.hpp @@ -17,8 +17,6 @@ #include #include -#include -#include #include // Boost.Test @@ -445,10 +443,6 @@ class parser { } - // help/usage - void usage( out_stream& ostr ); - void help( out_stream& ostr ); - private: typedef rt_cla_detail::parameter_trie_ptr trie_ptr; typedef rt_cla_detail::trie_per_char trie_per_char; diff --git a/include/boost/test/utils/runtime/cla/parser.ipp b/include/boost/test/utils/runtime/cla/parser.ipp deleted file mode 100644 index 5eed6d553f..0000000000 --- a/include/boost/test/utils/runtime/cla/parser.ipp +++ /dev/null @@ -1,275 +0,0 @@ -// (C) Copyright Gennadiy Rozental 2005-2012. -// Use, modification, and distribution are subject to 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) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements parser - public interface for CLA parsing and accessing -// *************************************************************************** - -#ifndef BOOST_RT_CLA_PARSER_IPP_062904GER -#define BOOST_RT_CLA_PARSER_IPP_062904GER - -// Boost.Runtime.Parameter -#include -#include -#include - -#include -#include -#include -#include -#include - -// Boost.Test -#include -#include - -// Boost -#include - -namespace boost { - -namespace BOOST_RT_PARAM_NAMESPACE { - -namespace cla { - -// ************************************************************************** // -// ************** runtime::cla::parser ************** // -// ************************************************************************** // - -BOOST_RT_PARAM_INLINE -parser::parser( cstring program_name ) -{ - assign_op( m_program_name, program_name, 0 ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE parser::param_iterator -parser::first_param() const -{ - return m_parameters.begin(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE parser::param_iterator -parser::last_param() const -{ - return m_parameters.end(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE argument const& -parser::valid_argument( cstring string_id ) const -{ - const_argument_ptr arg = (*this)[string_id]; - - BOOST_RT_PARAM_VALIDATE_LOGIC( !!arg, "Actual argument for parameter " << string_id << " is not present" ); - - return *arg; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE parser& -parser::operator<<( parameter_ptr new_param ) -{ - BOOST_TEST_FOREACH( parameter_ptr, old_param, m_parameters ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !old_param->conflict_with( *new_param ), - BOOST_RT_PARAM_LITERAL( "Definition of parameter " ) << new_param->id_2_report() << - BOOST_RT_PARAM_LITERAL( " conflicts with defintion of parameter " ) << old_param->id_2_report() ); - } - - m_parameters.push_back( new_param ); - - return *this; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::parse( int& argc, char_type** argv ) -{ - if( m_program_name.empty() ) { - m_program_name.assign( argv[0] ); - dstring::size_type pos = m_program_name.find_last_of( BOOST_RT_PARAM_LITERAL( "/\\" ) ); - - if( pos != static_cast(cstring::npos) ) - m_program_name.erase( 0, pos+1 ); - } - - m_traverser.init( argc, argv ); - - try { - while( !m_traverser.eoi() ) { - parameter_ptr found_param; - - BOOST_RT_PARAM_TRACE( "Total " << m_parameters.size() << " parameters registered" ); - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - BOOST_RT_PARAM_TRACE( "Try parameter " << curr_param->id_2_report() ); - - if( curr_param->matching( m_traverser, !found_param ) ) { - BOOST_RT_PARAM_TRACE( "Match found" ); - BOOST_RT_CLA_VALIDATE_INPUT( !found_param, (m_traverser.rollback(),m_traverser), "Ambiguous input" ); - - found_param = curr_param; - } - - m_traverser.rollback(); - } - - if( !found_param ) { - BOOST_RT_PARAM_TRACE( "No match found" ); - BOOST_RT_CLA_VALIDATE_INPUT( m_traverser.handle_mismatch(), m_traverser, - BOOST_RT_PARAM_LITERAL( "Unexpected input" ) ); - - continue; - } - - BOOST_RT_PARAM_TRACE( "Parse argument value" ); - found_param->produce_argument( m_traverser ); - - m_traverser.commit(); - } - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - if( !curr_param->p_optional && !curr_param->actual_argument() ) { - curr_param->produce_argument( *this ); - - BOOST_RT_PARAM_VALIDATE_LOGIC( curr_param->actual_argument(), - BOOST_RT_PARAM_LITERAL( "Required argument for parameter " ) << curr_param->id_2_report() - << BOOST_RT_PARAM_LITERAL( " is missing" ) ); - } - } - } - catch( bad_lexical_cast const& ) { - BOOST_RT_PARAM_REPORT_LOGIC_ERROR( - BOOST_RT_PARAM_LITERAL( "String to value convertion error during input parsing" ) ); - } - - m_traverser.remainder( argc, argv ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE const_argument_ptr -parser::operator[]( cstring string_id ) const -{ - parameter_ptr found_param; - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - if( curr_param->responds_to( string_id ) ) { - BOOST_RT_PARAM_VALIDATE_LOGIC( !found_param, - BOOST_RT_PARAM_LITERAL( "Ambiguous parameter string id: " ) << string_id ); - - found_param = curr_param; - } - } - - return found_param ? found_param->actual_argument() : argument_ptr(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE cstring -parser::get( cstring string_id ) const -{ - return get( string_id ); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::usage( out_stream& ostr ) -{ - if( m_program_name.empty() ) - assign_op( m_program_name, BOOST_RT_PARAM_CSTRING_LITERAL( "" ), 0 ); - - format_stream fs; - - fs << m_program_name; - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - fs << BOOST_RT_PARAM_LITERAL( ' ' ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( '[' ); - - curr_param->usage_info( fs ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( ']' ); - - if( curr_param->p_multiplicable ) { - fs << BOOST_RT_PARAM_CSTRING_LITERAL( " ... " ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( '[' ); - - curr_param->usage_info( fs ); - - if( curr_param->p_optional ) - fs << BOOST_RT_PARAM_LITERAL( ']' ); - } - } - - ostr << BOOST_RT_PARAM_CSTRING_LITERAL( "Usage:\n" ) << fs.str() << std::endl; -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::help( out_stream& ostr ) -{ - usage( ostr ); - - bool need_where = true; - - BOOST_TEST_FOREACH( parameter_ptr const&, curr_param, m_parameters ) { - if( curr_param->p_description->empty() ) - continue; - - if( need_where ) { - ostr << BOOST_RT_PARAM_CSTRING_LITERAL( "where:\n" ); - need_where = false; - } - - ostr << curr_param->id_2_report() << BOOST_RT_PARAM_CSTRING_LITERAL( " - " ) << curr_param->p_description << std::endl; - } -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::reset() -{ - BOOST_TEST_FOREACH( parameter_ptr const&, param, m_parameters ) - param->reset(); -} - -//____________________________________________________________________________// - -BOOST_RT_PARAM_INLINE void -parser::clear() -{ - m_parameters.clear(); -} - -//____________________________________________________________________________// - -} // namespace cla - -} // namespace BOOST_RT_PARAM_NAMESPACE - -} // namespace boost - -#endif // BOOST_RT_CLA_PARSER_IPP_062904GER