update boost on linux
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
// Boost.Test Runtime parameters
|
||||
#include <boost/test/utils/runtime/errors.hpp>
|
||||
#include <boost/test/utils/runtime/argument.hpp>
|
||||
#include <boost/test/utils/runtime/modifier.hpp>
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/basic_cstring/io.hpp>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
// Boost.Test Runtime parameters
|
||||
#include <boost/test/utils/runtime/fwd.hpp>
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
|
||||
@@ -109,12 +109,12 @@ struct parameter_trie {
|
||||
// ************** runtime::cla::report_foreing_token ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
static void
|
||||
static void
|
||||
report_foreing_token( cstring program_name, cstring token )
|
||||
{
|
||||
std::cerr << "Boost.Test WARNING: token \"" << token << "\" does not correspond to the Boost.Test argument \n"
|
||||
<< " and should be placed after all Boost.Test arguments and the -- separator.\n"
|
||||
<< " For example: " << program_name << " --random -- " << token << "\n";
|
||||
<< " For example: " << program_name << " --random -- " << token << "\n";
|
||||
}
|
||||
|
||||
} // namespace rt_cla_detail
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
|
||||
if( negative_form ) {
|
||||
BOOST_TEST_I_ASSRT( found_id.m_negatable,
|
||||
format_error( found_param->p_name )
|
||||
format_error( found_param->p_name )
|
||||
<< "Parameter tag " << found_id.m_tag << " is not negatable." );
|
||||
|
||||
curr_token.trim_left( m_negation_prefix.size() );
|
||||
@@ -211,13 +211,18 @@ public:
|
||||
|
||||
curr_token.trim_left( name.size() );
|
||||
|
||||
bool should_go_to_next = true;
|
||||
cstring value;
|
||||
|
||||
|
||||
// Skip validations if parameter has optional value and we are at the end of token
|
||||
if( !value_separator.is_empty() || !found_param->p_has_optional_value ) {
|
||||
|
||||
// we are given a separator or there is no optional value
|
||||
|
||||
// Validate and skip value separator in the input
|
||||
BOOST_TEST_I_ASSRT( found_id.m_value_separator == value_separator,
|
||||
format_error( found_param->p_name )
|
||||
format_error( found_param->p_name )
|
||||
<< "Invalid separator for the parameter "
|
||||
<< found_param->p_name
|
||||
<< " in the argument " << tr.current_token() );
|
||||
@@ -237,6 +242,40 @@ public:
|
||||
<< found_param->p_name
|
||||
<< " in the argument " << tr.current_token() );
|
||||
}
|
||||
else if( (value_separator.is_empty() && found_id.m_value_separator.empty()) ) {
|
||||
// Deduce value source
|
||||
value = curr_token;
|
||||
if( value.is_empty() ) {
|
||||
tr.next_token(); // tokenization broke the value, we check the next one
|
||||
|
||||
if(!found_param->p_has_optional_value) {
|
||||
// there is no separator and there is no optional value
|
||||
// we look for the value on the next token
|
||||
// example "-t XXXX" (no default)
|
||||
// and we commit this value as being the passed value
|
||||
value = tr.current_token();
|
||||
}
|
||||
else {
|
||||
// there is no separator and the value is optional
|
||||
// we check the next token
|
||||
// example "-c" (defaults to true)
|
||||
// and commit this as the value if this is not a token
|
||||
cstring value_check = tr.current_token();
|
||||
|
||||
cstring prefix_test, name_test, value_separator_test;
|
||||
bool negative_form_test;
|
||||
if( validate_token_format( value_check, prefix_test, name_test, value_separator_test, negative_form_test )
|
||||
&& m_param_trie[prefix_test]) {
|
||||
// this is a token, we consume what we have
|
||||
should_go_to_next = false;
|
||||
}
|
||||
else {
|
||||
// this is a value, we commit it
|
||||
value = value_check;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate against argument duplication
|
||||
BOOST_TEST_I_ASSRT( !res.has( found_param->p_name ) || found_param->p_repeatable,
|
||||
@@ -248,7 +287,9 @@ public:
|
||||
// Produce argument value
|
||||
found_param->produce_argument( value, negative_form, res );
|
||||
|
||||
tr.next_token();
|
||||
if(should_go_to_next) {
|
||||
tr.next_token();
|
||||
}
|
||||
}
|
||||
|
||||
// generate the remainder and return it's size
|
||||
@@ -273,7 +314,7 @@ public:
|
||||
<< BOOST_VERSION % 100 ;
|
||||
ostr << " with ";
|
||||
#if defined(BOOST_TEST_INCLUDED)
|
||||
ostr << "single header inclusion of";
|
||||
ostr << "header-only inclusion of";
|
||||
#elif defined(BOOST_TEST_DYN_LINK)
|
||||
ostr << "dynamic linking to";
|
||||
#else
|
||||
@@ -287,57 +328,119 @@ public:
|
||||
}
|
||||
|
||||
void
|
||||
usage( std::ostream& ostr, cstring param_name = cstring() )
|
||||
usage(std::ostream& ostr,
|
||||
cstring param_name = cstring(),
|
||||
bool use_color = true)
|
||||
{
|
||||
namespace utils = unit_test::utils;
|
||||
namespace ut_detail = unit_test::ut_detail;
|
||||
|
||||
if( !param_name.is_empty() ) {
|
||||
basic_param_ptr param = locate_parameter( m_param_trie[help_prefix], param_name, "" ).second;
|
||||
param->usage( ostr, m_negation_prefix );
|
||||
}
|
||||
else {
|
||||
ostr << "Usage: " << m_program_name << " [Boost.Test argument]... ";
|
||||
if( !m_end_of_param_indicator.empty() )
|
||||
ostr << m_end_of_param_indicator << " [custom test module argument]...";
|
||||
ostr << "\n";
|
||||
ostr << "\n The program '" << m_program_name << "' is a Boost.Test module containing unit tests.";
|
||||
|
||||
{
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::ORIGINAL );
|
||||
ostr << "\n\n Usage\n ";
|
||||
}
|
||||
|
||||
{
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::GREEN );
|
||||
ostr << m_program_name << " [Boost.Test argument]... ";
|
||||
}
|
||||
if( !m_end_of_param_indicator.empty() ) {
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::YELLOW );
|
||||
ostr << '[' << m_end_of_param_indicator << " [custom test module argument]...]";
|
||||
}
|
||||
}
|
||||
|
||||
ostr << "\nFor detailed help on Boost.Test parameters use:\n"
|
||||
<< " " << m_program_name << " --help\n"
|
||||
<< "or\n"
|
||||
<< " " << m_program_name << " --help=<parameter name>\n";
|
||||
ostr << "\n\n Use\n ";
|
||||
{
|
||||
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::GREEN );
|
||||
ostr << m_program_name << " --help";
|
||||
}
|
||||
ostr << "\n or ";
|
||||
{
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::GREEN );
|
||||
ostr << m_program_name << " --help=<parameter name>";
|
||||
}
|
||||
ostr << "\n for detailed help on Boost.Test parameters.\n";
|
||||
}
|
||||
|
||||
void
|
||||
help( std::ostream& ostr, parameters_store const& parameters, cstring param_name )
|
||||
help(std::ostream& ostr,
|
||||
parameters_store const& parameters,
|
||||
cstring param_name,
|
||||
bool use_color = true)
|
||||
{
|
||||
namespace utils = unit_test::utils;
|
||||
namespace ut_detail = unit_test::ut_detail;
|
||||
|
||||
if( !param_name.is_empty() ) {
|
||||
basic_param_ptr param = locate_parameter( m_param_trie[help_prefix], param_name, "" ).second;
|
||||
param->help( ostr, m_negation_prefix );
|
||||
param->help( ostr, m_negation_prefix, use_color);
|
||||
return;
|
||||
}
|
||||
|
||||
ostr << "Usage: " << m_program_name << " [Boost.Test argument]... ";
|
||||
if( !m_end_of_param_indicator.empty() )
|
||||
ostr << m_end_of_param_indicator << " [custom test module argument]...";
|
||||
usage(ostr, cstring(), use_color);
|
||||
|
||||
ostr << "\n\nBoost.Test arguments correspond to parameters listed below. "
|
||||
"All parameters are optional. You can use specify parameter value either "
|
||||
"as a command line argument or as a value of corresponding environment "
|
||||
"variable. In case if argument for the same parameter is specified in both "
|
||||
"places, command line is taking precedence. Command line argument format "
|
||||
"supports parameter name guessing, so you can use any unambiguous "
|
||||
"prefix to identify a parameter.";
|
||||
if( !m_end_of_param_indicator.empty() )
|
||||
ostr << " All the arguments after the " << m_end_of_param_indicator << " are ignored by the Boost.Test.";
|
||||
ostr << "\n\n";
|
||||
{
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::ORIGINAL );
|
||||
ostr << " Command line flags:\n";
|
||||
}
|
||||
runtime::commandline_pretty_print(
|
||||
ostr,
|
||||
" ",
|
||||
"The command line flags of Boost.Test are listed below. "
|
||||
"All parameters are optional. You can specify parameter value either "
|
||||
"as a command line argument or as a value of its corresponding environment "
|
||||
"variable. If a flag is specified as a command line argument and an environment variable "
|
||||
"at the same time, the command line takes precedence. "
|
||||
"The command line argument "
|
||||
"support name guessing, and works with shorter names as long as those are not ambiguous."
|
||||
);
|
||||
|
||||
ostr << "\n\nBoost.Test supports following parameters:\n";
|
||||
|
||||
BOOST_TEST_FOREACH( parameters_store::storage_type::value_type const&, v, parameters.all() ) {
|
||||
basic_param_ptr param = v.second;
|
||||
|
||||
param->usage( ostr, m_negation_prefix );
|
||||
if( !m_end_of_param_indicator.empty() ) {
|
||||
ostr << "\n\n All the arguments after the '";
|
||||
{
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::YELLOW );
|
||||
ostr << m_end_of_param_indicator;
|
||||
}
|
||||
ostr << "' are ignored by Boost.Test.";
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::ORIGINAL );
|
||||
ostr << "\n\n Environment variables:\n";
|
||||
}
|
||||
runtime::commandline_pretty_print(
|
||||
ostr,
|
||||
" ",
|
||||
"Every argument listed below may also be set by a corresponding environment"
|
||||
"variable. For an argument '--argument_x=<value>', the corresponding "
|
||||
"environment variable is 'BOOST_TEST_ARGUMENT_X=value"
|
||||
);
|
||||
|
||||
|
||||
|
||||
ostr << "\n\n The following parameters are supported:\n";
|
||||
|
||||
BOOST_TEST_FOREACH(
|
||||
parameters_store::storage_type::value_type const&,
|
||||
v,
|
||||
parameters.all() )
|
||||
{
|
||||
basic_param_ptr param = v.second;
|
||||
ostr << "\n";
|
||||
param->usage( ostr, m_negation_prefix, use_color);
|
||||
}
|
||||
|
||||
ostr << "\nUse --help=<parameter name> to display detailed help for specific parameter.\n";
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace runtime {
|
||||
// ************** runtime::param_error ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
class param_error : public std::exception {
|
||||
class BOOST_SYMBOL_VISIBLE param_error : public std::exception {
|
||||
public:
|
||||
~param_error() BOOST_NOEXCEPT_OR_NOTHROW {}
|
||||
|
||||
@@ -55,13 +55,13 @@ protected:
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
class init_error : public param_error {
|
||||
class BOOST_SYMBOL_VISIBLE init_error : public param_error {
|
||||
protected:
|
||||
explicit init_error( cstring param_name ) : param_error( param_name ) {}
|
||||
~init_error() BOOST_NOEXCEPT_OR_NOTHROW {}
|
||||
};
|
||||
|
||||
class input_error : public param_error {
|
||||
class BOOST_SYMBOL_VISIBLE input_error : public param_error {
|
||||
protected:
|
||||
explicit input_error( cstring param_name ) : param_error( param_name ) {}
|
||||
~input_error() BOOST_NOEXCEPT_OR_NOTHROW {}
|
||||
@@ -70,7 +70,7 @@ protected:
|
||||
//____________________________________________________________________________//
|
||||
|
||||
template<typename Derived, typename Base>
|
||||
class specific_param_error : public Base {
|
||||
class BOOST_SYMBOL_VISIBLE specific_param_error : public Base {
|
||||
protected:
|
||||
explicit specific_param_error( cstring param_name ) : Base( param_name ) {}
|
||||
~specific_param_error() BOOST_NOEXCEPT_OR_NOTHROW {}
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
{
|
||||
this->msg.append( val );
|
||||
|
||||
return reinterpret_cast<Derived&&>(*this);
|
||||
return static_cast<Derived&&>(*this);
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -96,7 +96,7 @@ public:
|
||||
{
|
||||
this->msg.append( unit_test::utils::string_cast( val ) );
|
||||
|
||||
return reinterpret_cast<Derived&&>(*this);
|
||||
return static_cast<Derived&&>(*this);
|
||||
}
|
||||
|
||||
//____________________________________________________________________________//
|
||||
@@ -133,7 +133,7 @@ public:
|
||||
// ************************************************************************** //
|
||||
|
||||
#define SPECIFIC_EX_TYPE( type, base ) \
|
||||
class type : public specific_param_error<type,base> { \
|
||||
class BOOST_SYMBOL_VISIBLE type : public specific_param_error<type,base> { \
|
||||
public: \
|
||||
explicit type( cstring param_name = cstring() ) \
|
||||
: specific_param_error<type,base>( param_name ) \
|
||||
@@ -155,7 +155,7 @@ SPECIFIC_EX_TYPE( missing_req_arg, input_error );
|
||||
|
||||
#undef SPECIFIC_EX_TYPE
|
||||
|
||||
class ambiguous_param : public specific_param_error<ambiguous_param, input_error> {
|
||||
class BOOST_SYMBOL_VISIBLE ambiguous_param : public specific_param_error<ambiguous_param, input_error> {
|
||||
public:
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
explicit ambiguous_param( std::vector<cstring>&& amb_candidates )
|
||||
@@ -171,7 +171,7 @@ public:
|
||||
std::vector<cstring> m_amb_candidates;
|
||||
};
|
||||
|
||||
class unrecognized_param : public specific_param_error<unrecognized_param, input_error> {
|
||||
class BOOST_SYMBOL_VISIBLE unrecognized_param : public specific_param_error<unrecognized_param, input_error> {
|
||||
public:
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
explicit unrecognized_param( std::vector<cstring>&& type_candidates )
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/named_params.hpp>
|
||||
#include <boost/test/detail/global_typedef.hpp>
|
||||
|
||||
#include <boost/test/detail/suppress_warnings.hpp>
|
||||
|
||||
|
||||
@@ -24,9 +24,10 @@
|
||||
// Boost.Test
|
||||
#include <boost/test/utils/class_properties.hpp>
|
||||
#include <boost/test/utils/foreach.hpp>
|
||||
#include <boost/test/utils/setcolor.hpp>
|
||||
|
||||
// Boost
|
||||
#include <boost/function/function2.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/algorithm/cxx11/all_of.hpp>
|
||||
|
||||
// STL
|
||||
@@ -37,6 +38,40 @@
|
||||
namespace boost {
|
||||
namespace runtime {
|
||||
|
||||
inline
|
||||
std::ostream& commandline_pretty_print(
|
||||
std::ostream& ostr,
|
||||
std::string const& prefix,
|
||||
std::string const& to_print) {
|
||||
|
||||
const int split_at = 80;
|
||||
|
||||
std::string::size_type current = 0;
|
||||
|
||||
while(current < to_print.size()) {
|
||||
|
||||
// discards spaces at the beginning
|
||||
std::string::size_type startpos = to_print.find_first_not_of(" \t\n", current);
|
||||
current += startpos - current;
|
||||
|
||||
bool has_more_lines = (current + split_at) < to_print.size();
|
||||
|
||||
if(has_more_lines) {
|
||||
std::string::size_type endpos = to_print.find_last_of(" \t\n", current + split_at);
|
||||
std::string sub(to_print.substr(current, endpos - current));
|
||||
ostr << prefix << sub;
|
||||
ostr << "\n";
|
||||
current += endpos - current;
|
||||
}
|
||||
else
|
||||
{
|
||||
ostr << prefix << to_print.substr(current, split_at);
|
||||
current += split_at;
|
||||
}
|
||||
}
|
||||
return ostr;
|
||||
}
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** runtime::parameter_cla_id ************** //
|
||||
// ************************************************************************** //
|
||||
@@ -142,23 +177,37 @@ public:
|
||||
virtual void produce_default( arguments_store& store ) const = 0;
|
||||
|
||||
/// interfaces for help message reporting
|
||||
virtual void usage( std::ostream& ostr, cstring negation_prefix_ )
|
||||
virtual void usage( std::ostream& ostr, cstring negation_prefix_, bool use_color = true )
|
||||
{
|
||||
ostr << "Parameter: " << p_name << '\n';
|
||||
if( !p_description.empty() )
|
||||
ostr << ' ' << p_description << '\n';
|
||||
namespace utils = unit_test::utils;
|
||||
namespace ut_detail = unit_test::ut_detail;
|
||||
|
||||
//
|
||||
ostr << " ";
|
||||
{
|
||||
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::GREEN );
|
||||
ostr << p_name;
|
||||
}
|
||||
|
||||
ostr << '\n';
|
||||
|
||||
if( !p_description.empty() ) {
|
||||
commandline_pretty_print(ostr, " ", p_description) << '\n';
|
||||
}
|
||||
|
||||
ostr << " Command line formats:\n";
|
||||
BOOST_TEST_FOREACH( parameter_cla_id const&, id, cla_ids() ) {
|
||||
if( id.m_prefix == help_prefix )
|
||||
continue;
|
||||
|
||||
ostr << " " << id.m_prefix;
|
||||
if( id.m_negatable )
|
||||
cla_name_help( ostr, id.m_tag, negation_prefix_ );
|
||||
else
|
||||
cla_name_help( ostr, id.m_tag, "" );
|
||||
ostr << " " << id.m_prefix;
|
||||
|
||||
if( id.m_negatable )
|
||||
cla_name_help( ostr, id.m_tag, negation_prefix_, use_color );
|
||||
else
|
||||
cla_name_help( ostr, id.m_tag, "", use_color );
|
||||
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::YELLOW );
|
||||
bool optional_value_ = false;
|
||||
|
||||
if( p_has_optional_value ) {
|
||||
@@ -166,6 +215,7 @@ public:
|
||||
ostr << '[';
|
||||
}
|
||||
|
||||
|
||||
if( id.m_value_separator.empty() )
|
||||
ostr << ' ';
|
||||
else {
|
||||
@@ -179,16 +229,16 @@ public:
|
||||
|
||||
ostr << '\n';
|
||||
}
|
||||
if( !p_env_var.empty() )
|
||||
ostr << " Environment variable: " << p_env_var << '\n';
|
||||
}
|
||||
|
||||
virtual void help( std::ostream& ostr, cstring negation_prefix_ )
|
||||
virtual void help( std::ostream& ostr, cstring negation_prefix_, bool use_color = true )
|
||||
{
|
||||
usage( ostr, negation_prefix_ );
|
||||
usage( ostr, negation_prefix_, use_color );
|
||||
|
||||
if( !p_help.empty() )
|
||||
ostr << '\n' << p_help << '\n';
|
||||
if( !p_help.empty() ) {
|
||||
ostr << '\n';
|
||||
commandline_pretty_print(ostr, " ", p_help);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -220,7 +270,7 @@ protected:
|
||||
|
||||
private:
|
||||
/// interface for usage/help customization
|
||||
virtual void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring /* negation_prefix_ */) const
|
||||
virtual void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring /*negation_prefix_*/, bool /*use_color*/ = true) const
|
||||
{
|
||||
ostr << cla_tag;
|
||||
}
|
||||
@@ -337,12 +387,16 @@ private:
|
||||
{
|
||||
m_arg_factory.produce_default( p_name, store );
|
||||
}
|
||||
virtual void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring negation_prefix_ ) const
|
||||
virtual void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring negation_prefix_, bool use_color = true ) const
|
||||
{
|
||||
if( negation_prefix_.is_empty() )
|
||||
ostr << cla_tag;
|
||||
else
|
||||
ostr << '[' << negation_prefix_ << ']' << cla_tag;
|
||||
namespace utils = unit_test::utils;
|
||||
namespace ut_detail = unit_test::ut_detail;
|
||||
|
||||
if( !negation_prefix_.is_empty() ) {
|
||||
BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::YELLOW );
|
||||
ostr << '[' << negation_prefix_ << ']';
|
||||
}
|
||||
ostr << cla_tag;
|
||||
}
|
||||
virtual void value_help( std::ostream& ostr ) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user