diff options
author | spuchin <spuchin@ydb.tech> | 2022-08-30 19:11:18 +0300 |
---|---|---|
committer | spuchin <spuchin@ydb.tech> | 2022-08-30 19:11:18 +0300 |
commit | afa22e2bffbb5a24e0f69722587033bd425b4278 (patch) | |
tree | 8f7cc273269c7d6092099449617301191aa45806 /contrib | |
parent | b39c849cda9decf6c19b135df25f21b5cf0d0d5b (diff) | |
download | ydb-afa22e2bffbb5a24e0f69722587033bd425b4278.tar.gz |
Introduce snapshot_read_only tx mode. ()
Diffstat (limited to 'contrib')
93 files changed, 2367 insertions, 1270 deletions
diff --git a/contrib/restricted/boost/test/CONTRIBUTE.md b/contrib/restricted/boost/test/CONTRIBUTE.md index e9773acdf2..c67b112d52 100644 --- a/contrib/restricted/boost/test/CONTRIBUTE.md +++ b/contrib/restricted/boost/test/CONTRIBUTE.md @@ -1,9 +1,10 @@ # How to contribute to Boost.Test ## Ticket -We like having a ticket stating the bug or the feature you want to implement. We use a dedicated ticket -management for this that can be found here: https://svn.boost.org/ . Please create a ticket there -by selecting the component `test`. +We like having a ticket stating the bug you are experiencing or the feature you want to implement. +We use the [GitHub issues](https://github.com/boostorg/test/issues) for raising bugs and feature requests, +while older tickets may be found in our former bug tracking system at https://svn.boost.org/ +(`test` component). ## Pull requests We welcome any contribution in the form of a pull request. Each PR is never integrated exactly as submitted, diff --git a/contrib/restricted/boost/test/LICENSE b/contrib/restricted/boost/test/LICENSE new file mode 100644 index 0000000000..36b7cd93cd --- /dev/null +++ b/contrib/restricted/boost/test/LICENSE @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/contrib/restricted/boost/test/README.md b/contrib/restricted/boost/test/README.md index ebf4f73f85..cabe8ff780 100644 --- a/contrib/restricted/boost/test/README.md +++ b/contrib/restricted/boost/test/README.md @@ -1,9 +1,9 @@ ![boosttest logo](doc/html/images/boost.test.logo.png) # What is Boost.Test? -Boost.Test is a C++03 and C++11/14 unit testing library, available on a wide range of platforms and compilers. +Boost.Test is a C++03/11/14/17 unit testing library, available on a wide range of platforms and compilers. -The library is part of [Boost](www.boost.org). The latest release +The library is part of [Boost](http://www.boost.org). The latest release of the library is available from the boost web site. Full instructions for use of this library can be accessed from @@ -11,13 +11,22 @@ http://www.boost.org/doc/libs/release/libs/test/ # Key features -* Easy to get started with: +* Easy to get started with: 1. download and deflate the latest boost archive 1. create a test module with this (header version): ``` #define BOOST_TEST_MODULE your_test_module #include <boost/test/included/unit_test.hpp> ``` + 1. Write your first test case: + ``` + BOOST_AUTO_TEST_CASE( your_test_case ) { + std::vector<int> a{1, 2}; + std::vector<int> b{1, 2}; + BOOST_TEST( a == b ); + } + ``` + 1. build and run 1. done * powerful and unique test assertion macro [`BOOST_TEST`](http://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/testing_tools/boost_test_universal_macro.html), that understands floating points, collections, strings... and uses appropriate comparison paradigm * self-registering test cases, organize cases in test suites, apply fixtures on test cases, suites or globally @@ -26,14 +35,23 @@ http://www.boost.org/doc/libs/release/libs/test/ * add [decoration](http://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/tests_organization/decorators.html) to test cases and suites for [advanced description](http://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/tests_organization/semantic.html), [group/label](http://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/tests_organization/tests_grouping.html), and [dependencies](http://www.boost.org/doc/libs/release/libs/test/doc/html/boost_test/tests_organization/tests_dependencies.html) * powerful command line options and test case filters * extensible logging, XML and JUNIT outputs for third-party tools (eg. cont. integration) -* various usage (shared/static library) for faster compilation/build cycles, smaller binaries +* various usage (shared/static library/header only) for faster integration and/or compilation/build cycles, smaller binaries # Copyright and license -Copyright 2001-2014, Gennadiy Rozental. -Copyright 2013-2018, Boost.Test team. +Copyright 2001-2014, Gennadiy Rozental.<br/> +Copyright 2013-2020, Boost.Test team. -Distributed under the Boost Software License, Version 1.0. +Distributed under the Boost Software License, Version 1.0.<br/> (Get a copy at www.boost.org/LICENSE_1_0.txt) # Contribute Please read [this document](CONTRIBUTE.md) to get started. + +# Build Status + +Boost.Test uses mostly the facility provided by our wonderful Boost testers (column `Tests` below). + +Branch | Deps | Docs | Tests | +:-------------: | ---- | ---- | ----- | +[`master`](https://github.com/boostorg/test/tree/master) | [![Deps](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/test.html) | [![Documentation](https://img.shields.io/badge/docs-master-brightgreen.svg)](http://www.boost.org/doc/libs/master/doc/html/test.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-master-brightgreen.svg)](http://www.boost.org/development/tests/master/developer/test.html) +[`develop`](https://github.com/boostorg/test/tree/develop) | [![Deps](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/test.html) | [![Documentation](https://img.shields.io/badge/docs-develop-brightgreen.svg)](http://www.boost.org/doc/libs/develop/doc/html/test.html) | [![Enter the Matrix](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](http://www.boost.org/development/tests/develop/developer/test.html) diff --git a/contrib/restricted/boost/test/include/boost/test/detail/config.hpp b/contrib/restricted/boost/test/include/boost/test/detail/config.hpp index db9b5d2b92..343a8667e4 100644 --- a/contrib/restricted/boost/test/include/boost/test/detail/config.hpp +++ b/contrib/restricted/boost/test/include/boost/test/detail/config.hpp @@ -16,8 +16,9 @@ #include <boost/config.hpp> // compilers workarounds #include <boost/detail/workaround.hpp> -#if defined(_WIN32) && !defined(BOOST_DISABLE_WIN32) && \ - (!defined(__COMO__) && !defined(__MWERKS__) && !defined(__GNUC__) || \ +#if defined(_WIN32) && !defined(BOOST_DISABLE_WIN32) && \ + (!defined(__COMO__) && !defined(__MWERKS__) && \ + !defined(__GNUC__) && !defined(BOOST_EMBTC) || \ BOOST_WORKAROUND(__MWERKS__, >= 0x3000)) # define BOOST_SEH_BASED_SIGNAL_HANDLING #endif @@ -30,7 +31,7 @@ class type_info; //____________________________________________________________________________// -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x570)) || \ +#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x570)) || \ BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(600)) || \ (defined __sgi && BOOST_WORKAROUND(_COMPILER_VERSION, BOOST_TESTED_AT(730))) # define BOOST_TEST_SHIFTED_LINE @@ -52,7 +53,7 @@ class type_info; //____________________________________________________________________________// -#if BOOST_WORKAROUND(__BORLANDC__, <= 0x570) || \ +#if BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x570) || \ BOOST_WORKAROUND( __COMO__, <= 0x433 ) || \ BOOST_WORKAROUND( __INTEL_COMPILER, <= 800 ) || \ defined(__sgi) && _COMPILER_VERSION <= 730 || \ @@ -64,24 +65,41 @@ class type_info; //____________________________________________________________________________// -#if defined(__GNUC__) || BOOST_WORKAROUND(BOOST_MSVC, == 1400) -#define BOOST_TEST_PROTECTED_VIRTUAL virtual -#else +#if BOOST_WORKAROUND(BOOST_MSVC, < 1400) #define BOOST_TEST_PROTECTED_VIRTUAL +#else +#define BOOST_TEST_PROTECTED_VIRTUAL virtual #endif //____________________________________________________________________________// -#if !defined(__BORLANDC__) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 ) +#if !defined(BOOST_BORLANDC) && !BOOST_WORKAROUND( __SUNPRO_CC, < 0x5100 ) #define BOOST_TEST_SUPPORT_TOKEN_ITERATOR 1 #endif //____________________________________________________________________________// +// Sun compiler does not support visibility on enums +#if defined(__SUNPRO_CC) +#define BOOST_TEST_ENUM_SYMBOL_VISIBLE +#else +#define BOOST_TEST_ENUM_SYMBOL_VISIBLE BOOST_SYMBOL_VISIBLE +#endif + +//____________________________________________________________________________// + #if defined(BOOST_ALL_DYN_LINK) && !defined(BOOST_TEST_DYN_LINK) # define BOOST_TEST_DYN_LINK #endif +// in case any of the define from cmake/b2 is set +#if !defined(BOOST_TEST_DYN_LINK) \ + && (defined(BOOST_UNIT_TEST_FRAMEWORK_DYN_LINK) \ + || defined(BOOST_TEST_EXEC_MONITOR_DYN_LINK) \ + || defined(BOOST_PRG_EXEC_MONITOR_DYN_LINK) ) +# define BOOST_TEST_DYN_LINK +#endif + #if defined(BOOST_TEST_INCLUDED) # undef BOOST_TEST_DYN_LINK #endif @@ -90,12 +108,16 @@ class type_info; # define BOOST_TEST_ALTERNATIVE_INIT_API # ifdef BOOST_TEST_SOURCE -# define BOOST_TEST_DECL BOOST_SYMBOL_EXPORT +# define BOOST_TEST_DECL BOOST_SYMBOL_EXPORT BOOST_SYMBOL_VISIBLE # else -# define BOOST_TEST_DECL BOOST_SYMBOL_IMPORT +# define BOOST_TEST_DECL BOOST_SYMBOL_IMPORT BOOST_SYMBOL_VISIBLE # endif // BOOST_TEST_SOURCE #else -# define BOOST_TEST_DECL +# if defined(BOOST_TEST_INCLUDED) +# define BOOST_TEST_DECL +# else +# define BOOST_TEST_DECL BOOST_SYMBOL_VISIBLE +# endif #endif #if !defined(BOOST_TEST_MAIN) && defined(BOOST_AUTO_TEST_MAIN) @@ -108,7 +130,7 @@ class type_info; -#ifndef BOOST_PP_VARIADICS /* we can change this only if not already defined) */ +#ifndef BOOST_PP_VARIADICS /* we can change this only if not already defined */ #ifdef __PGI #define BOOST_PP_VARIADICS 1 @@ -122,6 +144,27 @@ class type_info; #define BOOST_PP_VARIADICS 1 #endif +#if defined(__NVCC__) +#define BOOST_PP_VARIADICS 1 +#endif + #endif /* ifndef BOOST_PP_VARIADICS */ +// some versions of VC exibit a manifest error with this BOOST_UNREACHABLE_RETURN +#if BOOST_WORKAROUND(BOOST_MSVC, < 1910) +# define BOOST_TEST_UNREACHABLE_RETURN(x) return x +#else +# define BOOST_TEST_UNREACHABLE_RETURN(x) BOOST_UNREACHABLE_RETURN(x) +#endif + +//____________________________________________________________________________// +// string_view support +//____________________________________________________________________________// +// note the code should always be compatible with compiled version of boost.test +// using a pre-c++17 compiler + +#ifndef BOOST_NO_CXX17_HDR_STRING_VIEW +#define BOOST_TEST_STRING_VIEW +#endif + #endif // BOOST_TEST_CONFIG_HPP_071894GER diff --git a/contrib/restricted/boost/test/include/boost/test/detail/enable_warnings.hpp b/contrib/restricted/boost/test/include/boost/test/detail/enable_warnings.hpp index 45afb31944..d61c7dc592 100644 --- a/contrib/restricted/boost/test/include/boost/test/detail/enable_warnings.hpp +++ b/contrib/restricted/boost/test/include/boost/test/detail/enable_warnings.hpp @@ -26,7 +26,7 @@ # pragma warning(pop) #endif -#if BOOST_CLANG +#if defined(BOOST_CLANG) && (BOOST_CLANG == 1) #pragma clang diagnostic pop #endif diff --git a/contrib/restricted/boost/test/include/boost/test/detail/fwd_decl.hpp b/contrib/restricted/boost/test/include/boost/test/detail/fwd_decl.hpp index d5c97fb706..3d6b55a139 100644 --- a/contrib/restricted/boost/test/include/boost/test/detail/fwd_decl.hpp +++ b/contrib/restricted/boost/test/include/boost/test/detail/fwd_decl.hpp @@ -27,6 +27,7 @@ class master_test_suite_t; class test_tree_visitor; class test_observer; class test_unit_fixture; +class global_fixture; // singletons class unit_test_monitor_t; diff --git a/contrib/restricted/boost/test/include/boost/test/detail/global_typedef.hpp b/contrib/restricted/boost/test/include/boost/test/detail/global_typedef.hpp index aeede00e9c..5e6f960737 100644 --- a/contrib/restricted/boost/test/include/boost/test/detail/global_typedef.hpp +++ b/contrib/restricted/boost/test/include/boost/test/detail/global_typedef.hpp @@ -13,7 +13,6 @@ #define BOOST_TEST_GLOBAL_TYPEDEF_HPP_021005GER #include <boost/test/utils/basic_cstring/basic_cstring.hpp> -#include <boost/test/detail/workaround.hpp> #define BOOST_TEST_L( s ) ::boost::unit_test::const_string( s, sizeof( s ) - 1 ) #define BOOST_TEST_STRINGIZE( s ) BOOST_TEST_L( BOOST_STRINGIZE( s ) ) @@ -101,6 +100,45 @@ T static_constant<T>::value; //____________________________________________________________________________// +// helper defines for singletons. +// BOOST_TEST_SINGLETON_CONS should appear in the class body, +// BOOST_TEST_SINGLETON_CONS_IMPL should be in only one translation unit. The +// global instance should be declared by BOOST_TEST_SINGLETON_INST. + +#define BOOST_TEST_SINGLETON_CONS_NO_CTOR( type ) \ +public: \ + static type& instance(); \ +private: \ + BOOST_DELETED_FUNCTION(type(type const&)) \ + BOOST_DELETED_FUNCTION(type& operator=(type const&)) \ + BOOST_DEFAULTED_FUNCTION(~type(), {}) \ +/**/ + +#define BOOST_TEST_SINGLETON_CONS( type ) \ + BOOST_TEST_SINGLETON_CONS_NO_CTOR(type) \ +private: \ + BOOST_DEFAULTED_FUNCTION(type(), {}) \ +/**/ + +#define BOOST_TEST_SINGLETON_CONS_IMPL( type ) \ + type& type::instance() { \ + static type the_inst; return the_inst; \ + } \ +/**/ + +//____________________________________________________________________________// + +#if defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4 +#define BOOST_TEST_SINGLETON_INST( inst ) \ +static BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN (inst, _t)::instance(); + +#else + +#define BOOST_TEST_SINGLETON_INST( inst ) \ +namespace { BOOST_JOIN( inst, _t)& inst BOOST_ATTRIBUTE_UNUSED = BOOST_JOIN( inst, _t)::instance(); } + +#endif + } // namespace unit_test } // namespace boost diff --git a/contrib/restricted/boost/test/include/boost/test/detail/log_level.hpp b/contrib/restricted/boost/test/include/boost/test/detail/log_level.hpp index abdecea7ec..d391e103d1 100644 --- a/contrib/restricted/boost/test/include/boost/test/detail/log_level.hpp +++ b/contrib/restricted/boost/test/include/boost/test/detail/log_level.hpp @@ -12,6 +12,8 @@ #ifndef BOOST_TEST_LOG_LEVEL_HPP_011605GER #define BOOST_TEST_LOG_LEVEL_HPP_011605GER +#include <boost/test/detail/config.hpp> + namespace boost { namespace unit_test { @@ -20,7 +22,7 @@ namespace unit_test { // ************************************************************************** // // each log level includes all subsequent higher loging levels -enum log_level { +enum BOOST_TEST_ENUM_SYMBOL_VISIBLE log_level { invalid_log_level = -1, log_successful_tests = 0, log_test_units = 1, diff --git a/contrib/restricted/boost/test/include/boost/test/detail/suppress_warnings.hpp b/contrib/restricted/boost/test/include/boost/test/detail/suppress_warnings.hpp index 4badf20758..2145da5f91 100644 --- a/contrib/restricted/boost/test/include/boost/test/detail/suppress_warnings.hpp +++ b/contrib/restricted/boost/test/include/boost/test/detail/suppress_warnings.hpp @@ -26,13 +26,16 @@ # pragma warning(disable: 4511) // 'class' : copy constructor could not be generated #endif -#if BOOST_CLANG +#if defined(BOOST_CLANG) && (BOOST_CLANG == 1) # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wvariadic-macros" +# pragma clang diagnostic ignored "-Wmissing-declarations" #endif #if defined(BOOST_GCC) && (BOOST_GCC >= 4 * 10000 + 6 * 100) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wvariadic-macros" +# pragma GCC diagnostic ignored "-Wmissing-declarations" +// # pragma GCC diagnostic ignored "-Wattributes" #endif diff --git a/contrib/restricted/boost/test/include/boost/test/detail/throw_exception.hpp b/contrib/restricted/boost/test/include/boost/test/detail/throw_exception.hpp index 3f2f4687d3..19b50ba49c 100644 --- a/contrib/restricted/boost/test/include/boost/test/detail/throw_exception.hpp +++ b/contrib/restricted/boost/test/include/boost/test/detail/throw_exception.hpp @@ -33,7 +33,7 @@ namespace ut_detail { template<typename E> BOOST_NORETURN inline void -throw_exception(E const& e) { abort(); } +throw_exception(E const& /*e*/) { abort(); } #define BOOST_TEST_I_TRY #define BOOST_TEST_I_CATCH( T, var ) for(T const& var = *(T*)0; false;) diff --git a/contrib/restricted/boost/test/include/boost/test/detail/workaround.hpp b/contrib/restricted/boost/test/include/boost/test/detail/workaround.hpp deleted file mode 100644 index 4ba3a7e934..0000000000 --- a/contrib/restricted/boost/test/include/boost/test/detail/workaround.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// (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) - -// See http://www.boost.org/libs/test for the library home page. -// -//!@file -//!@brief contains mics. workarounds -// *************************************************************************** - -#ifndef BOOST_TEST_WORKAROUND_HPP_021005GER -#define BOOST_TEST_WORKAROUND_HPP_021005GER - -// Boost -#include <boost/config.hpp> // compilers workarounds and std::ptrdiff_t - -// STL -#include <iterator> // for std::distance - -#include <boost/test/detail/suppress_warnings.hpp> - -//____________________________________________________________________________// - -namespace boost { -namespace unit_test { -namespace ut_detail { - -#ifdef BOOST_NO_STD_DISTANCE -template <class T> -std::ptrdiff_t distance( T const& x_, T const& y_ ) -{ - std::ptrdiff_t res = 0; - - std::distance( x_, y_, res ); - - return res; -} - -//____________________________________________________________________________// - -#else -using std::distance; -#endif - -template <class T> inline void ignore_unused_variable_warning(const T&) {} - -} // namespace ut_detail -} // namespace unit_test -} // namespace boost - -//____________________________________________________________________________// - -#include <boost/test/detail/enable_warnings.hpp> - -#endif // BOOST_TEST_WORKAROUND_HPP_021005GER diff --git a/contrib/restricted/boost/test/include/boost/test/execution_monitor.hpp b/contrib/restricted/boost/test/include/boost/test/execution_monitor.hpp index ed06ef254e..6f1893bcd6 100644 --- a/contrib/restricted/boost/test/include/boost/test/execution_monitor.hpp +++ b/contrib/restricted/boost/test/include/boost/test/execution_monitor.hpp @@ -76,7 +76,7 @@ !(defined(__UCLIBC__) || defined(__nios2__) || defined(__microblaze__)) //! Indicates that floating point exception handling is supported for the //! non SEH version of it, for the GLIBC extensions only - // see dicussions on the related topic: https://svn.boost.org/trac/boost/ticket/11756 + // see discussions on the related topic: https://svn.boost.org/trac/boost/ticket/11756 #define BOOST_TEST_FPE_SUPPORT_WITH_GLIBC_EXTENSIONS__ #endif #endif @@ -111,7 +111,8 @@ namespace boost { /// /// @section DesignRationale Design Rationale /// -/// The Execution Monitor design assumes that it can be used when no (or almost no) memory available. Also the Execution Monitor is intended to be portable to as many platforms as possible. +/// The Execution Monitor design assumes that it can be used when no (or almost no) memory available. Also the Execution Monitor +/// is intended to be portable to as many platforms as possible. /// /// @section UserGuide User's guide /// The Execution Monitor is designed to solve the problem of executing potentially dangerous function that may result in any number of error conditions, @@ -237,7 +238,7 @@ protected: /// this class never allocates any memory and assumes that strings it refers to are either some constants or live in a some kind of persistent (preallocated) memory. // ************************************************************************** // -class BOOST_TEST_DECL execution_exception { +class BOOST_SYMBOL_VISIBLE execution_exception { typedef boost::unit_test::const_string const_string; public: /// These values are sometimes used as program return codes. @@ -309,7 +310,7 @@ private: /// This class is used to uniformly detect and report an occurrence of several types of signals and exceptions, reducing various /// errors to a uniform execution_exception that is returned to a caller. /// -/// The executiom_monitor behavior can be customized through a set of public parameters (properties) associated with the execution_monitor instance. +/// The execution_monitor behavior can be customized through a set of public parameters (properties) associated with the execution_monitor instance. /// All parameters are implemented as public unit_test::readwrite_property data members of the class execution_monitor. // ************************************************************************** // @@ -337,9 +338,9 @@ public: /// Specifies the seconds that elapse before a timer_error occurs. /// - /// The @em p_timeout property is an integer timeout (in seconds) for monitored function execution. Use this parameter to monitor code with possible deadlocks - /// or indefinite loops. This feature is only available for some operating systems (not yet Microsoft Windows). - unit_test::readwrite_property<unsigned> p_timeout; + /// The @em p_timeout property is an integer timeout (in microseconds) for monitored function execution. Use this parameter to monitor code with possible deadlocks + /// or infinite loops. This feature is only available for some operating systems (not yet Microsoft Windows). + unit_test::readwrite_property<unsigned long int> p_timeout; /// Should monitor use alternative stack for the signal catching. /// @@ -371,7 +372,7 @@ public: /// @brief Execution monitor entry point for functions returning void /// - /// This method is semantically identical to execution_monitor::execute, but des't produce any result code. + /// This method is semantically identical to execution_monitor::execute, but doesn't produce any result code. /// @param[in] F Function to monitor /// @see execute void vexecute( boost::function<void ()> const& F ); @@ -441,7 +442,7 @@ public: : translator_holder_base( next, tag ), m_translator( tr ) {} // translator holder interface - virtual int operator()( boost::function<int ()> const& F ) + int operator()( boost::function<int ()> const& F ) BOOST_OVERRIDE { BOOST_TEST_I_TRY { return m_next ? (*m_next)( F ) : F(); @@ -452,7 +453,7 @@ public: } } #ifndef BOOST_NO_RTTI - virtual translator_holder_base_ptr erase( translator_holder_base_ptr this_, std::type_info const& ti ) + translator_holder_base_ptr erase( translator_holder_base_ptr this_, std::type_info const& ti ) BOOST_OVERRIDE { return ti == typeid(ExceptionType) ? m_next : this_; } @@ -478,7 +479,7 @@ execution_monitor::register_exception_translator( ExceptionTranslator const& tr, /// @brief This is a trivial default constructible class. Use it to report graceful abortion of a monitored function execution. // ************************************************************************** // -struct execution_aborted {}; +struct BOOST_SYMBOL_VISIBLE execution_aborted {}; // ************************************************************************** // // ************** system_error ************** // @@ -515,8 +516,12 @@ enum masks { BOOST_FPE_ALL = MCW_EM, #elif !defined(BOOST_TEST_FPE_SUPPORT_WITH_GLIBC_EXTENSIONS__)/* *** */ + BOOST_FPE_DIVBYZERO = BOOST_FPE_OFF, + BOOST_FPE_INEXACT = BOOST_FPE_OFF, + BOOST_FPE_INVALID = BOOST_FPE_OFF, + BOOST_FPE_OVERFLOW = BOOST_FPE_OFF, + BOOST_FPE_UNDERFLOW = BOOST_FPE_OFF, BOOST_FPE_ALL = BOOST_FPE_OFF, - #else /* *** */ #if defined(FE_DIVBYZERO) diff --git a/contrib/restricted/boost/test/include/boost/test/framework.hpp b/contrib/restricted/boost/test/include/boost/test/framework.hpp index 099c02969b..1a139e099c 100644 --- a/contrib/restricted/boost/test/include/boost/test/framework.hpp +++ b/contrib/restricted/boost/test/include/boost/test/framework.hpp @@ -18,8 +18,6 @@ #include <boost/test/detail/fwd_decl.hpp> #include <boost/test/detail/throw_exception.hpp> -#include <boost/test/utils/trivial_singleton.hpp> - #include <boost/test/detail/suppress_warnings.hpp> // STL @@ -145,13 +143,13 @@ BOOST_TEST_DECL void deregister_observer( test_observer& to ); /// any other tests finished. /// Test unit fixture lifetime should exceed the testing execution timeframe /// @param[in] tuf fixture to add -BOOST_TEST_DECL void register_global_fixture( test_unit_fixture& tuf ); +BOOST_TEST_DECL void register_global_fixture( global_fixture& tuf ); /// Removes a test global fixture from the framework /// /// Test unit fixture lifetime should exceed the testing execution timeframe /// @param[in] tuf fixture to remove -BOOST_TEST_DECL void deregister_global_fixture( test_unit_fixture& tuf ); +BOOST_TEST_DECL void deregister_global_fixture( global_fixture& tuf ); /// @} /// @name Assertion/uncaught exception context support @@ -264,6 +262,12 @@ namespace impl { // exclusively for self test BOOST_TEST_DECL void setup_for_execution( test_unit const& ); BOOST_TEST_DECL void setup_loggers( ); + +// Helper for setting the name of the master test suite globally +struct BOOST_TEST_DECL master_test_suite_name_setter { + master_test_suite_name_setter( const_string name ); +}; + } // namespace impl // ************************************************************************** // diff --git a/contrib/restricted/boost/test/include/boost/test/impl/compiler_log_formatter.ipp b/contrib/restricted/boost/test/include/boost/test/impl/compiler_log_formatter.ipp index aa0a0e229f..4c99a9338d 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/compiler_log_formatter.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/compiler_log_formatter.ipp @@ -26,8 +26,6 @@ #include <boost/test/utils/basic_cstring/io.hpp> #include <boost/test/utils/lazy_ostream.hpp> -#include <boost/test/utils/setcolor.hpp> - // Boost #include <boost/version.hpp> @@ -80,14 +78,16 @@ compiler_log_formatter::log_finish( std::ostream& ostr ) //____________________________________________________________________________// void -compiler_log_formatter::log_build_info( std::ostream& output ) +compiler_log_formatter::log_build_info( std::ostream& output, bool log_build_info ) { - output << "Platform: " << BOOST_PLATFORM << '\n' - << "Compiler: " << BOOST_COMPILER << '\n' - << "STL : " << BOOST_STDLIB << '\n' - << "Boost : " << BOOST_VERSION/100000 << "." - << BOOST_VERSION/100 % 1000 << "." - << BOOST_VERSION % 100 << std::endl; + if(log_build_info) { + output << "Platform: " << BOOST_PLATFORM << '\n' + << "Compiler: " << BOOST_COMPILER << '\n' + << "STL : " << BOOST_STDLIB << '\n' + << "Boost : " << BOOST_VERSION/100000 << "." + << BOOST_VERSION/100 % 1000 << "." + << BOOST_VERSION % 100 << std::endl; + } } //____________________________________________________________________________// @@ -182,30 +182,25 @@ compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data co switch( let ) { case BOOST_UTL_ET_INFO: print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - if( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::GREEN ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::GREEN, term_color::ORIGINAL, &m_color_state); output << "info: "; break; case BOOST_UTL_ET_MESSAGE: - if( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::CYAN ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::CYAN, term_color::ORIGINAL, &m_color_state); break; case BOOST_UTL_ET_WARNING: print_prefix( output, entry_data.m_file_name, entry_data.m_line_num ); - if( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::YELLOW ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::YELLOW, term_color::ORIGINAL, &m_color_state); 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( m_color_output ) - output << setcolor( term_attr::BRIGHT, term_color::RED ); + output << setcolor( m_color_output, term_attr::BRIGHT, term_color::RED, term_color::ORIGINAL, &m_color_state); 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( m_color_output ) - output << setcolor( term_attr::UNDERLINE, term_color::RED ); + output << setcolor( m_color_output, term_attr::UNDERLINE, term_color::RED, term_color::ORIGINAL, &m_color_state); output << "fatal error: in \"" << test_phase_identifier() << "\": "; break; } @@ -233,7 +228,7 @@ void compiler_log_formatter::log_entry_finish( std::ostream& output ) { if( m_color_output ) - output << utils::setcolor(); + output << utils::setcolor(m_color_output, &m_color_state); output << std::endl; } diff --git a/contrib/restricted/boost/test/include/boost/test/impl/debug.ipp b/contrib/restricted/boost/test/include/boost/test/impl/debug.ipp index cc5e9dbe29..a2725d8e82 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/debug.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/debug.ipp @@ -17,12 +17,13 @@ // Boost.Test #include <boost/test/detail/config.hpp> -#include <boost/test/detail/workaround.hpp> #include <boost/test/detail/global_typedef.hpp> #include <boost/test/debug.hpp> #include <boost/test/debug_config.hpp> +#include <boost/core/ignore_unused.hpp> + // Implementation on Windows #if defined(_WIN32) && !defined(UNDER_CE) && !defined(BOOST_DISABLE_WIN32) // ******* WIN32 @@ -83,7 +84,7 @@ namespace std { using ::memset; using ::sprintf; } # include <procfs.h> -# elif defined(linux) || defined(__linux) +# elif defined(linux) || defined(__linux__) # define BOOST_LINUX_BASED_DEBUG @@ -94,7 +95,7 @@ namespace std { using ::memset; using ::sprintf; } # endif # ifndef BOOST_TEST_DBG_LIST -# define BOOST_TEST_DBG_LIST gdb +# define BOOST_TEST_DBG_LIST gdb;lldb # endif # define BOOST_TEST_CNL_DBG gdb @@ -102,6 +103,15 @@ namespace std { using ::memset; using ::sprintf; } # endif +#elif defined(__APPLE__) // ********************* APPLE + +# define BOOST_APPLE_BASED_DEBUG + +# include <assert.h> +# include <sys/types.h> +# include <unistd.h> +# include <sys/sysctl.h> + #endif #include <boost/test/detail/suppress_warnings.hpp> @@ -287,7 +297,7 @@ process_info::process_info( int pid ) m_binary_path_buff[num_read] = 0; m_binary_path.assign( m_binary_path_buff, num_read ); -#else // ****************************************************** default +#else (void) pid; // silence 'unused variable' warning #endif } @@ -423,7 +433,9 @@ prepare_gdb_cmnd_file( dbg_startup_info const& dsi ) static char cmd_file_name[] = "/tmp/btl_gdb_cmd_XXXXXX"; // !! ?? // prepare commands + const mode_t cur_umask = ::umask( S_IRWXO | S_IRWXG ); fd_holder cmd_fd( ::mkstemp( cmd_file_name ) ); + ::umask( cur_umask ); if( cmd_fd == -1 ) return 0; @@ -658,6 +670,33 @@ under_debugger() return false; +#elif defined(BOOST_APPLE_BASED_DEBUG) // ********************** APPLE + + // See https://developer.apple.com/library/mac/qa/qa1361/_index.html + int junk; + int mib[4]; + struct kinfo_proc info; + size_t size; + + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + size = sizeof(info); + junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); + assert(junk == 0); + + // We're being debugged if the P_TRACED flag is set. + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + #else // ****************************************************** default return false; @@ -680,7 +719,7 @@ debugger_break() #if defined(BOOST_WIN32_BASED_DEBUG) // *********************** WIN32 #if defined(__GNUC__) && !defined(__MINGW32__) || \ - defined(__INTEL_COMPILER) + defined(__INTEL_COMPILER) || defined(BOOST_EMBTC) # define BOOST_DEBUG_BREAK __debugbreak #else # define BOOST_DEBUG_BREAK DebugBreak @@ -770,7 +809,7 @@ struct safe_handle_helper } } - ~safe_handle_helper() + ~safe_handle_helper() { close_handle(); } @@ -806,7 +845,7 @@ attach_debugger( bool break_or_continue ) if( !dbg_init_done_ev ) return false; - + safe_handle_helper safe_handle_obj( dbg_init_done_ev ); // *************************************************** // @@ -824,7 +863,7 @@ attach_debugger( bool break_or_continue ) DWORD format_size = MAX_CMD_LINE; DWORD type = REG_SZ; - bool b_read_key = s_info.m_reg_query_value && + bool b_read_key = s_info.m_reg_query_value && ((*s_info.m_reg_query_value)( reg_key, // handle of open key "Debugger", // name of subkey to query @@ -835,7 +874,7 @@ attach_debugger( bool break_or_continue ) if( !s_info.m_reg_close_key || (*s_info.m_reg_close_key)( reg_key ) != ERROR_SUCCESS ) return false; - + if( !b_read_key ) return false; @@ -891,7 +930,9 @@ attach_debugger( bool break_or_continue ) #elif defined(BOOST_UNIX_BASED_DEBUG) // ********************** UNIX char init_done_lock_fn[] = "/tmp/btl_dbg_init_done_XXXXXX"; + const mode_t cur_umask = ::umask( S_IRWXO | S_IRWXG ); fd_holder init_done_lock_fd( ::mkstemp( init_done_lock_fn ) ); + ::umask( cur_umask ); if( init_done_lock_fd == -1 ) return false; @@ -955,7 +996,7 @@ attach_debugger( bool break_or_continue ) void detect_memory_leaks( bool on_off, unit_test::const_string report_file ) { - unit_test::ut_detail::ignore_unused_variable_warning( on_off ); + boost::ignore_unused( on_off ); #ifdef BOOST_MS_CRT_BASED_DEBUG int flags = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG ); @@ -977,7 +1018,7 @@ detect_memory_leaks( bool on_off, unit_test::const_string report_file ) _CrtSetDbgFlag ( flags ); #else - unit_test::ut_detail::ignore_unused_variable_warning( report_file ); + boost::ignore_unused( report_file ); #endif // BOOST_MS_CRT_BASED_DEBUG } @@ -991,7 +1032,7 @@ detect_memory_leaks( bool on_off, unit_test::const_string report_file ) void break_memory_alloc( long mem_alloc_order_num ) { - unit_test::ut_detail::ignore_unused_variable_warning( mem_alloc_order_num ); + boost::ignore_unused( mem_alloc_order_num ); #ifdef BOOST_MS_CRT_BASED_DEBUG // only set the value if one was supplied (do not use default used by UTF just as a indicator to enable leak detection) @@ -1008,4 +1049,3 @@ break_memory_alloc( long mem_alloc_order_num ) #include <boost/test/detail/enable_warnings.hpp> #endif // BOOST_TEST_DEBUG_API_IPP_112006GER - diff --git a/contrib/restricted/boost/test/include/boost/test/impl/decorator.ipp b/contrib/restricted/boost/test/include/boost/test/impl/decorator.ipp index 74d42b22a2..3a0ebb7061 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/decorator.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/decorator.ipp @@ -5,10 +5,6 @@ // See http://www.boost.org/libs/test for the library home page. // -// File : $RCSfile$ -// -// Version : $Revision$ -// // Description : unit test decorators implementation // *************************************************************************** @@ -35,13 +31,17 @@ namespace unit_test { namespace decorator { // ************************************************************************** // -// ************** decorator::collector ************** // +// ************** decorator::collector_t ************** // // ************************************************************************** // -collector& -collector::operator*( base const& d ) +// singleton pattern +BOOST_TEST_SINGLETON_CONS_IMPL(collector_t) + + +collector_t& +collector_t::operator*( base const& d ) { - m_tu_decorators.push_back( d.clone() ); + m_tu_decorators_stack.begin()->push_back( d.clone() ); return *this; } @@ -49,17 +49,41 @@ collector::operator*( base const& d ) //____________________________________________________________________________// void -collector::store_in( test_unit& tu ) +collector_t::store_in( test_unit& tu ) { - tu.p_decorators.value.insert( tu.p_decorators.value.end(), m_tu_decorators.begin(), m_tu_decorators.end() ); + tu.p_decorators.value.insert( + tu.p_decorators.value.end(), + m_tu_decorators_stack.begin()->begin(), + m_tu_decorators_stack.begin()->end() ); } //____________________________________________________________________________// void -collector::reset() +collector_t::reset() { - m_tu_decorators.clear(); + if(m_tu_decorators_stack.size() > 1) { + m_tu_decorators_stack.erase(m_tu_decorators_stack.begin()); + } + else { + assert(m_tu_decorators_stack.size() == 1); + m_tu_decorators_stack.begin()->clear(); + } +} + +void +collector_t::stack() +{ + assert(m_tu_decorators_stack.size() >= 1); + m_tu_decorators_stack.insert(m_tu_decorators_stack.begin(), std::vector<base_ptr>()); +} + +//____________________________________________________________________________// + +std::vector<base_ptr> +collector_t::get_lazy_decorators() const +{ + return *m_tu_decorators_stack.begin(); } //____________________________________________________________________________// @@ -68,10 +92,28 @@ collector::reset() // ************** decorator::base ************** // // ************************************************************************** // -collector& +collector_t& base::operator*() const { - return collector::instance() * *this; + return collector_t::instance() * *this; +} + +// ************************************************************************** // +// ************** decorator::stack_decorator ************** // +// ************************************************************************** // + +collector_t& +stack_decorator::operator*() const +{ + collector_t& instance = collector_t::instance(); + instance.stack(); + return instance * *this; +} + +void +stack_decorator::apply( test_unit& /*tu*/ ) +{ + // does nothing by definition } // ************************************************************************** // diff --git a/contrib/restricted/boost/test/include/boost/test/impl/execution_monitor.ipp b/contrib/restricted/boost/test/include/boost/test/impl/execution_monitor.ipp index 035bb958c1..0635db5807 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/execution_monitor.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/execution_monitor.ipp @@ -23,7 +23,6 @@ // Boost.Test #include <boost/test/detail/config.hpp> -#include <boost/test/detail/workaround.hpp> #include <boost/test/detail/throw_exception.hpp> #include <boost/test/execution_monitor.hpp> #include <boost/test/debug.hpp> @@ -35,6 +34,7 @@ #ifndef BOOST_NO_EXCEPTIONS #include <boost/exception/get_error_info.hpp> // for get_error_info #include <boost/exception/current_exception_cast.hpp> // for current_exception_cast +#include <boost/exception/diagnostic_information.hpp> #endif // STL @@ -47,24 +47,19 @@ #include <cassert> // for assert #include <cstddef> // for NULL #include <cstdio> // for vsnprintf +#include <stdio.h> #include <cstdarg> // for varargs +#include <stdarg.h> +#include <cmath> // for ceil #include <iostream> // for varargs #ifdef BOOST_NO_STDC_NAMESPACE -namespace std { using ::strerror; using ::strlen; using ::strncat; } +namespace std { using ::strerror; using ::strlen; using ::strncat; using ::ceil; } #endif // to use vsnprintf -#if defined(__SUNPRO_CC) || defined(__SunOS) -# include <stdio.h> -# include <stdarg.h> -using std::va_list; -#endif - -// to use vsnprintf -#if defined(__QNXNTO__) || defined(__VXWORKS__) -# include <stdio.h> +#if defined(__SUNPRO_CC) || defined(__SunOS) || defined(__QNXNTO__) || defined(__VXWORKS__) using std::va_list; #endif @@ -73,17 +68,22 @@ using std::va_list; #endif #ifdef BOOST_SEH_BASED_SIGNAL_HANDLING + +# if !defined(_WIN32_WINNT) // WinXP +# define _WIN32_WINNT 0x0501 +# endif + # include <windows.h> # if defined(__MWERKS__) || (defined(_MSC_VER) && !defined(UNDER_CE)) # include <eh.h> # endif -# if defined(__BORLANDC__) && __BORLANDC__ >= 0x560 || defined(__MWERKS__) +# if defined(BOOST_BORLANDC) && BOOST_BORLANDC >= 0x560 || defined(__MWERKS__) # include <stdint.h> # endif -# if defined(__BORLANDC__) && __BORLANDC__ < 0x560 +# if defined(BOOST_BORLANDC) && BOOST_BORLANDC < 0x560 typedef unsigned uintptr_t; # endif @@ -106,6 +106,10 @@ using std::va_list; # define BOOST_TEST_CRT_SET_HOOK(H) (void*)(H) # endif +# if defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0501) /* WinXP */ +# define BOOST_TEST_WIN32_WAITABLE_TIMERS +# endif + # if (!BOOST_WORKAROUND(_MSC_VER, >= 1400 ) && \ !defined(BOOST_COMO)) || defined(UNDER_CE) @@ -119,7 +123,7 @@ _set_invalid_parameter_handler( _invalid_parameter_handler arg ) # endif -# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) || defined(UNDER_CE) +# if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0564)) || defined(UNDER_CE) namespace { void _set_se_translator( void* ) {} } @@ -159,7 +163,7 @@ namespace { void _set_se_translator( void* ) {} } // documentation of BOOST_TEST_DISABLE_ALT_STACK in execution_monitor.hpp # if !defined(__CYGWIN__) && !defined(__QNXNTO__) && !defined(__bgq__) && \ - (!defined(__ANDROID__) || __ANDROID_API__ >= 8) && \ + (!defined(__ANDROID__) || __ANDROID_API__ >= 8) && !defined(__wasm__) && \ !defined(BOOST_TEST_DISABLE_ALT_STACK) # define BOOST_TEST_USE_ALT_STACK # endif @@ -210,16 +214,25 @@ void throw_exception( std::exception const & e ) { abort(); } namespace detail { -#ifdef __BORLANDC__ +#ifdef BOOST_BORLANDC # define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) std::vsnprintf( (a1), (a2), (a3), (a4) ) #elif BOOST_WORKAROUND(_MSC_VER, <= 1310) || \ BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3000)) || \ - defined(UNDER_CE) + defined(UNDER_CE) || \ + (defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)) # define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) _vsnprintf( (a1), (a2), (a3), (a4) ) #else # define BOOST_TEST_VSNPRINTF( a1, a2, a3, a4 ) vsnprintf( (a1), (a2), (a3), (a4) ) #endif + +/* checks the printf formatting by adding a decorator to the function */ +#if __GNUC__ >= 3 || defined(BOOST_EMBTC) +#define BOOST_TEST_PRINTF_ATTRIBUTE_CHECK(x, y) __attribute__((__format__ (__printf__, x, y))) +#else +#define BOOST_TEST_PRINTF_ATTRIBUTE_CHECK(x, y) +#endif + #ifndef BOOST_NO_EXCEPTIONS template <typename ErrorInfo> @@ -237,6 +250,7 @@ extract( boost::exception const* ex ) //____________________________________________________________________________// static void +BOOST_TEST_PRINTF_ATTRIBUTE_CHECK(3, 0) report_error( execution_exception::error_code ec, boost::exception const* be, char const* format, va_list* args ) { static const int REPORT_ERROR_BUFFER_SIZE = 4096; @@ -255,6 +269,7 @@ report_error( execution_exception::error_code ec, boost::exception const* be, ch //____________________________________________________________________________// static void +BOOST_TEST_PRINTF_ATTRIBUTE_CHECK(3, 4) report_error( execution_exception::error_code ec, boost::exception const* be, char const* format, ... ) { va_list args; @@ -268,6 +283,7 @@ report_error( execution_exception::error_code ec, boost::exception const* be, ch //____________________________________________________________________________// static void +BOOST_TEST_PRINTF_ATTRIBUTE_CHECK(2, 3) report_error( execution_exception::error_code ec, char const* format, ... ) { va_list args; @@ -368,16 +384,16 @@ system_signal_exception::report() const switch( m_sig_info->si_code ) { #ifdef __VXWORKS__ -// a bit of a hack to adapt code to small m_sig_info VxWorks uses +// a bit of a hack to adapt code to small m_sig_info VxWorks uses #define si_addr si_value.sival_int #define si_band si_value.sival_int -#else +#else case SI_USER: report_error( execution_exception::system_error, "signal: generated by kill() (or family); uid=%d; pid=%d", (int)m_sig_info->si_uid, (int)m_sig_info->si_pid ); break; -#endif +#endif case SI_QUEUE: report_error( execution_exception::system_error, "signal: sent by sigqueue()" ); @@ -386,14 +402,19 @@ system_signal_exception::report() const report_error( execution_exception::system_error, "signal: the expiration of a timer set by timer_settimer()" ); break; +// OpenBSD was missing SI_ASYNCIO and SI_MESGQ +#ifdef SI_ASYNCIO case SI_ASYNCIO: report_error( execution_exception::system_error, "signal: generated by the completion of an asynchronous I/O request" ); break; +#endif +#ifdef SI_MESGQ case SI_MESGQ: report_error( execution_exception::system_error, "signal: generated by the the arrival of a message on an empty message queue" ); break; +#endif default: break; } @@ -405,48 +426,48 @@ system_signal_exception::report() const case ILL_ILLOPC: report_error( execution_exception::system_fatal_error, "signal: illegal opcode; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case ILL_ILLTRP: report_error( execution_exception::system_fatal_error, "signal: illegal trap; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case ILL_PRVREG: report_error( execution_exception::system_fatal_error, "signal: privileged register; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case ILL_BADSTK: report_error( execution_exception::system_fatal_error, "signal: internal stack error; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; #endif case ILL_ILLOPN: report_error( execution_exception::system_fatal_error, "signal: illegal operand; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case ILL_ILLADR: report_error( execution_exception::system_fatal_error, "signal: illegal addressing mode; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case ILL_PRVOPC: report_error( execution_exception::system_fatal_error, "signal: privileged opcode; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case ILL_COPROC: report_error( execution_exception::system_fatal_error, "signal: co-processor error; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; default: report_error( execution_exception::system_fatal_error, "signal: SIGILL, si_code: %d (illegal instruction; address of failing instruction: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); + m_sig_info->si_code, (unsigned long) m_sig_info->si_addr ); break; } break; @@ -456,47 +477,47 @@ system_signal_exception::report() const case FPE_INTDIV: report_error( execution_exception::system_error, "signal: integer divide by zero; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case FPE_INTOVF: report_error( execution_exception::system_error, "signal: integer overflow; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case FPE_FLTDIV: report_error( execution_exception::system_error, "signal: floating point divide by zero; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case FPE_FLTOVF: report_error( execution_exception::system_error, "signal: floating point overflow; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case FPE_FLTUND: report_error( execution_exception::system_error, "signal: floating point underflow; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case FPE_FLTRES: report_error( execution_exception::system_error, "signal: floating point inexact result; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case FPE_FLTINV: report_error( execution_exception::system_error, "signal: invalid floating point operation; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case FPE_FLTSUB: report_error( execution_exception::system_error, "signal: subscript out of range; address of failing instruction: 0x%08lx", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; default: report_error( execution_exception::system_error, "signal: SIGFPE, si_code: %d (errnoneous arithmetic operations; address of failing instruction: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); + m_sig_info->si_code, (unsigned long) m_sig_info->si_addr ); break; } break; @@ -507,18 +528,18 @@ system_signal_exception::report() const case SEGV_MAPERR: report_error( execution_exception::system_fatal_error, "memory access violation at address: 0x%08lx: no mapping at fault address", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case SEGV_ACCERR: report_error( execution_exception::system_fatal_error, "memory access violation at address: 0x%08lx: invalid permissions", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; #endif default: report_error( execution_exception::system_fatal_error, "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); + m_sig_info->si_code, (unsigned long) m_sig_info->si_addr ); break; } break; @@ -529,23 +550,23 @@ system_signal_exception::report() const case BUS_ADRALN: report_error( execution_exception::system_fatal_error, "memory access violation at address: 0x%08lx: invalid address alignment", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case BUS_ADRERR: report_error( execution_exception::system_fatal_error, "memory access violation at address: 0x%08lx: non-existent physical address", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; case BUS_OBJERR: report_error( execution_exception::system_fatal_error, "memory access violation at address: 0x%08lx: object specific hardware error", - m_sig_info->si_addr ); + (unsigned long) m_sig_info->si_addr ); break; #endif default: report_error( execution_exception::system_fatal_error, "signal: SIGSEGV, si_code: %d (memory access violation at address: 0x%08lx)", - m_sig_info->si_addr, m_sig_info->si_code ); + m_sig_info->si_code, (unsigned long) m_sig_info->si_addr ); break; } break; @@ -591,7 +612,7 @@ system_signal_exception::report() const default: report_error( execution_exception::system_error, "signal: SIGPOLL, si_code: %d (asynchronous I/O event occurred; band event %d)", - (int)m_sig_info->si_band, m_sig_info->si_code ); + m_sig_info->si_code, (int)m_sig_info->si_band ); break; } break; @@ -696,7 +717,11 @@ signal_action::~signal_action() class signal_handler { public: // Constructor - explicit signal_handler( bool catch_system_errors, bool detect_fpe, unsigned timeout, bool attach_dbg, char* alt_stack ); + explicit signal_handler( bool catch_system_errors, + bool detect_fpe, + unsigned long int timeout_microseconds, + bool attach_dbg, + char* alt_stack ); // Destructor ~signal_handler(); @@ -719,7 +744,7 @@ public: private: // Data members signal_handler* m_prev_handler; - unsigned m_timeout; + unsigned long int m_timeout_microseconds; // Note: We intentionality do not catch SIGCHLD. Users have to deal with it themselves signal_action m_ILL_action; @@ -743,24 +768,28 @@ signal_handler* signal_handler::s_active_handler = signal_handler_ptr(); //____________________________________________________________________________// -signal_handler::signal_handler( bool catch_system_errors, bool detect_fpe, unsigned timeout, bool attach_dbg, char* alt_stack ) +signal_handler::signal_handler( bool catch_system_errors, + bool detect_fpe, + unsigned long int timeout_microseconds, + bool attach_dbg, + char* alt_stack ) : m_prev_handler( s_active_handler ) -, m_timeout( timeout ) -, m_ILL_action ( SIGILL , catch_system_errors, attach_dbg, alt_stack ) -, m_FPE_action ( SIGFPE , detect_fpe , attach_dbg, alt_stack ) -, m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack ) -, m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack ) +, m_timeout_microseconds( timeout_microseconds ) +, m_ILL_action ( SIGILL , catch_system_errors, attach_dbg, alt_stack ) +, m_FPE_action ( SIGFPE , detect_fpe , attach_dbg, alt_stack ) +, m_SEGV_action( SIGSEGV, catch_system_errors, attach_dbg, alt_stack ) +, m_BUS_action ( SIGBUS , catch_system_errors, attach_dbg, alt_stack ) #ifdef BOOST_TEST_CATCH_SIGPOLL -, m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack ) +, m_POLL_action( SIGPOLL, catch_system_errors, attach_dbg, alt_stack ) #endif -, m_ABRT_action( SIGABRT, catch_system_errors, attach_dbg, alt_stack ) -, m_ALRM_action( SIGALRM, timeout > 0 , attach_dbg, alt_stack ) +, m_ABRT_action( SIGABRT, catch_system_errors, attach_dbg, alt_stack ) +, m_ALRM_action( SIGALRM, timeout_microseconds > 0, attach_dbg, alt_stack ) { s_active_handler = this; - if( m_timeout > 0 ) { + if( m_timeout_microseconds > 0 ) { ::alarm( 0 ); - ::alarm( timeout ); + ::alarm( static_cast<unsigned int>(std::ceil(timeout_microseconds / 1E6) )); // alarm has a precision to the seconds } #ifdef BOOST_TEST_USE_ALT_STACK @@ -786,7 +815,7 @@ signal_handler::~signal_handler() { assert( s_active_handler == this ); - if( m_timeout > 0 ) + if( m_timeout_microseconds > 0 ) ::alarm( 0 ); #ifdef BOOST_TEST_USE_ALT_STACK @@ -884,7 +913,7 @@ execution_monitor::catch_signals( boost::function<int ()> const& F ) // ************** Microsoft structured exception handling ************** // // ************************************************************************** // -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x0564)) +#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x0564)) namespace { void _set_se_translator( void* ) {} } #endif @@ -902,8 +931,10 @@ public: , m_se_id( 0 ) , m_fault_address( 0 ) , m_dir( false ) + , m_timeout( false ) {} + void set_timed_out(); void report() const; int operator()( unsigned id, _EXCEPTION_POINTERS* exps ); @@ -914,6 +945,7 @@ private: unsigned m_se_id; void* m_fault_address; bool m_dir; + bool m_timeout; }; //____________________________________________________________________________// @@ -928,6 +960,14 @@ seh_catch_preventer( unsigned /* id */, _EXCEPTION_POINTERS* /* exps */ ) //____________________________________________________________________________// +void +system_signal_exception::set_timed_out() +{ + m_timeout = true; +} + +//____________________________________________________________________________// + int system_signal_exception::operator()( unsigned id, _EXCEPTION_POINTERS* exps ) { @@ -1079,7 +1119,12 @@ system_signal_exception::report() const break; default: - detail::report_error( execution_exception::system_error, "unrecognized exception. Id: 0x%08lx", m_se_id ); + if( m_timeout ) { + detail::report_error(execution_exception::timeout_error, "timeout while executing function"); + } + else { + detail::report_error( execution_exception::system_error, "unrecognized exception. Id: 0x%08lx", m_se_id ); + } break; } } @@ -1138,6 +1183,31 @@ execution_monitor::catch_signals( boost::function<int ()> const& F ) #endif } +#if defined(BOOST_TEST_WIN32_WAITABLE_TIMERS) + HANDLE htimer = INVALID_HANDLE_VALUE; + BOOL bTimerSuccess = FALSE; + + if( p_timeout ) { + htimer = ::CreateWaitableTimer( + NULL, + TRUE, + NULL); // naming the timer might create collisions + + if( htimer != INVALID_HANDLE_VALUE ) { + LARGE_INTEGER liDueTime; + liDueTime.QuadPart = - static_cast<LONGLONG>(p_timeout) * 10ll; // resolution of 100 ns + + bTimerSuccess = ::SetWaitableTimer( + htimer, + &liDueTime, + 0, + 0, + 0, + FALSE); // Do not restore a suspended system + } + } +#endif + detail::system_signal_exception SSE( this ); int ret_val = 0; @@ -1151,8 +1221,26 @@ execution_monitor::catch_signals( boost::function<int ()> const& F ) __except( SSE( GetExceptionCode(), GetExceptionInformation() ) ) { throw SSE; } + + // we check for time outs: we do not have any signaling facility on Win32 + // however, we signal a timeout as a hard error as for the other operating systems + // and throw the signal error handler + if( bTimerSuccess && htimer != INVALID_HANDLE_VALUE) { + if (::WaitForSingleObject(htimer, 0) == WAIT_OBJECT_0) { + SSE.set_timed_out(); + throw SSE; + } + } + } __finally { + +#if defined(BOOST_TEST_WIN32_WAITABLE_TIMERS) + if( htimer != INVALID_HANDLE_VALUE ) { + ::CloseHandle(htimer); + } +#endif + if( l_catch_system_errors ) { BOOST_TEST_CRT_SET_HOOK( old_crt_hook ); @@ -1208,7 +1296,7 @@ execution_monitor::execute( boost::function<int ()> const& F ) BOOST_TEST_I_TRY { detail::fpe_except_guard G( p_detect_fp_exceptions ); - unit_test::ut_detail::ignore_unused_variable_warning( G ); + boost::ignore_unused( G ); return catch_signals( F ); } @@ -1227,6 +1315,12 @@ execution_monitor::execute( boost::function<int ()> const& F ) { detail::report_error( execution_exception::cpp_exception_error, "std::string: %s", ex.c_str() ); } + // boost::exception (before std::exception, with extended diagnostic) + catch( boost::exception const& ex ) + { detail::report_error( execution_exception::cpp_exception_error, + &ex, + "%s", boost::diagnostic_information(ex).c_str() ); } + // std:: exceptions #if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI) #define CATCH_AND_REPORT_STD_EXCEPTION( ex_name ) \ @@ -1245,15 +1339,8 @@ execution_monitor::execute( boost::function<int ()> const& F ) #endif CATCH_AND_REPORT_STD_EXCEPTION( std::bad_alloc ) - -#if BOOST_WORKAROUND(__BORLANDC__, <= 0x0551) CATCH_AND_REPORT_STD_EXCEPTION( std::bad_cast ) CATCH_AND_REPORT_STD_EXCEPTION( std::bad_typeid ) -#else - CATCH_AND_REPORT_STD_EXCEPTION( std::bad_cast ) - CATCH_AND_REPORT_STD_EXCEPTION( std::bad_typeid ) -#endif - CATCH_AND_REPORT_STD_EXCEPTION( std::bad_exception ) CATCH_AND_REPORT_STD_EXCEPTION( std::domain_error ) CATCH_AND_REPORT_STD_EXCEPTION( std::invalid_argument ) @@ -1267,15 +1354,6 @@ execution_monitor::execute( boost::function<int ()> const& F ) CATCH_AND_REPORT_STD_EXCEPTION( std::exception ) #undef CATCH_AND_REPORT_STD_EXCEPTION - catch( boost::exception const& ex ) - { detail::report_error( execution_exception::cpp_exception_error, - &ex, -#if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI) - "unknown boost::exception" ); } -#else - typeid(ex).name() ); } -#endif - // system errors catch( system_error const& ex ) { detail::report_error( execution_exception::cpp_exception_error, @@ -1297,7 +1375,7 @@ execution_monitor::execute( boost::function<int ()> const& F ) #endif // !BOOST_NO_EXCEPTIONS - return 0; // never reached; supplied to quiet compiler warnings + BOOST_TEST_UNREACHABLE_RETURN(0); // never reached; supplied to quiet compiler warnings } // execute //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/impl/framework.ipp b/contrib/restricted/boost/test/include/boost/test/impl/framework.ipp index 496e7de859..c4bfd6ac4d 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/framework.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/framework.ipp @@ -34,6 +34,7 @@ #include <boost/test/tree/visitor.hpp> #include <boost/test/tree/traverse.hpp> #include <boost/test/tree/test_case_counter.hpp> +#include <boost/test/tree/global_fixture.hpp> #if BOOST_TEST_SUPPORT_TOKEN_ITERATOR #include <boost/test/utils/iterator/token_iterator.hpp> @@ -47,8 +48,8 @@ #include <boost/test/detail/throw_exception.hpp> // Boost -#include <boost/timer.hpp> -#include <boost/bind.hpp> +#include <boost/test/utils/timer.hpp> +#include <boost/bind/bind.hpp> // STL #include <limits> @@ -57,9 +58,8 @@ #include <cstdlib> #include <ctime> #include <numeric> -#ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE +#include <cmath> #include <iterator> -#endif #ifdef BOOST_NO_STDC_NAMESPACE namespace std { using ::time; using ::srand; } @@ -274,13 +274,13 @@ private: } // test_tree_visitor interface - virtual void visit( test_case const& tc ) + void visit( test_case const& tc ) BOOST_OVERRIDE { // make sure we only accept test cases if we match last component of the filter if( m_depth == m_components.size() && filter_unit( tc ) ) m_targ_list.push_back( tc.p_id ); // found a test case } - virtual bool test_suite_start( test_suite const& ts ) + bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { if( !filter_unit( ts ) ) return false; @@ -294,7 +294,7 @@ private: return false; } - virtual void test_suite_finish( test_suite const& /*ts*/ ) + void test_suite_finish( test_suite const& /*ts*/ ) BOOST_OVERRIDE { --m_depth; } @@ -320,7 +320,7 @@ public: private: // test_tree_visitor interface - virtual bool visit( test_unit const& tu ) + bool visit( test_unit const& tu ) BOOST_OVERRIDE { if( tu.has_label( m_label ) ) { // found a test unit; add it to list of tu to enable with children and stop recursion in case of suites @@ -348,7 +348,7 @@ public: {} // test_tree_visitor interface - virtual bool visit( test_unit const& tu ) + bool visit( test_unit const& tu ) BOOST_OVERRIDE { const_cast<test_unit&>(tu).p_run_status.value = m_new_status == test_unit::RS_INVALID ? tu.p_default_status : m_new_status; if( m_dep_collector ) { @@ -439,9 +439,7 @@ parse_filters( test_unit_id master_tu_id, test_unit_id_list& tu_to_enable, test_ //____________________________________________________________________________// -#ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE - -// a poor man's implementation of random_shuffle +// a poor man's implementation of random_shuffle, deprecated in C++11 template< class RandomIt, class RandomFunc > void random_shuffle( RandomIt first, RandomIt last, RandomFunc &r ) { @@ -456,21 +454,18 @@ void random_shuffle( RandomIt first, RandomIt last, RandomFunc &r ) } } -#endif - - // A simple handle for registering the global fixtures to the master test suite // without deleting an existing static object (the global fixture itself) when the program // terminates (shared_ptr). class global_fixture_handle : public test_unit_fixture { public: global_fixture_handle(test_unit_fixture* fixture) : m_global_fixture(fixture) {} - ~global_fixture_handle() {} + ~global_fixture_handle() BOOST_OVERRIDE {} - virtual void setup() { + void setup() BOOST_OVERRIDE { m_global_fixture->setup(); } - virtual void teardown() { + void teardown() BOOST_OVERRIDE { m_global_fixture->teardown(); } @@ -485,7 +480,7 @@ private: // ************** framework::state ************** // // ************************************************************************** // -unsigned const TIMEOUT_EXCEEDED = static_cast<unsigned>( -1 ); +unsigned long int const TIMEOUT_EXCEEDED = static_cast<unsigned long int>( -1 ); class state { public: @@ -526,7 +521,7 @@ public: { test_unit& tu = framework::get( tu_id, TUT_ANY ); - // collect all sibling dependancy from tu own list + // collect all sibling dependencies from tu own list BOOST_TEST_FOREACH( test_unit_id, dep_id, tu.p_dependencies.get() ) collect_dependant_siblings( tu_id, dep_id, master_tu_id, tuoi ); @@ -623,7 +618,7 @@ public: while( parent_id != INV_TEST_UNIT_ID && parent_id != master_tu_id ) { - // we do not use the traverse_test_tree as otherwise it would enable the sibblings and subtree + // we do not use the traverse_test_tree as otherwise it would enable the siblings and subtree // of the test case we want to enable (we need to enable the parent suites and their dependencies only) // the parent_id needs to be enabled in order to be properly parsed by finalize_run_status, the visit // does the job @@ -664,27 +659,31 @@ public: // Executes the test tree with the root at specified test unit execution_result execute_test_tree( test_unit_id tu_id, - unsigned timeout = 0, + unsigned long int timeout_microseconds = 0, random_generator_helper const * const p_random_generator = 0) { test_unit const& tu = framework::get( tu_id, TUT_ANY ); execution_result result = unit_test_monitor_t::test_ok; - if( !tu.is_enabled() ) + if( !tu.is_enabled() ) { + BOOST_TEST_FOREACH( test_observer*, to, m_observers ) + to->test_unit_skipped( tu, "disabled" ); return result; + } // 10. Check preconditions, including zero time left for execution and // successful execution of all dependencies - if( timeout == TIMEOUT_EXCEEDED ) { + if( timeout_microseconds == TIMEOUT_EXCEEDED ) { // notify all observers about skipped test unit BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_skipped( tu, "timeout for the test unit is exceeded" ); return unit_test_monitor_t::os_timeout; } - else if( timeout == 0 || timeout > tu.p_timeout ) // deduce timeout for this test unit - timeout = tu.p_timeout; + else if( timeout_microseconds == 0 || (tu.p_timeout > 0 && timeout_microseconds > (tu.p_timeout * 1000000) ) ) // deduce timeout for this test unit + timeout_microseconds = tu.p_timeout * 1000000; + test_tools::assertion_result const precondition_res = tu.check_preconditions(); if( !precondition_res ) { @@ -692,7 +691,10 @@ public: BOOST_TEST_FOREACH( test_observer*, to, m_observers ) to->test_unit_skipped( tu, precondition_res.message() ); - return unit_test_monitor_t::precondition_failure; + // It is not an error to skip the test if any of the parent tests + // have failed. This one should be reported as skipped as if it was + // disabled + return unit_test_monitor_t::test_ok; } // 20. Notify all observers about the start of the test unit @@ -707,17 +709,18 @@ public: break; test_results const& test_rslt = unit_test::results_collector.results( m_curr_test_unit ); if( test_rslt.aborted() ) { - result = unit_test_monitor_t::precondition_failure; + result = unit_test_monitor_t::test_setup_failure; break; } } - // This is the time we are going to spend executing the test unit - unsigned long elapsed = 0; + // This is the time we are going to spend executing the test unit (in microseconds + // as expected by test_observer::test_unit_finish) + unsigned long elapsed_microseconds = 0; if( result == unit_test_monitor_t::test_ok ) { // 40. We are going to time the execution - boost::timer tu_timer; + boost::unit_test::timer::timer tu_timer; // we pass the random generator const random_generator_helper& rand_gen = p_random_generator ? *p_random_generator : random_generator_helper(); @@ -729,12 +732,29 @@ public: typedef std::pair<counter_t,test_unit_id> value_type; BOOST_TEST_FOREACH( value_type, chld, ts.m_ranked_children ) { - unsigned chld_timeout = child_timeout( timeout, tu_timer.elapsed() ); + // tu_timer.elapsed() returns nanosec, timeout and child_timeout in microsec + unsigned long int chld_timeout = child_timeout( + timeout_microseconds, + static_cast<unsigned long int>( microsecond_wall_time(tu_timer.elapsed()) )); result = (std::min)( result, execute_test_tree( chld.second, chld_timeout, &rand_gen ) ); if( unit_test_monitor.is_critical_error( result ) ) break; + + // we check for the time elapsed. If this is too high, we fail the current suite and return from here + elapsed_microseconds = static_cast<unsigned long int>( microsecond_wall_time(tu_timer.elapsed()) ); + + if( (timeout_microseconds > 0) && (elapsed_microseconds > timeout_microseconds) && (timeout_microseconds != TIMEOUT_EXCEEDED ) ) { + BOOST_TEST_FOREACH( test_observer*, to, m_observers ) { + to->test_unit_timed_out(tu); + } + result = (std::min)( result, unit_test_monitor_t::os_timeout ); + timeout_microseconds = TIMEOUT_EXCEEDED; + //break; + // we continue to explore the children, such that we can at least update their + // status to skipped + } } } else { @@ -754,24 +774,33 @@ public: it++; } -#ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE impl::random_shuffle( children_with_the_same_rank.begin(), children_with_the_same_rank.end(), rand_gen ); -#else - std::random_shuffle( children_with_the_same_rank.begin(), children_with_the_same_rank.end(), rand_gen ); -#endif BOOST_TEST_FOREACH( test_unit_id, chld, children_with_the_same_rank ) { - unsigned chld_timeout = child_timeout( timeout, tu_timer.elapsed() ); + unsigned long int chld_timeout = child_timeout( + timeout_microseconds, + static_cast<unsigned long int>(microsecond_wall_time(tu_timer.elapsed())) ); result = (std::min)( result, execute_test_tree( chld, chld_timeout, &rand_gen ) ); if( unit_test_monitor.is_critical_error( result ) ) break; + + // we check for the time elapsed. If this is too high, we fail the current suite and return from here + elapsed_microseconds = static_cast<unsigned long int>( microsecond_wall_time(tu_timer.elapsed()) ); + if( (timeout_microseconds > 0) && (elapsed_microseconds > timeout_microseconds) && (timeout_microseconds != TIMEOUT_EXCEEDED ) ) { + BOOST_TEST_FOREACH( test_observer*, to, m_observers ) { + to->test_unit_timed_out(tu); + } + result = (std::min)( result, unit_test_monitor_t::os_timeout ); + timeout_microseconds = TIMEOUT_EXCEEDED; + //break; + // we continue to explore the children, such that we can at least update their + // status to skipped + } } } } - - elapsed = static_cast<unsigned long>( tu_timer.elapsed() * 1e6 ); } else { // TUT_CASE test_case const& tc = static_cast<test_case const&>( tu ); @@ -782,9 +811,9 @@ public: // setup current test case ut_detail::test_unit_id_restore restore_current_test_unit(m_curr_test_unit, tc.p_id); - // execute the test case body - result = unit_test_monitor.execute_and_translate( tc.p_test_func, timeout ); - elapsed = static_cast<unsigned long>( tu_timer.elapsed() * 1e6 ); + // execute the test case body, transforms the time out to seconds + result = unit_test_monitor.execute_and_translate( tc.p_test_func, timeout_microseconds ); + elapsed_microseconds = static_cast<unsigned long int>( microsecond_wall_time(tu_timer.elapsed()) ); // cleanup leftover context m_context.clear(); @@ -813,27 +842,28 @@ public: // notify all observers about completion BOOST_TEST_REVERSE_FOREACH( test_observer*, to, m_observers ) - to->test_unit_finish( tu, elapsed ); + to->test_unit_finish( tu, elapsed_microseconds ); return result; } ////////////////////////////////////////////////////////////////// - unsigned child_timeout( unsigned tu_timeout, double elapsed ) + unsigned long int child_timeout( unsigned long tu_timeout_microseconds, unsigned long elpsed_microsec ) { - if( tu_timeout == 0U ) - return 0U; + if( tu_timeout_microseconds == 0UL || tu_timeout_microseconds == TIMEOUT_EXCEEDED) + return tu_timeout_microseconds; - unsigned elpsed_sec = static_cast<unsigned>(elapsed); // rounding to number of whole seconds - - return tu_timeout > elpsed_sec ? tu_timeout - elpsed_sec : TIMEOUT_EXCEEDED; + return tu_timeout_microseconds > elpsed_microsec ? + tu_timeout_microseconds - elpsed_microsec + : TIMEOUT_EXCEEDED; } struct priority_order { bool operator()( test_observer* lhs, test_observer* rhs ) const { - return (lhs->priority() < rhs->priority()) || ((lhs->priority() == rhs->priority()) && (lhs < rhs)); + return (lhs->priority() < rhs->priority()) || + ((lhs->priority() == rhs->priority()) && std::less<test_observer*>()(lhs, rhs)); } }; @@ -868,7 +898,7 @@ public: context_data m_context; int m_context_idx; - std::set<test_unit_fixture*> m_global_fixtures; + std::set<global_fixture*> m_global_fixtures; boost::execution_monitor m_aux_em; @@ -917,6 +947,23 @@ shutdown_loggers_and_reports() } void +unregister_global_fixture_and_configuration() +{ + // we make a copy as the set will change in the iteration + std::set<global_fixture*> gfixture_copy(s_frk_state().m_global_fixtures); + BOOST_TEST_FOREACH( global_fixture*, tuf, gfixture_copy ) { + tuf->unregister_from_framework(); + } + s_frk_state().m_global_fixtures.clear(); + + state::observer_store gobserver_copy(s_frk_state().m_observers); + BOOST_TEST_FOREACH( test_observer*, to, gobserver_copy ) { + framework::deregister_observer( *to ); + } + s_frk_state().m_observers.clear(); +} + +void setup_loggers() { @@ -945,6 +992,7 @@ setup_loggers() log_cleaner ); } unit_test_log.set_stream( stream_logger.ref() ); + unit_test_log.configure(); } else { @@ -1075,7 +1123,7 @@ setup_loggers() boost::ref(std::cout) ); if( ++current_format_specs != utils::string_token_iterator() && current_format_specs->size() ) { - stream_logger.setup( *current_format_specs, + stream_logger.setup( *current_format_specs, log_cleaner ); } else { @@ -1133,13 +1181,12 @@ init( init_unit_test_func init_func, int argc, char* argv[] ) s_frk_state().m_report_sink.setup( runtime_config::get<std::string>( runtime_config::btrt_report_sink ), report_cleaner ); } - + 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 ); - register_observer( framework_init_observer ); if( runtime_config::get<bool>( runtime_config::btrt_show_progress ) ) { progress_monitor.set_stream( std::cout ); // defaults to stdout @@ -1175,10 +1222,19 @@ finalize_setup_phase( test_unit_id master_tu_id ) master_tu_id = master_test_suite().p_id; // 10. Apply all decorators to the auto test units + // 10. checks for consistency (duplicate names, etc) class apply_decorators : public test_tree_visitor { private: // test_tree_visitor interface - virtual bool visit( test_unit const& tu ) + + bool test_suite_start( test_suite const& ts) BOOST_OVERRIDE + { + const_cast<test_suite&>(ts).generate(); + const_cast<test_suite&>(ts).check_for_duplicate_test_cases(); + return test_tree_visitor::test_suite_start(ts); + } + + bool visit( test_unit const& tu ) BOOST_OVERRIDE { BOOST_TEST_FOREACH( decorator::base_ptr, d, tu.p_decorators.get() ) d->apply( const_cast<test_unit&>(tu) ); @@ -1213,7 +1269,13 @@ test_in_progress() void shutdown() { + // shuts down the loggers singleton to avoid any further reference to the + // framework during the destruction of those impl::shutdown_loggers_and_reports(); + + // unregisters any global fixture and configuration object + impl::unregister_global_fixture_and_configuration(); + // eliminating some fake memory leak reports. See for more details: // http://connect.microsoft.com/VisualStudio/feedback/details/106937/memory-leaks-reported-by-debug-crt-inside-typeinfo-name @@ -1338,7 +1400,7 @@ deregister_observer( test_observer& to ) // ************************************************************************** // void -register_global_fixture( test_unit_fixture& tuf ) +register_global_fixture( global_fixture& tuf ) { impl::s_frk_state().m_global_fixtures.insert( &tuf ); } @@ -1350,7 +1412,7 @@ register_global_fixture( test_unit_fixture& tuf ) // ************************************************************************** // void -deregister_global_fixture( test_unit_fixture &tuf ) +deregister_global_fixture( global_fixture &tuf ) { impl::s_frk_state().m_global_fixtures.erase( &tuf ); } @@ -1456,6 +1518,14 @@ master_test_suite() return *impl::s_frk_state().m_master_test_suite; } +namespace impl { + +master_test_suite_name_setter::master_test_suite_name_setter(const_string name) { + assign_op( master_test_suite().p_name.value, name.trim( "\"" ), 0 ); +} + +} + //____________________________________________________________________________// // ************************************************************************** // @@ -1536,6 +1606,33 @@ struct swap_on_delete { Cont& m_c2; }; +struct register_observer_helper { + register_observer_helper(test_observer& observer) + : m_observer(observer) + { + register_obs(); + } + + ~register_observer_helper() { + if(m_registered) + deregister_observer( m_observer ); + } + + void deregister_obs() { + m_registered = false; + deregister_observer( m_observer ); + } + + void register_obs() { + m_registered = true; + register_observer( m_observer ); + } + + + test_observer& m_observer; + bool m_registered; +}; + void run( test_unit_id id, bool continue_test ) { @@ -1557,6 +1654,9 @@ run( test_unit_id id, bool continue_test ) bool init_ok = true; const_string setup_error; + framework_init_observer_t local_init_observer; + register_observer_helper init_observer_helper( local_init_observer ); + if( call_start_finish ) { // indicates the framework that no test is in progress now if observers need to be notified impl::s_frk_state().m_test_in_progress = false; @@ -1564,13 +1664,13 @@ run( test_unit_id id, bool continue_test ) BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers ) { BOOST_TEST_I_TRY { ut_detail::test_unit_id_restore restore_current_test_unit(impl::s_frk_state().m_curr_test_unit, id); - unit_test_monitor_t::error_level result = unit_test_monitor.execute_and_translate( boost::bind( &test_observer::test_start, to, tcc.p_count ) ); + unit_test_monitor_t::error_level result = unit_test_monitor.execute_and_translate( boost::bind( &test_observer::test_start, to, tcc.p_count, id ) ); if( init_ok ) { if( result != unit_test_monitor_t::test_ok ) { init_ok = false; } else { - if( unit_test::framework_init_observer.has_failed() ) { + if( local_init_observer.has_failed() ) { init_ok = false; } } @@ -1587,6 +1687,9 @@ run( test_unit_id id, bool continue_test ) } } + // removing this observer as it should not be of any use for the tests + init_observer_helper.deregister_obs(); + if( init_ok ) { // attaching the global fixtures to the main entry point @@ -1625,7 +1728,10 @@ run( test_unit_id id, bool continue_test ) results_reporter::make_report( INV_REPORT_LEVEL, id ); - unit_test::framework_init_observer.clear(); + // reinstalling this observer + init_observer_helper.register_obs(); + + local_init_observer.clear(); if( call_start_finish ) { // indicates the framework that no test is in progress anymore if observers need to be notified // and this is a teardown, so assertions should not raise any exception otherwise an exception @@ -1640,7 +1746,7 @@ run( test_unit_id id, bool continue_test ) impl::s_frk_state().m_test_in_progress = was_in_progress; // propagates the init/teardown error if any - BOOST_TEST_SETUP_ASSERT( init_ok && !unit_test::framework_init_observer.has_failed(), setup_error ); + BOOST_TEST_SETUP_ASSERT( init_ok && !local_init_observer.has_failed(), setup_error ); } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/impl/junit_log_formatter.ipp b/contrib/restricted/boost/test/include/boost/test/impl/junit_log_formatter.ipp index 0f7a8f4c51..8a3b17dc2e 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/junit_log_formatter.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/junit_log_formatter.ipp @@ -23,7 +23,6 @@ #include <boost/test/framework.hpp> #include <boost/test/tree/visitor.hpp> -#include <boost/test/tree/test_case_counter.hpp> #include <boost/test/tree/traverse.hpp> #include <boost/test/results_collector.hpp> @@ -35,6 +34,7 @@ // Boost #include <boost/version.hpp> +#include <boost/core/ignore_unused.hpp> // STL #include <iostream> @@ -241,7 +241,10 @@ public: } if( tu.p_type == TUT_SUITE ) { - name += "-setup-teardown"; + if(tr->p_timed_out) + name += "-timed-execution"; + else + name += "-setup-teardown"; } m_stream << "<testcase assertions" << utils::attr_value() << nb_assertions; @@ -359,7 +362,7 @@ public: } } else { - nb_assertions = tr->p_assertions_passed + tr->p_assertions_failed; + nb_assertions = static_cast<int>(tr->p_assertions_passed + tr->p_assertions_failed); } return nb_assertions; @@ -394,7 +397,7 @@ public: m_stream << "</testcase>" << std::endl; } - void visit( test_case const& tc ) + void visit( test_case const& tc ) BOOST_OVERRIDE { test_results const& tr = results_collector.results( tc.p_id ); @@ -409,7 +412,7 @@ public: } } - bool test_suite_start( test_suite const& ts ) + bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { test_results const& tr = results_collector.results( ts.p_id ); @@ -417,12 +420,25 @@ public: if( m_ts.p_id == ts.p_id ) { m_stream << "<testsuite"; + // think about: maybe we should add the number of fixtures of a test_suite as + // independent tests (field p_fixtures). + // same goes for the timed-execution: we can think of that as a separate test-unit + // in the suite. + // see https://llg.cubic.org/docs/junit/ and + // http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java?view=markup m_stream // << "disabled=\"" << tr.p_test_cases_skipped << "\" " - << " tests" << utils::attr_value() << tr.p_test_cases_passed + << " tests" << utils::attr_value() + << tr.p_test_cases_passed + + tr.p_test_cases_failed + // + tr.p_test_cases_aborted // aborted is also failed, we avoid counting it twice << " skipped" << utils::attr_value() << tr.p_test_cases_skipped << " errors" << utils::attr_value() << tr.p_test_cases_aborted - << " failures" << utils::attr_value() << tr.p_test_cases_failed + << " failures" << utils::attr_value() + << tr.p_test_cases_failed + + tr.p_test_suites_timed_out + + tr.p_test_cases_timed_out + - tr.p_test_cases_aborted // failed is not aborted in the Junit sense << " id" << utils::attr_value() << m_id++ << " name" << utils::attr_value() << tu_name_normalize(ts.p_name) << " time" << utils::attr_value() << (tr.p_duration_microseconds * 1E-6) @@ -455,7 +471,7 @@ public: return true; // indicates that the children should also be parsed } - virtual void test_suite_finish( test_suite const& ts ) + void test_suite_finish( test_suite const& ts ) BOOST_OVERRIDE { if( m_ts.p_id == ts.p_id ) { write_testcase_system_out(runner_log, 0, false); @@ -507,9 +523,9 @@ junit_log_formatter::log_finish( std::ostream& ostr ) //____________________________________________________________________________// void -junit_log_formatter::log_build_info( std::ostream& /*ostr*/ ) +junit_log_formatter::log_build_info( std::ostream& /*ostr*/, bool log_build_info ) { - m_display_build_info = true; + m_display_build_info = log_build_info; } //____________________________________________________________________________// @@ -525,12 +541,12 @@ junit_log_formatter::test_unit_start( std::ostream& /*ostr*/, test_unit const& t //____________________________________________________________________________// + void junit_log_formatter::test_unit_finish( std::ostream& /*ostr*/, test_unit const& tu, unsigned long /*elapsed*/ ) { - (void) tu; // unused when asserts are turned off - // the time is already stored in the result_reporter + boost::ignore_unused( tu ); assert( tu.p_id == list_path_to_root.back() ); list_path_to_root.pop_back(); } @@ -538,8 +554,7 @@ junit_log_formatter::test_unit_finish( std::ostream& /*ostr*/, test_unit const& void junit_log_formatter::test_unit_aborted( std::ostream& /*ostr*/, test_unit const& tu ) { - (void) tu; // unused when asserts are turned off - + boost::ignore_unused( tu ); assert( tu.p_id == list_path_to_root.back() ); //list_path_to_root.pop_back(); } @@ -547,6 +562,25 @@ junit_log_formatter::test_unit_aborted( std::ostream& /*ostr*/, test_unit const& //____________________________________________________________________________// void +junit_log_formatter::test_unit_timed_out( std::ostream& /*os*/, test_unit const& tu) +{ + if(tu.p_type == TUT_SUITE) + { + // if we reach this call, it means that the test has already started and + // test_unit_start has already been called on the tu. + junit_impl::junit_log_helper& last_entry = get_current_log_entry(); + junit_impl::junit_log_helper::assertion_entry entry; + entry.logentry_message = "test-suite time out"; + entry.logentry_type = "execution timeout"; + entry.log_entry = junit_impl::junit_log_helper::assertion_entry::log_entry_error; + entry.output = "the current suite exceeded the allocated execution time"; + last_entry.assertion_entries.push_back(entry); + } +} + +//____________________________________________________________________________// + +void junit_log_formatter::test_unit_skipped( std::ostream& /*ostr*/, test_unit const& tu, const_string reason ) { // if a test unit is skipped, then the start of this TU has not been called yet. diff --git a/contrib/restricted/boost/test/include/boost/test/impl/plain_report_formatter.ipp b/contrib/restricted/boost/test/include/boost/test/impl/plain_report_formatter.ipp index cbf5a4c029..c69b895a8f 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/plain_report_formatter.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/plain_report_formatter.ipp @@ -108,6 +108,8 @@ plain_report_formatter::test_unit_report_start( test_unit const& tu, std::ostrea descr = "has passed"; else if( tr.p_skipped ) descr = "was skipped"; + else if( tr.p_timed_out ) + descr = "has timed out"; else if( tr.p_aborted ) descr = "was aborted"; else @@ -122,8 +124,9 @@ plain_report_formatter::test_unit_report_start( test_unit const& tu, std::ostrea return; } + // aborted test case within failed ones, timed-out TC exclusive with failed/aborted counter_t total_assertions = tr.p_assertions_passed + tr.p_assertions_failed; - counter_t total_tc = tr.p_test_cases_passed + tr.p_test_cases_warned + tr.p_test_cases_failed + tr.p_test_cases_skipped; + counter_t total_tc = tr.p_test_cases_passed + tr.p_test_cases_warned + tr.p_test_cases_failed + tr.p_test_cases_skipped + tr.p_test_cases_timed_out; if( total_assertions > 0 || total_tc > 0 || tr.p_warnings_failed > 0) ostr << " with:"; @@ -134,6 +137,8 @@ plain_report_formatter::test_unit_report_start( test_unit const& tu, std::ostrea print_stat_value( ostr, tr.p_test_cases_passed , m_indent, total_tc , "test case", "passed" ); print_stat_value( ostr, tr.p_test_cases_warned , m_indent, total_tc , "test case", "passed with warnings" ); print_stat_value( ostr, tr.p_test_cases_failed , m_indent, total_tc , "test case", "failed" ); + print_stat_value( ostr, tr.p_test_cases_timed_out, m_indent, total_tc , "test case", "timed-out" ); + print_stat_value( ostr, tr.p_test_suites_timed_out, m_indent, tr.p_test_suites, "test suite", "timed-out" ); print_stat_value( ostr, tr.p_test_cases_skipped, m_indent, total_tc , "test case", "skipped" ); print_stat_value( ostr, tr.p_test_cases_aborted, m_indent, total_tc , "test case", "aborted" ); print_stat_value( ostr, tr.p_assertions_passed , m_indent, total_assertions, "assertion", "passed" ); @@ -174,6 +179,12 @@ plain_report_formatter::do_confirmation_report( test_unit const& tu, std::ostrea return; } + if( tr.p_timed_out ) { + ostr << "*** The test " << tu.p_type_name << ' ' << quote() << tu.full_name() << " has timed out" + << "; see standard output for details\n"; + return; + } + if( tr.p_aborted ) { ostr << "*** The test " << tu.p_type_name << ' ' << quote() << tu.full_name() << " was aborted" << "; see standard output for details\n"; diff --git a/contrib/restricted/boost/test/include/boost/test/impl/progress_monitor.ipp b/contrib/restricted/boost/test/include/boost/test/impl/progress_monitor.ipp index 34149745cf..4aacb357a4 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/progress_monitor.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/progress_monitor.ipp @@ -52,7 +52,7 @@ struct progress_display { << "\n|----|----|----|----|----|----|----|----|----|----|" << std::endl; - if( !m_expected_count ) + if( !m_expected_count ) m_expected_count = 1; // prevent divide by zero } @@ -63,7 +63,7 @@ struct progress_display { // use of floating point ensures that both large and small counts // work correctly. static_cast<>() is also used several places - // to suppress spurious compiler warnings. + // to suppress spurious compiler warnings. unsigned int tics_needed = static_cast<unsigned int>( (static_cast<double>(m_count)/m_expected_count)*50.0 ); @@ -121,8 +121,12 @@ progress_monitor_impl& s_pm_impl() { static progress_monitor_impl the_inst; retu //____________________________________________________________________________// +BOOST_TEST_SINGLETON_CONS_IMPL(progress_monitor_t) + +//____________________________________________________________________________// + void -progress_monitor_t::test_start( counter_t test_cases_amount ) +progress_monitor_t::test_start( counter_t test_cases_amount, test_unit_id ) { s_pm_impl().m_color_output = runtime_config::get<bool>( runtime_config::btrt_color_output ); diff --git a/contrib/restricted/boost/test/include/boost/test/impl/results_collector.ipp b/contrib/restricted/boost/test/include/boost/test/impl/results_collector.ipp index fd74bdb65c..dfcd55fb24 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/results_collector.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/results_collector.ipp @@ -5,11 +5,9 @@ // See http://www.boost.org/libs/test for the library home page. // -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : implements Unit Test results collecting facility. +/// @file +/// Test results collecting facility. +/// // *************************************************************************** #ifndef BOOST_TEST_RESULTS_COLLECTOR_IPP_021105GER @@ -19,6 +17,7 @@ #include <boost/test/unit_test_log.hpp> #include <boost/test/results_collector.hpp> #include <boost/test/framework.hpp> +#include <boost/test/execution_monitor.hpp> #include <boost/test/tree/test_unit.hpp> #include <boost/test/tree/visitor.hpp> @@ -52,13 +51,19 @@ test_results::test_results() bool test_results::passed() const { + // if it is skipped, it is not passed. However, if any children is not failed/aborted + // then their skipped status is not taken into account. return !p_skipped && p_test_cases_failed == 0 && p_assertions_failed <= p_expected_failures && - p_test_cases_skipped == 0 && - !p_aborted; + // p_test_cases_skipped == 0 && + !p_timed_out && + p_test_cases_timed_out == 0 && + !aborted(); } +//____________________________________________________________________________// + bool test_results::aborted() const { @@ -67,11 +72,19 @@ test_results::aborted() const //____________________________________________________________________________// +bool +test_results::skipped() const +{ + return p_skipped; +} + +//____________________________________________________________________________// + int test_results::result_code() const { return passed() ? exit_success - : ( (p_assertions_failed > p_expected_failures || p_skipped ) + : ( (p_assertions_failed > p_expected_failures || p_skipped || p_timed_out || p_test_cases_timed_out ) ? exit_test_failure : exit_exception_failure ); } @@ -81,6 +94,7 @@ test_results::result_code() const void test_results::operator+=( test_results const& tr ) { + p_test_suites.value += tr.p_test_suites; p_assertions_passed.value += tr.p_assertions_passed; p_assertions_failed.value += tr.p_assertions_failed; p_warnings_failed.value += tr.p_warnings_failed; @@ -89,6 +103,8 @@ test_results::operator+=( test_results const& tr ) p_test_cases_failed.value += tr.p_test_cases_failed; p_test_cases_skipped.value += tr.p_test_cases_skipped; p_test_cases_aborted.value += tr.p_test_cases_aborted; + p_test_cases_timed_out.value += tr.p_test_cases_timed_out; + p_test_suites_timed_out.value += tr.p_test_suites_timed_out; p_duration_microseconds.value += tr.p_duration_microseconds; } @@ -97,6 +113,7 @@ test_results::operator+=( test_results const& tr ) void test_results::clear() { + p_test_suites.value = 0; p_assertions_passed.value = 0; p_assertions_failed.value = 0; p_warnings_failed.value = 0; @@ -106,9 +123,12 @@ test_results::clear() p_test_cases_failed.value = 0; p_test_cases_skipped.value = 0; p_test_cases_aborted.value = 0; + p_test_cases_timed_out.value = 0; + p_test_suites_timed_out.value = 0; p_duration_microseconds.value= 0; p_aborted.value = false; p_skipped.value = false; + p_timed_out.value = false; } //____________________________________________________________________________// @@ -125,14 +145,41 @@ struct results_collector_impl { results_collector_impl& s_rc_impl() { static results_collector_impl the_inst; return the_inst; } +// deletes the entries of results_collector_impl +class clear_subtree_result : public test_tree_visitor { +public: + clear_subtree_result(results_collector_impl& store) + : m_store( store ) + {} + +private: + bool visit( test_unit const& tu) BOOST_OVERRIDE + { + typedef std::map<test_unit_id,test_results>::iterator iterator; + iterator found = m_store.m_results_store.find(tu.p_id); + if(found != m_store.m_results_store.end()) { + m_store.m_results_store.erase( found ); + } + return true; + } + + results_collector_impl& m_store; +}; + } // local namespace //____________________________________________________________________________// +BOOST_TEST_SINGLETON_CONS_IMPL( results_collector_t ) + +//____________________________________________________________________________// + void -results_collector_t::test_start( counter_t ) +results_collector_t::test_start( counter_t, test_unit_id id ) { - s_rc_impl().m_results_store.clear(); + // deletes the results under id only + clear_subtree_result tree_clear(s_rc_impl()); + traverse_test_tree( id, tree_clear ); } //____________________________________________________________________________// @@ -154,7 +201,7 @@ class results_collect_helper : public test_tree_visitor { public: explicit results_collect_helper( test_results& tr, test_unit const& ts ) : m_tr( tr ), m_ts( ts ) {} - void visit( test_case const& tc ) + void visit( test_case const& tc ) BOOST_OVERRIDE { test_results const& tr = results_collector.results( tc.p_id ); m_tr += tr; @@ -165,8 +212,12 @@ public: else m_tr.p_test_cases_passed.value++; } - else if( tr.p_skipped ) + else if( tr.p_timed_out ) { + m_tr.p_test_cases_timed_out.value++; + } + else if( tr.p_skipped || !tc.is_enabled() ) { m_tr.p_test_cases_skipped.value++; + } else { if( tr.p_aborted ) m_tr.p_test_cases_aborted.value++; @@ -174,12 +225,16 @@ public: m_tr.p_test_cases_failed.value++; } } - bool test_suite_start( test_suite const& ts ) + bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { if( m_ts.p_id == ts.p_id ) return true; m_tr += results_collector.results( ts.p_id ); + m_tr.p_test_suites.value++; + + if( results_collector.results( ts.p_id ).p_timed_out ) + m_tr.p_test_suites_timed_out.value++; return false; } @@ -194,15 +249,12 @@ private: void results_collector_t::test_unit_finish( test_unit const& tu, unsigned long elapsed_in_microseconds ) { + test_results & tr = s_rc_impl().m_results_store[tu.p_id]; if( tu.p_type == TUT_SUITE ) { - results_collect_helper ch( s_rc_impl().m_results_store[tu.p_id], tu ); - - traverse_test_tree( tu, ch ); + results_collect_helper ch( tr, tu ); + traverse_test_tree( tu, ch, true ); // true to ignore the status: we need to count the skipped/disabled tests } else { - test_results & tr = s_rc_impl().m_results_store[tu.p_id]; - tr.p_duration_microseconds.value = elapsed_in_microseconds; - bool num_failures_match = tr.p_aborted || tr.p_assertions_failed >= tr.p_expected_failures; if( !num_failures_match ) BOOST_TEST_FRAMEWORK_MESSAGE( "Test case " << tu.full_name() << " has fewer failures than expected" ); @@ -211,6 +263,7 @@ results_collector_t::test_unit_finish( test_unit const& tu, unsigned long elapse if( !check_any_assertions ) BOOST_TEST_FRAMEWORK_MESSAGE( "Test case " << tu.full_name() << " did not check any assertions" ); } + tr.p_duration_microseconds.value = elapsed_in_microseconds; } //____________________________________________________________________________// @@ -219,14 +272,13 @@ void results_collector_t::test_unit_skipped( test_unit const& tu, const_string /*reason*/ ) { test_results& tr = s_rc_impl().m_results_store[tu.p_id]; - tr.clear(); tr.p_skipped.value = true; if( tu.p_type == TUT_SUITE ) { - test_case_counter tcc; - traverse_test_tree( tu, tcc ); + test_case_counter tcc(true); + traverse_test_tree( tu, tcc, true ); // true because need to count the disabled tests/units tr.p_test_cases_skipped.value = tcc.p_count; } @@ -235,6 +287,15 @@ results_collector_t::test_unit_skipped( test_unit const& tu, const_string /*reas //____________________________________________________________________________// void +results_collector_t::test_unit_timed_out(test_unit const& tu) +{ + test_results& tr = s_rc_impl().m_results_store[tu.p_id]; + tr.p_timed_out.value = true; +} + +//____________________________________________________________________________// + +void results_collector_t::assertion_result( unit_test::assertion_result ar ) { test_results& tr = s_rc_impl().m_results_store[framework::current_test_case_id()]; @@ -252,11 +313,14 @@ results_collector_t::assertion_result( unit_test::assertion_result ar ) //____________________________________________________________________________// void -results_collector_t::exception_caught( execution_exception const& ) +results_collector_t::exception_caught( execution_exception const& ex) { test_results& tr = s_rc_impl().m_results_store[framework::current_test_case_id()]; tr.p_assertions_failed.value++; + if( ex.code() == execution_exception::timeout_error ) { + tr.p_timed_out.value = true; + } } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/impl/results_reporter.ipp b/contrib/restricted/boost/test/include/boost/test/impl/results_reporter.ipp index 87c1172e12..90dc80ab51 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/results_reporter.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/results_reporter.ipp @@ -9,7 +9,7 @@ // // Version : $Revision$ // -// Description : result reporting facilties +// Description : result reporting facilities // *************************************************************************** #ifndef BOOST_TEST_RESULTS_REPORTER_IPP_020105GER @@ -59,12 +59,12 @@ struct results_reporter_impl : test_tree_visitor { {} // test tree visitor interface implementation - void visit( test_case const& tc ) + void visit( test_case const& tc ) BOOST_OVERRIDE { 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 ) + bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { m_formatter->test_unit_report_start( ts, *m_stream ); @@ -74,7 +74,7 @@ struct results_reporter_impl : test_tree_visitor { m_formatter->test_unit_report_finish( ts, *m_stream ); return false; } - void test_suite_finish( test_suite const& ts ) + void test_suite_finish( test_suite const& ts ) BOOST_OVERRIDE { m_formatter->test_unit_report_finish( ts, *m_stream ); } diff --git a/contrib/restricted/boost/test/include/boost/test/impl/test_framework_init_observer.ipp b/contrib/restricted/boost/test/include/boost/test/impl/test_framework_init_observer.ipp index 89f854aaed..4e9f49f700 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/test_framework_init_observer.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/test_framework_init_observer.ipp @@ -29,33 +29,16 @@ namespace unit_test { // ************** framework_init_observer_t ************** // // ************************************************************************** // -namespace { - -struct test_init_observer_check { - bool has_failure; - - void clear() - { - has_failure = false; - } -}; - - -test_init_observer_check& s_tioc_impl() { static test_init_observer_check the_inst; return the_inst; } - -} // local namespace - void framework_init_observer_t::clear() { - if(!framework::test_in_progress()) - s_tioc_impl().clear(); + m_has_failure = false; } //____________________________________________________________________________// void -framework_init_observer_t::test_start( counter_t ) +framework_init_observer_t::test_start( counter_t, test_unit_id ) { clear(); } @@ -65,11 +48,8 @@ framework_init_observer_t::test_start( counter_t ) void framework_init_observer_t::assertion_result( unit_test::assertion_result ar ) { - test_init_observer_check& tr = s_tioc_impl(); switch( ar ) { - case AR_TRIGGERED: break; - case AR_PASSED: break; - case AR_FAILED: tr.has_failure = true; break; + case AR_FAILED: m_has_failure = true; break; default: break; } @@ -80,14 +60,13 @@ framework_init_observer_t::assertion_result( unit_test::assertion_result ar ) void framework_init_observer_t::exception_caught( execution_exception const& ) { - test_init_observer_check& tr = s_tioc_impl(); - tr.has_failure = true; + m_has_failure = true; } void framework_init_observer_t::test_aborted() { - s_tioc_impl().has_failure = true; + m_has_failure = true; } @@ -96,7 +75,7 @@ framework_init_observer_t::test_aborted() bool framework_init_observer_t::has_failed() const { - return s_tioc_impl().has_failure; + return m_has_failure; } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/impl/test_tools.ipp b/contrib/restricted/boost/test/include/boost/test/impl/test_tools.ipp index 2956879326..03b631ebba 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/test_tools.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/test_tools.ipp @@ -16,6 +16,7 @@ #define BOOST_TEST_TEST_TOOLS_IPP_012205GER // Boost.Test +#include <boost/test/test_tools.hpp> #include <boost/test/unit_test_log.hpp> #include <boost/test/tools/context.hpp> #include <boost/test/tools/output_test_stream.hpp> @@ -59,6 +60,13 @@ namespace std { using ::wcscmp; } #endif # endif + +namespace boost { +namespace unit_test { + // local static variable, needed here for visibility reasons + lazy_ostream lazy_ostream::inst = lazy_ostream(); +}} + namespace boost { namespace test_tools { namespace tt_detail { @@ -106,6 +114,22 @@ print_log_value<unsigned char>::operator()( std::ostream& ostr, unsigned char t //____________________________________________________________________________// void +print_log_value<wchar_t>::operator()( std::ostream& ostr, wchar_t r ) +{ + std::mbstate_t state; + std::string mb(MB_CUR_MAX, '\0'); + std::size_t ret = std::wcrtomb(&mb[0], r, &state); + if( ret > 0) { + ostr << mb; + } + else { + ostr << "(wchar_t unable to convert)"; + } +} + +//____________________________________________________________________________// + +void print_log_value<char const*>::operator()( std::ostream& ostr, char const* t ) { ostr << ( t ? t : "null string" ); @@ -116,7 +140,12 @@ print_log_value<char const*>::operator()( std::ostream& ostr, char const* t ) void print_log_value<wchar_t const*>::operator()( std::ostream& ostr, wchar_t const* t ) { - ostr << ( t ? t : L"null string" ); + if(t) { + ostr << static_cast<const void*>(t); + } + else { + ostr << "null w-string"; + } } //____________________________________________________________________________// @@ -374,7 +403,9 @@ report_assertion( assertion_result const& ar, framework::assertion_result( AR_FAILED ); framework::test_unit_aborted( framework::current_test_unit() ); BOOST_TEST_I_THROW( execution_aborted() ); - return false; + // the previous line either throws or aborts and the return below is not reached + // return false; + BOOST_TEST_UNREACHABLE_RETURN(false); } return true; @@ -394,7 +425,7 @@ format_assertion_result( const_string expr_val, const_string details ) if( !details.is_empty() ) { if( first_char(details) != '[' ) - res.message().stream() << ". "; + res.message().stream() << ": "; else res.message().stream() << " "; @@ -723,7 +754,7 @@ output_test_stream::match_pattern( bool flush_stream ) for( std::size_t k = 1; k < (std::max)(best_pattern_start_index, best_stream_start_index); k++ ) { // 1 is for the current char c std::string s1(pretty_print_log(std::string(1, last_elements_ordered[(std::min)(k, best_pattern_start_index)]))); std::string s2(pretty_print_log(std::string(1, sub_str_suffix[(std::min)(k, best_stream_start_index)]))); - for( int h = (std::max)(s1.size(), s2.size()); h > 0; h--) + for( int h = static_cast<int>((std::max)(s1.size(), s2.size())); h > 0; h--) result.message() << "~"; } diff --git a/contrib/restricted/boost/test/include/boost/test/impl/test_tree.ipp b/contrib/restricted/boost/test/include/boost/test/impl/test_tree.ipp index e0839e3dd1..0872682ea6 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/test_tree.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/test_tree.ipp @@ -30,12 +30,10 @@ #include <boost/test/unit_test_parameters.hpp> -// Boost -#include <boost/timer.hpp> - // STL #include <algorithm> #include <vector> +#include <set> #include <boost/test/detail/suppress_warnings.hpp> @@ -124,7 +122,7 @@ test_unit::check_preconditions() const test_results const& test_rslt = unit_test::results_collector.results( dep_id ); if( !test_rslt.passed() ) { test_tools::assertion_result res(false); - res.message() << "dependency test " << dep.p_type_name << " \"" << dep.full_name() << "\" has failed"; + res.message() << "dependency test " << dep.p_type_name << " \"" << dep.full_name() << (test_rslt.skipped() ? "\" was skipped":"\" has failed"); return res; } @@ -241,14 +239,6 @@ test_suite::test_suite( const_string module_name ) void test_suite::add( test_unit* tu, counter_t expected_failures, unsigned timeout ) { - // check for clashing names #12597 - for( test_unit_id_list::const_iterator it(m_children.begin()), ite(m_children.end()); - it < ite; - ++it) { - BOOST_TEST_SETUP_ASSERT( tu->p_name != framework::get(*it, TUT_ANY).p_name, - "test unit with name '" + tu->p_name.value + std::string("' registered multiple times") ); - } - tu->p_timeout.value = timeout; m_children.push_back( tu->p_id ); @@ -274,20 +264,81 @@ test_suite::add( test_unit_generator const& gen, unsigned timeout ) //____________________________________________________________________________// void -test_suite::add( test_unit_generator const& gen, decorator::collector& decorators ) +test_suite::add( test_unit_generator const& gen, decorator::collector_t& decorators ) { test_unit* tu; while((tu = gen.next()) != 0) { decorators.store_in( *tu ); add( tu, 0 ); } + decorators.reset(); +} + +//____________________________________________________________________________// +void +test_suite::add( boost::shared_ptr<test_unit_generator> gen_ptr, decorator::collector_t& decorators ) +{ + std::pair<boost::shared_ptr<test_unit_generator>, std::vector<decorator::base_ptr> > tmp_p(gen_ptr, decorators.get_lazy_decorators() ); + m_generators.push_back(tmp_p); decorators.reset(); } //____________________________________________________________________________// void +test_suite::generate( ) +{ + typedef std::pair<boost::shared_ptr<test_unit_generator>, std::vector<decorator::base_ptr> > element_t; + + for(std::vector<element_t>::iterator it(m_generators.begin()), ite(m_generators.end()); + it < ite; + ++it) + { + test_unit* tu; + while((tu = it->first->next()) != 0) { + tu->p_decorators.value.insert( tu->p_decorators.value.end(), it->second.begin(), it->second.end() ); + //it->second.store_in( *tu ); + add( tu, 0 ); + } + + } + m_generators.clear(); + + #if 0 + test_unit* tu; + while((tu = gen.next()) != 0) { + decorators.store_in( *tu ); + add( tu, 0 ); + } + #endif +} + +//____________________________________________________________________________// + +void +test_suite::check_for_duplicate_test_cases() { + // check for clashing names #12597 + std::set<std::string> names; + for( test_unit_id_list::const_iterator it(m_children.begin()), ite(m_children.end()); + it < ite; + ++it) { + std::string name = framework::get(*it, TUT_ANY).p_name; + std::pair<std::set<std::string>::iterator, bool> ret = names.insert(name); + BOOST_TEST_SETUP_ASSERT(ret.second, + "test unit with name '" + + name + + std::string("' registered multiple times in the test suite '") + + this->p_name.value + + "'"); + } + + return; +} + +//____________________________________________________________________________// + +void test_suite::remove( test_unit_id id ) { test_unit_id_list::iterator it = std::find( m_children.begin(), m_children.end(), id ); @@ -401,7 +452,7 @@ normalize_test_case_name( const_string name ) } // sanitize all chars that might be used in runtime filters - static const char to_replace[] = { ':', '*', '@', '+', '!', '/' }; + static const char to_replace[] = { ':', '*', '@', '+', '!', '/', ',' }; for(std::size_t index = 0; index < sizeof(to_replace)/sizeof(to_replace[0]); index++) { @@ -417,7 +468,7 @@ normalize_test_case_name( const_string name ) // ************** auto_test_unit_registrar ************** // // ************************************************************************** // -auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::collector& decorators, counter_t exp_fail ) +auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::collector_t& decorators, counter_t exp_fail ) { framework::current_auto_test_suite().add( tc, exp_fail ); @@ -427,7 +478,7 @@ auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::co //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector& decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector_t& decorators ) { test_unit_id id = framework::current_auto_test_suite().get( ts_name ); @@ -450,13 +501,21 @@ auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_ //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector& decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector_t& decorators ) { framework::current_auto_test_suite().add( tc_gen, decorators ); } //____________________________________________________________________________// +auto_test_unit_registrar::auto_test_unit_registrar( boost::shared_ptr<test_unit_generator> tc_gen, decorator::collector_t& decorators ) +{ + framework::current_auto_test_suite().add( tc_gen, decorators ); +} + + +//____________________________________________________________________________// + auto_test_unit_registrar::auto_test_unit_registrar( int ) { framework::current_auto_test_suite( 0, false ); @@ -470,28 +529,49 @@ auto_test_unit_registrar::auto_test_unit_registrar( int ) // ************** global_fixture ************** // // ************************************************************************** // -global_fixture::global_fixture() +global_fixture::global_fixture(): registered(false) { framework::register_global_fixture( *this ); + registered = true; +} + +void global_fixture::unregister_from_framework() { + // not accessing the framework singleton after deregistering -> release + // of the observer from the framework + if(registered) { + framework::deregister_global_fixture( *this ); + } + registered = false; } global_fixture::~global_fixture() { - framework::deregister_global_fixture( *this ); + this->unregister_from_framework(); } // ************************************************************************** // // ************** global_configuration ************** // // ************************************************************************** // -global_configuration::global_configuration() +global_configuration::global_configuration(): registered(false) { framework::register_observer( *this ); + registered = true; +} + +void global_configuration::unregister_from_framework() +{ + // not accessing the framework singleton after deregistering -> release + // of the observer from the framework + if(registered) { + framework::deregister_observer( *this ); + } + registered = false; } global_configuration::~global_configuration() { - framework::deregister_observer( *this ); + this->unregister_from_framework(); } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_log.ipp b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_log.ipp index 2a6c0f4bc6..1b1e4eea9a 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_log.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_log.ipp @@ -131,11 +131,18 @@ struct unit_test_log_impl { typedef std::vector<unit_test_log_data_helper_impl> v_formatter_data_t; v_formatter_data_t m_log_formatter_data; + typedef std::vector<unit_test_log_data_helper_impl*> vp_formatter_data_t; + vp_formatter_data_t m_active_log_formatter_data; + // entry data log_entry_data m_entry_data; bool has_entry_in_progress() const { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl const&, current_logger_data, m_log_formatter_data ) { + for( vp_formatter_data_t::const_iterator it(m_active_log_formatter_data.begin()), ite(m_active_log_formatter_data.end()); + it < ite; + ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; if( current_logger_data.m_entry_in_progress ) return true; } @@ -155,25 +162,80 @@ struct unit_test_log_impl { unit_test_log_impl& s_log_impl() { static unit_test_log_impl the_inst; return the_inst; } -} // local namespace //____________________________________________________________________________// void -unit_test_log_t::test_start( counter_t test_cases_amount ) +log_entry_context( log_level l, unit_test_log_data_helper_impl& current_logger_data) { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( !current_logger_data.m_enabled || current_logger_data.get_log_level() == log_nothing ) + framework::context_generator const& context = framework::get_context(); + if( context.is_empty() ) + return; + + const_string frame; + current_logger_data.m_log_formatter->entry_context_start( current_logger_data.stream(), l ); + while( !(frame=context.next()).is_empty() ) + { + current_logger_data.m_log_formatter->log_entry_context( current_logger_data.stream(), l, frame ); + } + current_logger_data.m_log_formatter->entry_context_finish( current_logger_data.stream(), l ); +} + +//____________________________________________________________________________// + +void +clear_entry_context() +{ + framework::clear_context(); +} + +// convenience +typedef unit_test_log_impl::vp_formatter_data_t vp_logger_t; +typedef unit_test_log_impl::v_formatter_data_t v_logger_t; + +} // local namespace + +//____________________________________________________________________________// + +BOOST_TEST_SINGLETON_CONS_IMPL( unit_test_log_t ) + +void +unit_test_log_t::configure( ) +{ + // configure is not test_start: + // test_start pushes the necessary log information when the test module is starting, and implies configure. + // configure: should be called each time the set of loggers, stream or configuration is changed. + s_log_impl().m_active_log_formatter_data.clear(); + for( unit_test_log_impl::v_formatter_data_t::iterator it(s_log_impl().m_log_formatter_data.begin()), + ite(s_log_impl().m_log_formatter_data.end()); + it < ite; + ++it) + { + if( !it->m_enabled || it->get_log_level() == log_nothing ) continue; - current_logger_data.m_log_formatter->log_start( current_logger_data.stream(), test_cases_amount ); + s_log_impl().m_active_log_formatter_data.push_back(&*it); + it->m_entry_in_progress = false; + } +} - if( runtime_config::get<bool>( runtime_config::btrt_build_info ) ) - current_logger_data.m_log_formatter->log_build_info( current_logger_data.stream() ); +//____________________________________________________________________________// - //current_logger_data.stream().flush(); +void +unit_test_log_t::test_start( counter_t test_cases_amount, test_unit_id ) +{ + configure(); + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + + current_logger_data.m_log_formatter->log_start( current_logger_data.stream(), test_cases_amount ); + current_logger_data.m_log_formatter->log_build_info( + current_logger_data.stream(), + runtime_config::get<bool>( runtime_config::btrt_build_info )); - current_logger_data.m_entry_in_progress = false; + //current_logger_data.stream().flush(); } } @@ -182,12 +244,11 @@ unit_test_log_t::test_start( counter_t test_cases_amount ) void unit_test_log_t::test_finish() { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( !current_logger_data.m_enabled || current_logger_data.get_log_level() == log_nothing ) - continue; - + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; current_logger_data.m_log_formatter->log_finish( current_logger_data.stream() ); - current_logger_data.stream().flush(); } } @@ -207,8 +268,12 @@ unit_test_log_t::test_unit_start( test_unit const& tu ) { if( s_log_impl().has_entry_in_progress() ) *this << log::end(); - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units ) + + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + if( current_logger_data.get_log_level() > log_test_units ) continue; current_logger_data.m_log_formatter->test_unit_start( current_logger_data.stream(), tu ); } @@ -224,9 +289,11 @@ unit_test_log_t::test_unit_finish( test_unit const& tu, unsigned long elapsed ) if( s_log_impl().has_entry_in_progress() ) *this << log::end(); - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - - if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units ) + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + if( current_logger_data.get_log_level() > log_test_units ) continue; current_logger_data.m_log_formatter->test_unit_finish( current_logger_data.stream(), tu, elapsed ); @@ -241,8 +308,11 @@ unit_test_log_t::test_unit_skipped( test_unit const& tu, const_string reason ) if( s_log_impl().has_entry_in_progress() ) *this << log::end(); - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units ) + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + if( current_logger_data.get_log_level() > log_test_units ) continue; current_logger_data.m_log_formatter->test_unit_skipped( current_logger_data.stream(), tu, reason ); @@ -255,14 +325,34 @@ unit_test_log_t::test_unit_aborted( test_unit const& tu ) if( s_log_impl().has_entry_in_progress() ) *this << log::end(); - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( !current_logger_data.m_enabled || current_logger_data.get_log_level() > log_test_units ) + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + if( current_logger_data.get_log_level() > log_test_units ) continue; current_logger_data.m_log_formatter->test_unit_aborted(current_logger_data.stream(), tu ); } } +void +unit_test_log_t::test_unit_timed_out( test_unit const& tu ) +{ + if( s_log_impl().has_entry_in_progress() ) + *this << log::end(); + + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + if( current_logger_data.get_log_level() > log_test_units ) + continue; + + current_logger_data.m_log_formatter->test_unit_timed_out(current_logger_data.stream(), tu ); + } +} + //____________________________________________________________________________// void @@ -276,13 +366,16 @@ unit_test_log_t::exception_caught( execution_exception const& ex ) if( s_log_impl().has_entry_in_progress() ) *this << log::end(); - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; - if( current_logger_data.m_enabled && l >= current_logger_data.get_log_level() ) { + if( l >= current_logger_data.get_log_level() ) { current_logger_data.m_log_formatter->log_exception_start( current_logger_data.stream(), s_log_impl().m_checkpoint_data, ex ); - log_entry_context( l ); + log_entry_context( l, current_logger_data ); current_logger_data.m_log_formatter->log_exception_finish( current_logger_data.stream() ); } @@ -312,10 +405,11 @@ unit_test_log_t::operator<<( log::begin const& b ) if( s_log_impl().has_entry_in_progress() ) *this << log::end(); - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( current_logger_data.m_enabled ) { - current_logger_data.m_stream_state_saver->restore(); - } + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + current_logger_data.m_stream_state_saver->restore(); } s_log_impl().m_entry_data.clear(); @@ -338,10 +432,15 @@ unit_test_log_t& unit_test_log_t::operator<<( log::end const& ) { if( s_log_impl().has_entry_in_progress() ) { - log_entry_context( s_log_impl().m_entry_data.m_level ); - - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( current_logger_data.m_enabled && current_logger_data.m_entry_in_progress ) { + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + log_level l = s_log_impl().m_entry_data.m_level; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + if( current_logger_data.m_entry_in_progress ) { + if( l >= current_logger_data.get_log_level() ) { + log_entry_context( l, current_logger_data ); + } current_logger_data.m_log_formatter->log_entry_finish( current_logger_data.stream() ); } current_logger_data.m_entry_in_progress = false; @@ -376,53 +475,42 @@ unit_test_log_t::operator()( log_level l ) //____________________________________________________________________________// bool -unit_test_log_t::log_entry_start(output_format log_format) +log_entry_start(unit_test_log_data_helper_impl ¤t_logger_data) { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - - if( current_logger_data.m_format != log_format ) - continue; - - if( current_logger_data.m_entry_in_progress ) - return true; - - if( !current_logger_data.m_enabled ) - return false; - - switch( s_log_impl().m_entry_data.m_level ) { - case log_successful_tests: - current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_INFO ); - break; - case log_messages: - current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_MESSAGE ); - break; - case log_warnings: - current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_WARNING ); - break; - case log_all_errors: - case log_cpp_exception_errors: - case log_system_errors: - current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_ERROR ); - break; - case log_fatal_errors: - current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, - unit_test_log_formatter::BOOST_UTL_ET_FATAL_ERROR ); - break; - case log_nothing: - case log_test_units: - case invalid_log_level: - return false; - } - - current_logger_data.m_entry_in_progress = true; + if( current_logger_data.m_entry_in_progress ) return true; + + switch( s_log_impl().m_entry_data.m_level ) { + case log_successful_tests: + current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, + unit_test_log_formatter::BOOST_UTL_ET_INFO ); + break; + case log_messages: + current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, + unit_test_log_formatter::BOOST_UTL_ET_MESSAGE ); + break; + case log_warnings: + current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, + unit_test_log_formatter::BOOST_UTL_ET_WARNING ); + break; + case log_all_errors: + case log_cpp_exception_errors: + case log_system_errors: + current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, + unit_test_log_formatter::BOOST_UTL_ET_ERROR ); + break; + case log_fatal_errors: + current_logger_data.m_log_formatter->log_entry_start( current_logger_data.stream(), s_log_impl().m_entry_data, + unit_test_log_formatter::BOOST_UTL_ET_FATAL_ERROR ); + break; + case log_nothing: + case log_test_units: + case invalid_log_level: + return false; } - return false; + current_logger_data.m_entry_in_progress = true; + return true; } //____________________________________________________________________________// @@ -430,68 +518,42 @@ unit_test_log_t::log_entry_start(output_format log_format) unit_test_log_t& unit_test_log_t::operator<<( const_string value ) { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( current_logger_data.m_enabled && s_log_impl().m_entry_data.m_level >= current_logger_data.get_log_level() && !value.empty() && log_entry_start(current_logger_data.m_format) ) - current_logger_data.m_log_formatter->log_entry_value( current_logger_data.stream(), value ); - + if(value.empty()) { + return *this; } - return *this; -} - -//____________________________________________________________________________// -unit_test_log_t& -unit_test_log_t::operator<<( lazy_ostream const& value ) -{ - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( current_logger_data.m_enabled && s_log_impl().m_entry_data.m_level >= current_logger_data.get_log_level() && !value.empty() ) { - if( log_entry_start(current_logger_data.m_format) ) { + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = **it; + if( s_log_impl().m_entry_data.m_level >= current_logger_data.get_log_level() ) + if( log_entry_start(current_logger_data) ) { current_logger_data.m_log_formatter->log_entry_value( current_logger_data.stream(), value ); } - } } return *this; } //____________________________________________________________________________// -void -unit_test_log_t::log_entry_context( log_level l ) +unit_test_log_t& +unit_test_log_t::operator<<( lazy_ostream const& value ) { - framework::context_generator const& context = framework::get_context(); - if( context.is_empty() ) - return; - - const_string frame; - - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( current_logger_data.m_enabled ) { - current_logger_data.m_log_formatter->entry_context_start( current_logger_data.stream(), l ); - } + if(value.empty()) { + return *this; } - while( !(frame=context.next()).is_empty() ) + vp_logger_t& vloggers = s_log_impl().m_active_log_formatter_data; + for( vp_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( current_logger_data.m_enabled ) { - current_logger_data.m_log_formatter->log_entry_context( current_logger_data.stream(), l, frame ); + unit_test_log_data_helper_impl& current_logger_data = **it; + if( s_log_impl().m_entry_data.m_level >= current_logger_data.get_log_level() ) { + if( log_entry_start(current_logger_data) ) { + current_logger_data.m_log_formatter->log_entry_value( current_logger_data.stream(), value ); } } } - - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { - if( current_logger_data.m_enabled ) { - current_logger_data.m_log_formatter->entry_context_finish( current_logger_data.stream(), l ); - } - } -} - -//____________________________________________________________________________// - -void -unit_test_log_t::clear_entry_context() -{ - framework::clear_context(); + return *this; } //____________________________________________________________________________// @@ -502,7 +564,11 @@ unit_test_log_t::set_stream( std::ostream& str ) if( s_log_impl().has_entry_in_progress() ) return; - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; + current_logger_data.m_stream = &str; current_logger_data.m_stream_state_saver.reset( new io_saver_type( str ) ); } @@ -516,7 +582,10 @@ unit_test_log_t::set_stream( output_format log_format, std::ostream& str ) if( s_log_impl().has_entry_in_progress() ) return; - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; if( current_logger_data.m_format == log_format) { current_logger_data.m_stream = &str; current_logger_data.m_stream_state_saver.reset( new io_saver_type( str ) ); @@ -528,7 +597,10 @@ unit_test_log_t::set_stream( output_format log_format, std::ostream& str ) std::ostream* unit_test_log_t::get_stream( output_format log_format ) const { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; if( current_logger_data.m_format == log_format) { return current_logger_data.m_stream; } @@ -538,31 +610,43 @@ unit_test_log_t::get_stream( output_format log_format ) const //____________________________________________________________________________// -void +log_level unit_test_log_t::set_threshold_level( log_level lev ) { if( s_log_impl().has_entry_in_progress() || lev == invalid_log_level ) - return; + return invalid_log_level; - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + log_level ret = log_nothing; + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; + ret = (std::min)(ret, current_logger_data.m_log_formatter->get_log_level()); current_logger_data.m_log_formatter->set_log_level( lev ); } + return ret; } //____________________________________________________________________________// -void +log_level unit_test_log_t::set_threshold_level( output_format log_format, log_level lev ) { if( s_log_impl().has_entry_in_progress() || lev == invalid_log_level ) - return; + return invalid_log_level; - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + log_level ret = log_nothing; + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; if( current_logger_data.m_format == log_format) { + ret = current_logger_data.m_log_formatter->get_log_level(); current_logger_data.m_log_formatter->set_log_level( lev ); break; } } + return ret; } //____________________________________________________________________________// @@ -573,7 +657,10 @@ unit_test_log_t::set_format( output_format log_format ) if( s_log_impl().has_entry_in_progress() ) return; - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; current_logger_data.m_enabled = current_logger_data.m_format == log_format; } } @@ -586,7 +673,10 @@ unit_test_log_t::add_format( output_format log_format ) if( s_log_impl().has_entry_in_progress() ) return; - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; if( current_logger_data.m_format == log_format) { current_logger_data.m_enabled = true; break; @@ -598,7 +688,11 @@ unit_test_log_t::add_format( output_format log_format ) unit_test_log_formatter* unit_test_log_t::get_formatter( output_format log_format ) { - BOOST_TEST_FOREACH( unit_test_log_data_helper_impl&, current_logger_data, s_log_impl().m_log_formatter_data ) { + + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for( v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) + { + unit_test_log_data_helper_impl& current_logger_data = *it; if( current_logger_data.m_format == log_format) { return current_logger_data.m_log_formatter.get(); } @@ -611,10 +705,8 @@ void unit_test_log_t::add_formatter( unit_test_log_formatter* the_formatter ) { // remove only user defined logger - for(unit_test_log_impl::v_formatter_data_t::iterator it(s_log_impl().m_log_formatter_data.begin()), - ite(s_log_impl().m_log_formatter_data.end()); - it != ite; - ++it) + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for(v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) { if( it->m_format == OF_CUSTOM_LOGGER) { s_log_impl().m_log_formatter_data.erase(it); @@ -623,21 +715,23 @@ unit_test_log_t::add_formatter( unit_test_log_formatter* the_formatter ) } if( the_formatter ) { - s_log_impl().m_log_formatter_data.push_back( unit_test_log_data_helper_impl(the_formatter, OF_CUSTOM_LOGGER, true) ); + s_log_impl().m_active_log_formatter_data.clear(); // otherwise dandling references + vloggers.push_back( unit_test_log_data_helper_impl(the_formatter, OF_CUSTOM_LOGGER, true) ); } } void unit_test_log_t::set_formatter( unit_test_log_formatter* the_formatter ) { + if( s_log_impl().has_entry_in_progress() ) + return; + // remove only user defined logger log_level current_level = invalid_log_level; std::ostream *current_stream = 0; output_format previous_format = OF_INVALID; - for(unit_test_log_impl::v_formatter_data_t::iterator it(s_log_impl().m_log_formatter_data.begin()), - ite(s_log_impl().m_log_formatter_data.end()); - it != ite; - ++it) + v_logger_t& vloggers = s_log_impl().m_log_formatter_data; + for(v_logger_t::iterator it(vloggers.begin()), ite(vloggers.end()); it < ite; ++it) { if( it->m_enabled ) { if( current_level == invalid_log_level || it->m_format < previous_format || it->m_format == OF_CUSTOM_LOGGER) { @@ -654,6 +748,8 @@ unit_test_log_t::set_formatter( unit_test_log_formatter* the_formatter ) set_threshold_level(OF_CUSTOM_LOGGER, current_level); set_stream(OF_CUSTOM_LOGGER, *current_stream); } + + configure(); } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_main.ipp b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_main.ipp index 1780c6b93b..2fedecea44 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_main.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_main.ipp @@ -30,6 +30,7 @@ #include <boost/test/utils/basic_cstring/io.hpp> // Boost +#include <boost/core/ignore_unused.hpp> #include <boost/cstdlib.hpp> // STL @@ -37,6 +38,7 @@ #include <stdexcept> #include <iostream> #include <iomanip> +#include <iterator> #include <set> #include <boost/test/detail/suppress_warnings.hpp> @@ -66,15 +68,15 @@ private: m_os << "\n"; } - virtual void visit( test_case const& tc ) { report_test_unit( tc ); } - virtual bool test_suite_start( test_suite const& ts ) + void visit( test_case const& tc ) BOOST_OVERRIDE { report_test_unit( tc ); } + bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { if( m_indent >= 0 ) report_test_unit( ts ); m_indent += 4; return true; } - virtual void test_suite_finish( test_suite const& ) + void test_suite_finish( test_suite const& ) BOOST_OVERRIDE { m_indent -= 4; } @@ -131,11 +133,11 @@ private: } } - virtual void visit( test_case const& tc ) + void visit( test_case const& tc ) BOOST_OVERRIDE { report_test_unit( tc ); } - virtual bool test_suite_start( test_suite const& ts ) + bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { if( ts.p_parent_id == INV_TEST_UNIT_ID ) m_os << "digraph G {rankdir=LR;\n"; @@ -146,7 +148,7 @@ private: return true; } - virtual void test_suite_finish( test_suite const& ts ) + void test_suite_finish( test_suite const& ts ) BOOST_OVERRIDE { m_os << "}\n"; if( ts.p_parent_id == INV_TEST_UNIT_ID ) @@ -164,7 +166,7 @@ struct labels_collector : test_tree_visitor { std::set<std::string> const& labels() const { return m_labels; } private: - virtual bool visit( test_unit const& tu ) + bool visit( test_unit const& tu ) BOOST_OVERRIDE { m_labels.insert( tu.p_labels->begin(), tu.p_labels->end() ); return true; @@ -174,18 +176,35 @@ private: std::set<std::string> m_labels; }; +struct framework_shutdown_helper { + ~framework_shutdown_helper() { + try { + framework::shutdown(); + } + catch(...) { + std::cerr << "Boost.Test shutdown exception caught" << std::endl; + } + } +}; + } // namespace ut_detail // ************************************************************************** // // ************** unit_test_main ************** // // ************************************************************************** // + + int BOOST_TEST_DECL unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ) { int result_code = 0; + ut_detail::framework_shutdown_helper shutdown_helper; + boost::ignore_unused(shutdown_helper); + BOOST_TEST_I_TRY { + framework::init( init_func, argc, argv ); if( runtime_config::get<bool>( runtime_config::btrt_wait_for_debugger ) ) { @@ -247,14 +266,17 @@ unit_test_main( init_unit_test_func init_func, int argc, char* argv[] ) result_code = boost::exit_exception_failure; } + BOOST_TEST_I_CATCH( std::logic_error, ex ) { + results_reporter::get_stream() << "Test setup error: " << ex.what() << std::endl; + + result_code = boost::exit_exception_failure; + } BOOST_TEST_I_CATCHALL() { results_reporter::get_stream() << "Boost.Test framework internal error: unknown reason" << std::endl; result_code = boost::exit_exception_failure; } - framework::shutdown(); - return result_code; } diff --git a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_monitor.ipp b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_monitor.ipp index cfb41a239c..63a04c8f4f 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_monitor.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_monitor.ipp @@ -29,16 +29,19 @@ namespace boost { namespace unit_test { +// singleton pattern +BOOST_TEST_SINGLETON_CONS_IMPL(unit_test_monitor_t) + // ************************************************************************** // // ************** unit_test_monitor ************** // // ************************************************************************** // unit_test_monitor_t::error_level -unit_test_monitor_t::execute_and_translate( boost::function<void ()> const& func, unsigned timeout ) +unit_test_monitor_t::execute_and_translate( boost::function<void ()> const& func, unsigned long int timeout_microseconds ) { BOOST_TEST_I_TRY { p_catch_system_errors.value = runtime_config::get<bool>( runtime_config::btrt_catch_sys_errors ); - p_timeout.value = timeout; + p_timeout.value = timeout_microseconds; p_auto_start_dbg.value = runtime_config::get<bool>( runtime_config::btrt_auto_start_dbg ); p_use_alt_stack.value = runtime_config::get<bool>( runtime_config::btrt_use_alt_stack ); p_detect_fp_exceptions.value = runtime_config::get<bool>( runtime_config::btrt_detect_fp_except ); diff --git a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_parameters.ipp b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_parameters.ipp index 428c10116f..fec7bb94ca 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/unit_test_parameters.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/unit_test_parameters.ipp @@ -351,7 +351,7 @@ register_parameters( rt::parameters_store& store ) rt::env_var = "BOOST_TEST_LOG_SINK", rt::value_hint = "<stderr|stdout|file name>", rt::help = "Sets the log sink - the location " - "where Boost.Test writes the logs of the test execution. it allows to easily redirect the " + "where Boost.Test writes the logs of the test execution. It allows to easily redirect the " "test logs to file or standard streams. By default testing log is " "directed to standard output." )); @@ -380,8 +380,7 @@ register_parameters( rt::parameters_store& store ) , #endif rt::help = "Combines an effect of " + btrt_report_format + - " and " + btrt_log_format + " parameters. This parameter has higher priority " - "than either one of them. In other words if this parameter is specified " + " and " + btrt_log_format + " parameters. 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 " diff --git a/contrib/restricted/boost/test/include/boost/test/impl/xml_log_formatter.ipp b/contrib/restricted/boost/test/include/boost/test/impl/xml_log_formatter.ipp index ef44f1eade..e244d4d5f0 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/xml_log_formatter.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/xml_log_formatter.ipp @@ -63,16 +63,18 @@ xml_log_formatter::log_finish( std::ostream& ostr ) //____________________________________________________________________________// void -xml_log_formatter::log_build_info( std::ostream& ostr ) +xml_log_formatter::log_build_info( std::ostream& ostr, bool log_build_info ) { - ostr << "<BuildInfo" - << " 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 << '\"' - << "/>"; + if( log_build_info ) { + ostr << "<BuildInfo" + << " 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 << '\"' + << "/>"; + } } //____________________________________________________________________________// @@ -106,7 +108,7 @@ void xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu, const_string reason ) { ostr << "<" << tu_type_name( tu ) - << " name" << utils::attr_value() << tu.p_name + << " name" << utils::attr_value() << tu.p_name.get() << " skipped" << utils::attr_value() << "yes" << " reason" << utils::attr_value() << reason << "/>"; diff --git a/contrib/restricted/boost/test/include/boost/test/impl/xml_report_formatter.ipp b/contrib/restricted/boost/test/include/boost/test/impl/xml_report_formatter.ipp index 424ef4ba44..2718895b80 100644 --- a/contrib/restricted/boost/test/include/boost/test/impl/xml_report_formatter.ipp +++ b/contrib/restricted/boost/test/include/boost/test/impl/xml_report_formatter.ipp @@ -59,6 +59,8 @@ xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& descr = "passed"; else if( tr.p_skipped ) descr = "skipped"; + else if( tr.p_timed_out ) + descr = "timed-out"; else if( tr.p_aborted ) descr = "aborted"; else @@ -70,14 +72,18 @@ xml_report_formatter::test_unit_report_start( test_unit const& tu, std::ostream& << " 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; + << " expected_failures" << utils::attr_value() << tr.p_expected_failures + ; if( tu.p_type == TUT_SUITE ) { 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; + << " test_cases_aborted" << utils::attr_value() << tr.p_test_cases_aborted + << " test_cases_timed_out" << utils::attr_value() << tr.p_test_cases_timed_out + << " test_suites_timed_out"<< utils::attr_value() << tr.p_test_suites_timed_out + ; } ostr << '>'; diff --git a/contrib/restricted/boost/test/include/boost/test/output/compiler_log_formatter.hpp b/contrib/restricted/boost/test/include/boost/test/output/compiler_log_formatter.hpp index 50359334b1..ba4e1649f5 100644 --- a/contrib/restricted/boost/test/include/boost/test/output/compiler_log_formatter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/output/compiler_log_formatter.hpp @@ -16,6 +16,8 @@ #include <boost/test/detail/global_typedef.hpp> #include <boost/test/unit_test_log_formatter.hpp> +#include <boost/test/utils/setcolor.hpp> + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -31,34 +33,35 @@ namespace output { //!@brief Log formatter for the Human Readable Format (HRF) log format class BOOST_TEST_DECL compiler_log_formatter : public unit_test_log_formatter { public: - compiler_log_formatter() : m_color_output( false ) {} + compiler_log_formatter() : m_color_output( false ), m_color_state() {} // Formatter interface - void log_start( std::ostream&, counter_t test_cases_amount ); - void log_finish( std::ostream& ); - void log_build_info( std::ostream& ); + void log_start( std::ostream&, counter_t test_cases_amount ) BOOST_OVERRIDE; + void log_finish( std::ostream& ) BOOST_OVERRIDE; + void log_build_info( std::ostream&, bool ) BOOST_OVERRIDE; - void test_unit_start( std::ostream&, test_unit const& tu ); - void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ); - void test_unit_skipped( std::ostream&, test_unit const& tu, const_string reason ); + void test_unit_start( std::ostream&, test_unit const& tu ) BOOST_OVERRIDE; + void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ) BOOST_OVERRIDE; + void test_unit_skipped( std::ostream&, test_unit const& tu, const_string reason ) BOOST_OVERRIDE; - void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ); - void log_exception_finish( std::ostream& ); + void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ) BOOST_OVERRIDE; + void log_exception_finish( std::ostream& ) BOOST_OVERRIDE; - void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ); - void log_entry_value( std::ostream&, const_string value ); - void log_entry_value( std::ostream&, lazy_ostream const& value ); - void log_entry_finish( std::ostream& ); + void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ) BOOST_OVERRIDE; + void log_entry_value( std::ostream&, const_string value ) BOOST_OVERRIDE; + void log_entry_value( std::ostream&, lazy_ostream const& value ) BOOST_OVERRIDE; + void log_entry_finish( std::ostream& ) BOOST_OVERRIDE; - void entry_context_start( std::ostream&, log_level ); - void log_entry_context( std::ostream&, log_level l, const_string ); - void entry_context_finish( std::ostream&, log_level l ); + void entry_context_start( std::ostream&, log_level ) BOOST_OVERRIDE; + void log_entry_context( std::ostream&, log_level l, const_string ) BOOST_OVERRIDE; + void entry_context_finish( std::ostream&, log_level l ) BOOST_OVERRIDE; protected: virtual void print_prefix( std::ostream&, const_string file, std::size_t line ); // Data members bool m_color_output; + utils::setcolor::state m_color_state; }; } // namespace output diff --git a/contrib/restricted/boost/test/include/boost/test/output/junit_log_formatter.hpp b/contrib/restricted/boost/test/include/boost/test/output/junit_log_formatter.hpp index 713d3b016c..9695683572 100644 --- a/contrib/restricted/boost/test/include/boost/test/output/junit_log_formatter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/output/junit_log_formatter.hpp @@ -99,30 +99,31 @@ public: } // Formatter interface - void log_start( std::ostream&, counter_t test_cases_amount ); - void log_finish( std::ostream& ); - void log_build_info( std::ostream& ); + void log_start( std::ostream&, counter_t test_cases_amount ) BOOST_OVERRIDE; + void log_finish( std::ostream& ) BOOST_OVERRIDE; + void log_build_info( std::ostream&, bool ) BOOST_OVERRIDE; - void test_unit_start( std::ostream&, test_unit const& tu ); - void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ); - void test_unit_skipped( std::ostream&, test_unit const& tu, const_string reason ); - void test_unit_aborted( std::ostream& os, test_unit const& tu ); + void test_unit_start( std::ostream&, test_unit const& tu ) BOOST_OVERRIDE; + void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ) BOOST_OVERRIDE; + void test_unit_skipped( std::ostream&, test_unit const& tu, const_string reason ) BOOST_OVERRIDE; + void test_unit_aborted( std::ostream& os, test_unit const& tu ) BOOST_OVERRIDE; + void test_unit_timed_out( std::ostream& os, test_unit const& tu) BOOST_OVERRIDE; - void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ); - void log_exception_finish( std::ostream& ); + void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ) BOOST_OVERRIDE; + void log_exception_finish( std::ostream& ) BOOST_OVERRIDE; - void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ); + void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ) BOOST_OVERRIDE; using unit_test_log_formatter::log_entry_value; // bring base class functions into overload set - void log_entry_value( std::ostream&, const_string value ); - void log_entry_finish( std::ostream& ); + void log_entry_value( std::ostream&, const_string value ) BOOST_OVERRIDE; + void log_entry_finish( std::ostream& ) BOOST_OVERRIDE; - void entry_context_start( std::ostream&, log_level ); - void log_entry_context( std::ostream&, log_level, const_string ); - void entry_context_finish( std::ostream&, log_level ); + void entry_context_start( std::ostream&, log_level ) BOOST_OVERRIDE; + void log_entry_context( std::ostream&, log_level, const_string ) BOOST_OVERRIDE; + void entry_context_finish( std::ostream&, log_level ) BOOST_OVERRIDE; //! Discards changes in the log level - virtual void set_log_level(log_level ll) + void set_log_level(log_level ll) BOOST_OVERRIDE { if(ll > log_successful_tests && ll < log_messages) ll = log_successful_tests; @@ -135,7 +136,7 @@ public: //! Instead of a regular stream, returns a file name corresponding to //! the current master test suite. If the file already exists, adds an index //! to it. - virtual std::string get_default_stream_description() const; + std::string get_default_stream_description() const BOOST_OVERRIDE; private: diff --git a/contrib/restricted/boost/test/include/boost/test/output/plain_report_formatter.hpp b/contrib/restricted/boost/test/include/boost/test/output/plain_report_formatter.hpp index 8c50964597..82041cec68 100644 --- a/contrib/restricted/boost/test/include/boost/test/output/plain_report_formatter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/output/plain_report_formatter.hpp @@ -36,13 +36,13 @@ public: plain_report_formatter() : m_indent( 0 ), m_color_output( false ) {} // Formatter interface - void results_report_start( std::ostream& ostr ); - void results_report_finish( std::ostream& ostr ); + void results_report_start( std::ostream& ostr ) BOOST_OVERRIDE; + void results_report_finish( std::ostream& ostr ) BOOST_OVERRIDE; - void test_unit_report_start( test_unit const&, std::ostream& ostr ); - void test_unit_report_finish( test_unit const&, std::ostream& ostr ); + void test_unit_report_start( test_unit const&, std::ostream& ostr ) BOOST_OVERRIDE; + void test_unit_report_finish( test_unit const&, std::ostream& ostr ) BOOST_OVERRIDE; - void do_confirmation_report( test_unit const&, std::ostream& ostr ); + void do_confirmation_report( test_unit const&, std::ostream& ostr ) BOOST_OVERRIDE; private: // Data members diff --git a/contrib/restricted/boost/test/include/boost/test/output/xml_log_formatter.hpp b/contrib/restricted/boost/test/include/boost/test/output/xml_log_formatter.hpp index 1d8dec0f95..cbea180bde 100644 --- a/contrib/restricted/boost/test/include/boost/test/output/xml_log_formatter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/output/xml_log_formatter.hpp @@ -37,25 +37,25 @@ namespace output { class xml_log_formatter : public unit_test_log_formatter { public: // Formatter interface - void log_start( std::ostream&, counter_t test_cases_amount ); - void log_finish( std::ostream& ); - void log_build_info( std::ostream& ); + void log_start( std::ostream&, counter_t test_cases_amount ) BOOST_OVERRIDE; + void log_finish( std::ostream& ) BOOST_OVERRIDE; + void log_build_info( std::ostream&, bool ) BOOST_OVERRIDE; - void test_unit_start( std::ostream&, test_unit const& tu ); - void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ); - void test_unit_skipped( std::ostream&, test_unit const& tu, const_string reason ); + void test_unit_start( std::ostream&, test_unit const& tu ) BOOST_OVERRIDE; + void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed ) BOOST_OVERRIDE; + void test_unit_skipped( std::ostream&, test_unit const& tu, const_string reason ) BOOST_OVERRIDE; - void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ); - void log_exception_finish( std::ostream& ); + void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex ) BOOST_OVERRIDE; + void log_exception_finish( std::ostream& ) BOOST_OVERRIDE; - void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ); + void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let ) BOOST_OVERRIDE; using unit_test_log_formatter::log_entry_value; // bring base class functions into overload set - void log_entry_value( std::ostream&, const_string value ); - void log_entry_finish( std::ostream& ); + void log_entry_value( std::ostream&, const_string value ) BOOST_OVERRIDE; + void log_entry_finish( std::ostream& ) BOOST_OVERRIDE; - void entry_context_start( std::ostream&, log_level ); - void log_entry_context( std::ostream&, log_level, const_string ); - void entry_context_finish( std::ostream&, log_level ); + void entry_context_start( std::ostream&, log_level ) BOOST_OVERRIDE; + void log_entry_context( std::ostream&, log_level, const_string ) BOOST_OVERRIDE; + void entry_context_finish( std::ostream&, log_level ) BOOST_OVERRIDE; private: // Data members diff --git a/contrib/restricted/boost/test/include/boost/test/output/xml_report_formatter.hpp b/contrib/restricted/boost/test/include/boost/test/output/xml_report_formatter.hpp index ca5e47182f..555377f470 100644 --- a/contrib/restricted/boost/test/include/boost/test/output/xml_report_formatter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/output/xml_report_formatter.hpp @@ -34,13 +34,13 @@ namespace output { class xml_report_formatter : public results_reporter::format { public: // Formatter interface - void results_report_start( std::ostream& ostr ); - void results_report_finish( std::ostream& ostr ); + void results_report_start( std::ostream& ostr ) BOOST_OVERRIDE; + void results_report_finish( std::ostream& ostr ) BOOST_OVERRIDE; - void test_unit_report_start( test_unit const&, std::ostream& ostr ); - void test_unit_report_finish( test_unit const&, std::ostream& ostr ); + void test_unit_report_start( test_unit const&, std::ostream& ostr ) BOOST_OVERRIDE; + void test_unit_report_finish( test_unit const&, std::ostream& ostr ) BOOST_OVERRIDE; - void do_confirmation_report( test_unit const&, std::ostream& ostr ); + void do_confirmation_report( test_unit const&, std::ostream& ostr ) BOOST_OVERRIDE; }; } // namespace output diff --git a/contrib/restricted/boost/test/include/boost/test/progress_monitor.hpp b/contrib/restricted/boost/test/include/boost/test/progress_monitor.hpp index 2f661f5825..cc188d6372 100644 --- a/contrib/restricted/boost/test/include/boost/test/progress_monitor.hpp +++ b/contrib/restricted/boost/test/include/boost/test/progress_monitor.hpp @@ -14,7 +14,6 @@ // Boost.Test #include <boost/test/tree/observer.hpp> -#include <boost/test/utils/trivial_singleton.hpp> // STL #include <iosfwd> // for std::ostream& @@ -31,17 +30,17 @@ namespace unit_test { // ************************************************************************** // /// This class implements test observer interface and updates test progress as test units finish or get aborted -class BOOST_TEST_DECL progress_monitor_t : public test_observer, public singleton<progress_monitor_t> { +class BOOST_TEST_DECL progress_monitor_t : public test_observer { public: /// @name Test observer interface /// @{ - virtual void test_start( counter_t test_cases_amount ); - virtual void test_aborted(); + void test_start( counter_t test_cases_amount, test_unit_id ) BOOST_OVERRIDE; + void test_aborted() BOOST_OVERRIDE; - virtual void test_unit_finish( test_unit const&, unsigned long ); - virtual void test_unit_skipped( test_unit const&, const_string ); + void test_unit_finish( test_unit const&, unsigned long ) BOOST_OVERRIDE; + void test_unit_skipped( test_unit const&, const_string ) BOOST_OVERRIDE; - virtual int priority() { return 4; } + int priority() BOOST_OVERRIDE { return 4; } /// @} /// @name Configuration @@ -49,7 +48,7 @@ public: void set_stream( std::ostream& ); /// @} -private: + /// Singleton pattern BOOST_TEST_SINGLETON_CONS( progress_monitor_t ) }; // progress_monitor_t diff --git a/contrib/restricted/boost/test/include/boost/test/results_collector.hpp b/contrib/restricted/boost/test/include/boost/test/results_collector.hpp index 3acd7b87bc..b8edfffdb4 100644 --- a/contrib/restricted/boost/test/include/boost/test/results_collector.hpp +++ b/contrib/restricted/boost/test/include/boost/test/results_collector.hpp @@ -21,7 +21,6 @@ #include <boost/test/detail/global_typedef.hpp> #include <boost/test/detail/fwd_decl.hpp> -#include <boost/test/utils/trivial_singleton.hpp> #include <boost/test/utils/class_properties.hpp> #include <boost/test/detail/suppress_warnings.hpp> @@ -63,6 +62,7 @@ public: (test_results) (results_collect_helper) ) bool_prop; + counter_prop p_test_suites; //!< Number of test suites counter_prop p_assertions_passed; //!< Number of successful assertions counter_prop p_assertions_failed; //!< Number of failing assertions counter_prop p_warnings_failed; //!< Number of warnings @@ -72,13 +72,22 @@ public: counter_prop p_test_cases_failed; //!< Number of failing test cases counter_prop p_test_cases_skipped; //!< Number of skipped test cases counter_prop p_test_cases_aborted; //!< Number of aborted test cases + counter_prop p_test_cases_timed_out; //!< Number of timed out test cases + counter_prop p_test_suites_timed_out; //!< Number of timed out test suites counter_prop p_duration_microseconds; //!< Duration of the test in microseconds bool_prop p_aborted; //!< Indicates that the test unit execution has been aborted bool_prop p_skipped; //!< Indicates that the test unit execution has been skipped + bool_prop p_timed_out; //!< Indicates that the test unit has timed out /// Returns true if test unit passed bool passed() const; + /// Returns true if test unit skipped + /// + /// For test suites, this indicates if the test suite itself has been marked as + /// skipped, and not if the test suite contains any skipped test. + bool skipped() const; + /// Returns true if the test unit was aborted (hard failure) bool aborted() const; @@ -88,7 +97,7 @@ public: /// @returns /// - @c boost::exit_success on success, /// - @c boost::exit_exception_failure in case test unit - /// was aborted for any reason (incuding uncaught exception) + /// was aborted for any reason (including uncaught exception) /// - and @c boost::exit_test_failure otherwise int result_code() const; @@ -109,27 +118,28 @@ public: /// of the test tree. /// /// @see boost::unit_test::test_observer -class BOOST_TEST_DECL results_collector_t : public test_observer, public singleton<results_collector_t> { +class BOOST_TEST_DECL results_collector_t : public test_observer { public: - virtual void test_start( counter_t ); + void test_start( counter_t, test_unit_id ) BOOST_OVERRIDE; - virtual void test_unit_start( test_unit const& ); - virtual void test_unit_finish( test_unit const&, unsigned long ); - virtual void test_unit_skipped( test_unit const&, const_string ); - virtual void test_unit_aborted( test_unit const& ); + void test_unit_start( test_unit const& ) BOOST_OVERRIDE; + void test_unit_finish( test_unit const&, unsigned long ) BOOST_OVERRIDE; + void test_unit_skipped( test_unit const&, const_string ) BOOST_OVERRIDE; + void test_unit_aborted( test_unit const& ) BOOST_OVERRIDE; + void test_unit_timed_out( test_unit const& ) BOOST_OVERRIDE; - virtual void assertion_result( unit_test::assertion_result ); - virtual void exception_caught( execution_exception const& ); + void assertion_result( unit_test::assertion_result ) BOOST_OVERRIDE; + void exception_caught( execution_exception const& ) BOOST_OVERRIDE; - virtual int priority() { return 3; } + int priority() BOOST_OVERRIDE { return 3; } /// Results access per test unit /// /// @param[in] tu_id id of a test unit test_results const& results( test_unit_id tu_id ) const; -private: + /// Singleton pattern BOOST_TEST_SINGLETON_CONS( results_collector_t ) }; diff --git a/contrib/restricted/boost/test/include/boost/test/test_framework_init_observer.hpp b/contrib/restricted/boost/test/include/boost/test/test_framework_init_observer.hpp index cdf5ef5edd..16ee989106 100644 --- a/contrib/restricted/boost/test/include/boost/test/test_framework_init_observer.hpp +++ b/contrib/restricted/boost/test/include/boost/test/test_framework_init_observer.hpp @@ -18,8 +18,6 @@ #include <boost/test/detail/global_typedef.hpp> #include <boost/test/detail/fwd_decl.hpp> -#include <boost/test/utils/trivial_singleton.hpp> - #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -33,16 +31,18 @@ namespace unit_test { /// This class collects the state of the init/termination of the unit test framework. /// /// @see boost::unit_test::test_observer -class BOOST_TEST_DECL framework_init_observer_t : public test_observer, public singleton<framework_init_observer_t> { +class BOOST_TEST_DECL framework_init_observer_t : public test_observer { public: - virtual void test_start( counter_t ); + framework_init_observer_t(): m_has_failure( false ) {} + + void test_start( counter_t, test_unit_id ) BOOST_OVERRIDE; - virtual void assertion_result( unit_test::assertion_result ); - virtual void exception_caught( execution_exception const& ); - virtual void test_aborted(); + void assertion_result( unit_test::assertion_result ) BOOST_OVERRIDE; + void exception_caught( execution_exception const& ) BOOST_OVERRIDE; + void test_aborted() BOOST_OVERRIDE; - virtual int priority() { return 0; } + int priority() BOOST_OVERRIDE { return 0; } void clear(); @@ -50,11 +50,9 @@ public: bool has_failed( ) const; private: - BOOST_TEST_SINGLETON_CONS( framework_init_observer_t ) + bool m_has_failure; }; -BOOST_TEST_SINGLETON_INST( framework_init_observer ) - } // namespace unit_test } // namespace boost diff --git a/contrib/restricted/boost/test/include/boost/test/tools/assertion.hpp b/contrib/restricted/boost/test/include/boost/test/tools/assertion.hpp index cca2f52beb..39eab3b03b 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/assertion.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/assertion.hpp @@ -65,12 +65,12 @@ namespace assertion { namespace op { #define BOOST_TEST_FOR_EACH_COMP_OP(action) \ - action( < , LT, >= ) \ - action( <=, LE, > ) \ - action( > , GT, <= ) \ - action( >=, GE, < ) \ - action( ==, EQ, != ) \ - action( !=, NE, == ) \ + action( < , LT, >=, GE ) \ + action( <=, LE, > , GT ) \ + action( > , GT, <=, LE ) \ + action( >=, GE, < , LT ) \ + action( ==, EQ, !=, NE ) \ + action( !=, NE, ==, EQ ) \ /**/ //____________________________________________________________________________// @@ -78,23 +78,23 @@ namespace op { #ifndef BOOST_NO_CXX11_DECLTYPE #define BOOST_TEST_FOR_EACH_CONST_OP(action)\ - action(->*, MEMP, ->* ) \ + action(->*, MEMP, ->*, MEMP ) \ \ - action( * , MUL, * ) \ - action( / , DIV, / ) \ - action( % , MOD, % ) \ + action( * , MUL , * , MUL ) \ + action( / , DIV , / , DIV ) \ + action( % , MOD , % , MOD ) \ \ - action( + , ADD, + ) \ - action( - , SUB, - ) \ + action( + , ADD , + , ADD ) \ + action( - , SUB , - , SUB ) \ \ - action( <<, LSH, << ) \ - action( >>, RSH, >> ) \ + action( <<, LSH , << , LSH ) \ + action( >>, RSH , >> , RSH ) \ \ BOOST_TEST_FOR_EACH_COMP_OP(action) \ \ - action( & , BAND, & ) \ - action( ^ , XOR, ^ ) \ - action( | , BOR, | ) \ + action( & , BAND, & , BAND ) \ + action( ^ , XOR , ^ , XOR ) \ + action( | , BOR , | , BOR ) \ /**/ #else @@ -108,17 +108,17 @@ namespace op { //____________________________________________________________________________// #define BOOST_TEST_FOR_EACH_MUT_OP(action) \ - action( = , SET , = ) \ - action( +=, IADD, += ) \ - action( -=, ISUB, -= ) \ - action( *=, IMUL, *= ) \ - action( /=, IDIV, /= ) \ - action( %=, IMOD, %= ) \ - action(<<=, ILSH, <<=) \ - action(>>=, IRSH, >>=) \ - action( &=, IAND, &= ) \ - action( ^=, IXOR, ^= ) \ - action( |=, IOR , |= ) \ + action( = , SET , = , SET ) \ + action( +=, IADD, += , IADD ) \ + action( -=, ISUB, -= , ISUB ) \ + action( *=, IMUL, *= , IMUL ) \ + action( /=, IDIV, /= , IDIV ) \ + action( %=, IMOD, %= , IMOD ) \ + action(<<=, ILSH, <<=, ILSH ) \ + action(>>=, IRSH, >>=, IRSH ) \ + action( &=, IAND, &= , IAND ) \ + action( ^=, IXOR, ^= , IXOR ) \ + action( |=, IOR , |= , IOR ) \ /**/ //____________________________________________________________________________// @@ -132,11 +132,20 @@ namespace op { # define DEDUCE_RESULT_TYPE( oper ) bool #endif -#define DEFINE_CONST_OPER( oper, name, rev ) \ +#define DEFINE_CONST_OPER_FWD_DECL( oper, name, rev, name_inverse ) \ template<typename Lhs, typename Rhs, \ typename Enabler=void> \ +struct name; \ +/**/ + +BOOST_TEST_FOR_EACH_CONST_OP( DEFINE_CONST_OPER_FWD_DECL ) + +#define DEFINE_CONST_OPER( oper, name, rev, name_inverse ) \ +template<typename Lhs, typename Rhs, \ + typename Enabler> \ struct name { \ typedef DEDUCE_RESULT_TYPE( oper ) result_type; \ + typedef name_inverse<Lhs, Rhs> inverse; \ \ static result_type \ eval( Lhs const& lhs, Rhs const& rhs ) \ @@ -155,6 +164,8 @@ struct name { \ << tt_detail::print_helper( rhs ); \ } \ \ + static char const* forward() \ + { return " " #oper " "; } \ static char const* revert() \ { return " " #rev " "; } \ }; \ @@ -184,7 +195,7 @@ public: template<typename T> struct RhsT : remove_const<typename remove_reference<T>::type> {}; -#define ADD_OP_SUPPORT( oper, name, _ ) \ +#define ADD_OP_SUPPORT( oper, name, _, _i ) \ template<typename T> \ binary_expr<ExprType,T, \ op::name<ValType,typename RhsT<T>::type> > \ @@ -199,7 +210,7 @@ public: /**/ #else -#define ADD_OP_SUPPORT( oper, name, _ ) \ +#define ADD_OP_SUPPORT( oper, name, _, _i ) \ template<typename T> \ binary_expr<ExprType,typename boost::decay<T const>::type, \ op::name<ValType,typename boost::decay<T const>::type> >\ @@ -277,11 +288,11 @@ public: } void report( std::ostream& ostr ) const { - ostr << tt_detail::print_helper( m_value ); + ostr << tt_detail::print_helper( value() ); } // Mutating operators -#define ADD_OP_SUPPORT( OPER, ID, _ ) \ +#define ADD_OP_SUPPORT( OPER, ID, _, _i)\ template<typename U> \ value_expr<T>& \ operator OPER( U const& rhs ) \ @@ -309,8 +320,11 @@ public: private: template<typename U> - static void format_message( wrap_stringstream& ostr, U const& v ) { ostr << "[(bool)" << v << " is false]"; } - static void format_message( wrap_stringstream& /*ostr*/, bool /*v*/ ) {} + static void format_message( wrap_stringstream& ostr, U const& v ) + { + ostr << "['" << tt_detail::print_helper(v) << "' evaluates to false]"; + } + static void format_message( wrap_stringstream& /*ostr*/, bool /*v*/ ) {} static void format_message( wrap_stringstream& /*ostr*/, assertion_result const& /*v*/ ) {} // Data members diff --git a/contrib/restricted/boost/test/include/boost/test/tools/collection_comparison_op.hpp b/contrib/restricted/boost/test/include/boost/test/tools/collection_comparison_op.hpp index 864103fb4a..55d63301b3 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/collection_comparison_op.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/collection_comparison_op.hpp @@ -20,6 +20,7 @@ // Boost #include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> #include <boost/utility/enable_if.hpp> #include <boost/type_traits/decay.hpp> @@ -89,16 +90,19 @@ lexicographic_compare( Lhs const& lhs, Rhs const& rhs ) if( element_ar && !reverse_ar ) return ar; // a<=b and !(b<=a) => a < b => return true - if( element_ar || !reverse_ar ) + if( element_ar || !reverse_ar ) { continue; // (a<=b and b<=a) or (!(a<b) and !(b<a)) => a == b => keep looking + } // !(a<=b) and b<=a => b < a => return false ar = false; - ar.message() << "\nFailure at position " << pos << ": " - << tt_detail::print_helper(*first1) - << OP::revert() - << tt_detail::print_helper(*first2) - << ". " << element_ar.message(); + ar.message() << "\nFailure at position " << pos << ":"; + ar.message() << "\n - condition [" << tt_detail::print_helper(*first1) << OP::forward() << tt_detail::print_helper(*first2) << "] is false"; + if(!element_ar.has_empty_message()) + ar.message() << ": " << element_ar.message(); + ar.message() << "\n - inverse condition [" << tt_detail::print_helper(*first2) << OP::forward() << tt_detail::print_helper(*first1) << "] is true"; + if(!reverse_ar.has_empty_message()) + ar.message() << ": " << reverse_ar.message(); return ar; } @@ -130,8 +134,8 @@ typename boost::enable_if_c< assertion_result>::type lexicographic_compare( Lhs const& lhs, Rhs const& rhs ) { - typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type; - typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type; + typedef typename unit_test::deduce_cstring_transform<Lhs>::type lhs_char_type; + typedef typename unit_test::deduce_cstring_transform<Rhs>::type rhs_char_type; return lexicographic_compare<OP, can_be_equal, prefer_shorter>( lhs_char_type(lhs), @@ -173,11 +177,13 @@ element_compare( Lhs const& lhs, Rhs const& rhs ) continue; ar = false; - ar.message() << "\nMismatch at position " << pos << ": " + ar.message() << "\n - mismatch at position " << pos << ": [" << tt_detail::print_helper(*left) - << OP::revert() + << OP::forward() << tt_detail::print_helper(*right) - << ". " << element_ar.message(); + << "] is false"; + if(!element_ar.has_empty_message()) + ar.message() << ": " << element_ar.message(); } return ar; @@ -191,8 +197,8 @@ typename boost::enable_if_c< assertion_result>::type element_compare( Lhs const& lhs, Rhs const& rhs ) { - typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type; - typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type; + typedef typename unit_test::deduce_cstring_transform<Lhs>::type lhs_char_type; + typedef typename unit_test::deduce_cstring_transform<Rhs>::type rhs_char_type; return element_compare<OP>(lhs_char_type(lhs), rhs_char_type(rhs)); @@ -382,15 +388,16 @@ compare_collections( Lhs const& lhs, Rhs const& rhs, boost::type<op::GE<L, R> >* // ********* specialization of comparison operators for collections ********* // // ************************************************************************** // -#define DEFINE_COLLECTION_COMPARISON( oper, name, rev ) \ +#define DEFINE_COLLECTION_COMPARISON( oper, name, rev, name_inverse ) \ template<typename Lhs,typename Rhs> \ struct name<Lhs,Rhs,typename boost::enable_if_c< \ unit_test::is_forward_iterable<Lhs>::value \ - && !unit_test::is_cstring_comparable<Lhs>::value \ + && !unit_test::is_cstring_comparable<Lhs>::value \ && unit_test::is_forward_iterable<Rhs>::value \ - && !unit_test::is_cstring_comparable<Rhs>::value>::type> { \ + && !unit_test::is_cstring_comparable<Rhs>::value>::type> { \ public: \ typedef assertion_result result_type; \ + typedef name_inverse<Lhs, Rhs> inverse; \ typedef unit_test::bt_iterator_traits<Lhs> t_Lhs_iterator_helper; \ typedef unit_test::bt_iterator_traits<Rhs> t_Rhs_iterator_helper; \ \ @@ -428,6 +435,8 @@ public: \ PrevExprType const&, \ Rhs const& ) {} \ \ + static char const* forward() \ + { return " " #oper " "; } \ static char const* revert() \ { return " " #rev " "; } \ \ diff --git a/contrib/restricted/boost/test/include/boost/test/tools/context.hpp b/contrib/restricted/boost/test/include/boost/test/tools/context.hpp index 71650065ef..e5d6625e12 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/context.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/context.hpp @@ -17,6 +17,20 @@ // Boost.Test #include <boost/test/utils/lazy_ostream.hpp> +#include <boost/test/detail/pp_variadic.hpp> + +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/preprocessor/repetition/enum_binary_params.hpp> +#include <boost/preprocessor/repetition/repeat_from_to.hpp> + +#include <boost/preprocessor/variadic/to_seq.hpp> +#include <boost/preprocessor/variadic/size.hpp> +#include <boost/preprocessor/cat.hpp> +#include <boost/preprocessor/seq/for_each_i.hpp> +#include <boost/preprocessor/seq/for_each.hpp> +#include <boost/preprocessor/seq/enum.hpp> +#include <boost/preprocessor/control/iif.hpp> +#include <boost/preprocessor/comparison/equal.hpp> #include <boost/test/detail/suppress_warnings.hpp> @@ -47,13 +61,30 @@ private: ::boost::unit_test::framework::add_context( BOOST_TEST_LAZY_MSG( context_descr ) , false ) \ /**/ +#define BOOST_TEST_INFO_SCOPE( context_descr ) \ + ::boost::test_tools::tt_detail::context_frame BOOST_JOIN( context_frame_, __LINE__ ) = \ + ::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) ) \ +/**/ + //____________________________________________________________________________// -#define BOOST_TEST_CONTEXT( context_descr ) \ - if( ::boost::test_tools::tt_detail::context_frame BOOST_JOIN( context_frame_, __LINE__ ) = \ - ::boost::test_tools::tt_detail::context_frame( BOOST_TEST_LAZY_MSG( context_descr ) ) ) \ + +#define BOOST_CONTEXT_PARAM(r, ctx, i, context_descr) \ + if( ::boost::test_tools::tt_detail::context_frame BOOST_PP_CAT(ctx, i) = \ + ::boost::test_tools::tt_detail::context_frame(BOOST_TEST_LAZY_MSG( context_descr ) ) ) \ /**/ +#define BOOST_CONTEXT_PARAMS( params ) \ + BOOST_PP_SEQ_FOR_EACH_I(BOOST_CONTEXT_PARAM, \ + BOOST_JOIN( context_frame_, __LINE__ ), \ + params) \ +/**/ + +#define BOOST_TEST_CONTEXT( ... ) \ + BOOST_CONTEXT_PARAMS( BOOST_PP_VARIADIC_TO_SEQ(__VA_ARGS__) ) \ +/**/ + + //____________________________________________________________________________// } // namespace tt_detail diff --git a/contrib/restricted/boost/test/include/boost/test/tools/cstring_comparison_op.hpp b/contrib/restricted/boost/test/include/boost/test/tools/cstring_comparison_op.hpp index 50f181d858..04b38561ee 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/cstring_comparison_op.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/cstring_comparison_op.hpp @@ -34,17 +34,18 @@ namespace op { // ************** string_compare ************** // // ************************************************************************** // -#define DEFINE_CSTRING_COMPARISON( oper, name, rev ) \ +#define DEFINE_CSTRING_COMPARISON( oper, name, rev, name_inverse ) \ template<typename Lhs,typename Rhs> \ struct name<Lhs,Rhs,typename boost::enable_if_c< \ ( unit_test::is_cstring_comparable<Lhs>::value \ && unit_test::is_cstring_comparable<Rhs>::value) \ >::type > \ { \ - typedef typename unit_test::deduce_cstring<Lhs>::type lhs_char_type; \ - typedef typename unit_test::deduce_cstring<Rhs>::type rhs_char_type; \ + typedef typename unit_test::deduce_cstring_transform<Lhs>::type lhs_char_type; \ + typedef typename unit_test::deduce_cstring_transform<Rhs>::type rhs_char_type; \ public: \ typedef assertion_result result_type; \ + typedef name_inverse<Lhs, Rhs> inverse; \ \ typedef name< \ typename lhs_char_type::value_type, \ @@ -67,6 +68,8 @@ public: \ << tt_detail::print_helper( rhs ); \ } \ \ + static char const* forward() \ + { return " " #oper " "; } \ static char const* revert() \ { return " " #rev " "; } \ }; \ diff --git a/contrib/restricted/boost/test/include/boost/test/tools/detail/bitwise_manip.hpp b/contrib/restricted/boost/test/include/boost/test/tools/detail/bitwise_manip.hpp index f8c9685c10..329a893a9a 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/detail/bitwise_manip.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/detail/bitwise_manip.hpp @@ -34,12 +34,18 @@ namespace test_tools { // ************************************************************************** // //! Bitwise comparison manipulator +//! This is a terminal for the expression struct bitwise {}; //____________________________________________________________________________// -inline int -operator<<( unit_test::lazy_ostream const&, bitwise ) { return 0; } +inline unit_test::lazy_ostream & +operator<<( unit_test::lazy_ostream &o, bitwise ) { return o; } + +// needed for the lazy evaluation in lazy_ostream as bitwise is a terminal +inline std::ostream& +operator<<( std::ostream& o, bitwise ) { return o; } + //____________________________________________________________________________// @@ -106,10 +112,10 @@ operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,assertion::op::EQ<T //____________________________________________________________________________// -inline check_type +inline assertion_type operator<<( assertion_type const& , bitwise ) { - return CHECK_BUILT_ASSERTION; + return assertion_type(CHECK_BUILT_ASSERTION); } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/tools/detail/expression_holder.hpp b/contrib/restricted/boost/test/include/boost/test/tools/detail/expression_holder.hpp deleted file mode 100644 index 694a2d5f4e..0000000000 --- a/contrib/restricted/boost/test/include/boost/test/tools/detail/expression_holder.hpp +++ /dev/null @@ -1,70 +0,0 @@ -// (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) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision: 74248 $ -// -// Description : toolbox implementation details -// *************************************************************************** - -#ifndef BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER -#define BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER - -#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS - -#include <boost/test/detail/suppress_warnings.hpp> - -//____________________________________________________________________________// - -namespace boost { -namespace test_tools { -namespace tt_detail { - -// ************************************************************************** // -// ************** tt_detail::expression_holder ************** // -// ************************************************************************** // - -class expression_holder { -public: - virtual ~expression_holder() {} - virtual assertion_result evaluate( bool no_message = false ) const = 0; -}; - -//____________________________________________________________________________// - -template<typename E> -class expression_holder_t: public expression_holder { -public: - explicit expression_holder_t( E const& e ) : m_expr( e ) {} - -private: - virtual assertion_result evaluate( bool no_message = false ) const { return m_expr.evaluate( no_message ); } - - E m_expr; -}; - -//____________________________________________________________________________// - -template<typename E> -expression_holder_t<E> -hold_expression( E const& e ) -{ - return expression_holder_t<E>( e ); -} - -//____________________________________________________________________________// - -} // namespace tt_detail -} // namespace test_tools -} // namespace boost - -#include <boost/test/detail/enable_warnings.hpp> - -#endif - -#endif // BOOST_TEST_TOOLS_DETAIL_EXPRESSION_HOLDER_HPP_012705GER diff --git a/contrib/restricted/boost/test/include/boost/test/tools/detail/indirections.hpp b/contrib/restricted/boost/test/include/boost/test/tools/detail/indirections.hpp index 836218d98d..2622f2a653 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/detail/indirections.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/detail/indirections.hpp @@ -19,6 +19,10 @@ #include <boost/test/tools/detail/fwd.hpp> #include <boost/test/tools/assertion_result.hpp> +#include <boost/test/utils/lazy_ostream.hpp> + +#include <boost/shared_ptr.hpp> +#include <list> #include <boost/test/detail/suppress_warnings.hpp> @@ -28,16 +32,41 @@ namespace boost { namespace test_tools { namespace tt_detail { +struct assertion_evaluation_context +{ + assertion_evaluation_context(bool has_report = false) + : m_has_report(has_report) + {} + + bool m_has_report; +}; + // ************************************************************************** // // ************** assertion_evaluate indirection ************** // // ************************************************************************** // template<typename E> struct assertion_evaluate_t { - assertion_evaluate_t( E const& e ) : m_e( e ) {} - operator assertion_result() { return m_e.evaluate( true ); } + + typedef shared_ptr<assertion_evaluation_context> context_holder; + + assertion_evaluate_t( E const& e ) : m_e( e ), m_evaluate( true ) + {} + + operator assertion_result() { return m_e.evaluate( m_evaluate ); } + + assertion_evaluate_t<E> + stack_context(context_holder context) const { + assertion_evaluate_t<E> added_context(*this); + + added_context.m_context_holder.push_back(context); + added_context.m_evaluate = !context->m_has_report; + return added_context; + } E const& m_e; + std::list< context_holder > m_context_holder; + bool m_evaluate; }; //____________________________________________________________________________// @@ -58,14 +87,12 @@ operator<<( assertion_evaluate_t<E> const& ae, T const& ) { return ae; } // ************** assertion_text indirection ************** // // ************************************************************************** // -template<typename T> -inline unit_test::lazy_ostream const& -assertion_text( unit_test::lazy_ostream const& /*et*/, T const& m ) { return m; } - -//____________________________________________________________________________// - inline unit_test::lazy_ostream const& -assertion_text( unit_test::lazy_ostream const& et, int ) { return et; } +assertion_text( unit_test::lazy_ostream const& et, unit_test::lazy_ostream const& s) { + if(!s.empty()) + return s; + return et; +} //____________________________________________________________________________// @@ -74,7 +101,11 @@ assertion_text( unit_test::lazy_ostream const& et, int ) { return et; } // ************************************************************************** // struct assertion_type { - operator check_type() { return CHECK_MSG; } + assertion_type(check_type ct = CHECK_MSG) : m_check_type(ct) + {} + + operator check_type() { return m_check_type; } + check_type m_check_type; }; //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/tools/detail/lexicographic_manip.hpp b/contrib/restricted/boost/test/include/boost/test/tools/detail/lexicographic_manip.hpp index f6ffff7a34..30a49c0927 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/detail/lexicographic_manip.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/detail/lexicographic_manip.hpp @@ -17,8 +17,11 @@ #include <boost/test/tools/detail/indirections.hpp> #include <boost/test/tools/assertion.hpp> +#include <boost/test/utils/lazy_ostream.hpp> #include <boost/test/tools/collection_comparison_op.hpp> +#include <ostream> + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -31,12 +34,17 @@ namespace test_tools { // ************************************************************************** // //! Lexicographic comparison manipulator, for containers +//! This is a terminal that involves evaluation of the expression struct lexicographic {}; //____________________________________________________________________________// -inline int -operator<<( unit_test::lazy_ostream const&, lexicographic ) { return 0; } +inline unit_test::lazy_ostream& +operator<<( unit_test::lazy_ostream & o, lexicographic ) { return o; } + +// needed for the lazy evaluation in lazy_ostream as lexicographic is a terminal +inline std::ostream& +operator<<( std::ostream& o, lexicographic ) { return o; } //____________________________________________________________________________// @@ -52,10 +60,10 @@ operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP> > const& ae, le //____________________________________________________________________________// -inline check_type +inline assertion_type operator<<( assertion_type const&, lexicographic ) { - return CHECK_BUILT_ASSERTION; + return assertion_type(CHECK_BUILT_ASSERTION); } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/tools/detail/per_element_manip.hpp b/contrib/restricted/boost/test/include/boost/test/tools/detail/per_element_manip.hpp index 4a9aebbaaa..98b5703685 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/detail/per_element_manip.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/detail/per_element_manip.hpp @@ -16,9 +16,12 @@ #include <boost/test/tools/detail/fwd.hpp> #include <boost/test/tools/detail/indirections.hpp> +#include <boost/test/utils/lazy_ostream.hpp> #include <boost/test/tools/assertion.hpp> #include <boost/test/tools/collection_comparison_op.hpp> +#include <ostream> + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -31,12 +34,17 @@ namespace test_tools { // ************************************************************************** // //! Per element comparison manipulator, for containers +//! This is a terminal that involves evaluation of the expression struct per_element {}; //____________________________________________________________________________// -inline int -operator<<( unit_test::lazy_ostream const&, per_element ) { return 0; } +inline unit_test::lazy_ostream& +operator<<( unit_test::lazy_ostream &o, per_element ) { return o; } + +// needed for the lazy evaluation in lazy_ostream as per_element is a terminal +inline std::ostream& +operator<<( std::ostream& o, per_element ) { return o; } //____________________________________________________________________________// @@ -52,10 +60,10 @@ operator<<(assertion_evaluate_t<assertion::binary_expr<T1,T2,OP> > const& ae, pe //____________________________________________________________________________// -inline check_type +inline assertion_type operator<<( assertion_type const&, per_element ) { - return CHECK_BUILT_ASSERTION; + return assertion_type(CHECK_BUILT_ASSERTION); } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/tools/detail/print_helper.hpp b/contrib/restricted/boost/test/include/boost/test/tools/detail/print_helper.hpp index 2c6a3b5e80..dafa2bd48b 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/detail/print_helper.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/detail/print_helper.hpp @@ -18,7 +18,6 @@ // Boost.Test #include <boost/test/detail/config.hpp> #include <boost/test/detail/global_typedef.hpp> -#include <boost/test/detail/workaround.hpp> // Boost #include <boost/mpl/or.hpp> @@ -28,6 +27,8 @@ #include <boost/type_traits/is_abstract.hpp> #include <boost/type_traits/has_left_shift.hpp> +#include <ios> +#include <iostream> #include <limits> #if !defined(BOOST_NO_CXX11_NULLPTR) @@ -119,7 +120,7 @@ struct print_log_value { //____________________________________________________________________________// -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) template<typename T, std::size_t N > struct print_log_value< T[N] > { void operator()( std::ostream& ostr, T const* t ) @@ -153,6 +154,13 @@ struct BOOST_TEST_DECL print_log_value<unsigned char> { //____________________________________________________________________________// template<> +struct BOOST_TEST_DECL print_log_value<wchar_t> { + void operator()( std::ostream& ostr, wchar_t t ); +}; + +//____________________________________________________________________________// + +template<> struct BOOST_TEST_DECL print_log_value<char const*> { void operator()( std::ostream& ostr, char const* t ); }; @@ -191,7 +199,7 @@ struct print_helper_t { //____________________________________________________________________________// -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) // Borland suffers premature pointer decay passing arrays by reference template<typename T, std::size_t N > struct print_helper_t< T[N] > { diff --git a/contrib/restricted/boost/test/include/boost/test/tools/detail/tolerance_manip.hpp b/contrib/restricted/boost/test/include/boost/test/tools/detail/tolerance_manip.hpp index e07b043591..af945cf704 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/detail/tolerance_manip.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/detail/tolerance_manip.hpp @@ -19,9 +19,12 @@ #include <boost/test/tools/detail/fwd.hpp> #include <boost/test/tools/detail/indirections.hpp> +#include <boost/test/utils/lazy_ostream.hpp> #include <boost/test/tools/fpc_tolerance.hpp> #include <boost/test/tools/floating_point_comparison.hpp> +#include <ostream> + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -34,6 +37,8 @@ namespace tt_detail { // ************** fpc tolerance manipulator ************** // // ************************************************************************** // +//! Tolerance manipulator, not to be used directly +//! This is not a terminal of the expression template<typename FPT> struct tolerance_manip { explicit tolerance_manip( FPT const & tol ) : m_value( tol ) {} @@ -55,28 +60,47 @@ operator%( FPT v, tolerance_manip_delay const& ) return tolerance_manip<FPT>( FPT(v / 100) ); } +template <typename FPT> +struct tolerance_evaluation_context: assertion_evaluation_context { + tolerance_evaluation_context(FPT tol) + : assertion_evaluation_context( true ) // has report + , m_tolerance_context(tol) + {} + + local_fpc_tolerance<FPT> m_tolerance_context; +}; + //____________________________________________________________________________// template<typename E, typename FPT> -inline assertion_result +inline assertion_evaluate_t<E> operator<<(assertion_evaluate_t<E> const& ae, tolerance_manip<FPT> const& tol) { - local_fpc_tolerance<FPT> lt( tol.m_value ); - - return ae.m_e.evaluate(); + return ae.stack_context( + typename assertion_evaluate_t<E>::context_holder( + new tolerance_evaluation_context<FPT>( tol.m_value )) + ); } //____________________________________________________________________________// template<typename FPT> -inline int -operator<<( unit_test::lazy_ostream const&, tolerance_manip<FPT> const& ) { return 0; } +unit_test::lazy_ostream & +operator<<( unit_test::lazy_ostream &o, tolerance_manip<FPT> const& ) { return o; } + +// needed for the lazy evaluation in lazy_ostream as for commutativity with other arguments +template<typename FPT> +std::ostream& +operator<<( std::ostream& o, tolerance_manip<FPT> const& ) { return o; } + //____________________________________________________________________________// template<typename FPT> -inline check_type -operator<<( assertion_type const& /*at*/, tolerance_manip<FPT> const& ) { return CHECK_BUILT_ASSERTION; } +inline assertion_type +operator<<( assertion_type const& /*at*/, tolerance_manip<FPT> const& ) { + return assertion_type(CHECK_BUILT_ASSERTION); +} //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/tools/floating_point_comparison.hpp b/contrib/restricted/boost/test/include/boost/test/tools/floating_point_comparison.hpp index d704a41092..1364fde8b8 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/floating_point_comparison.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/floating_point_comparison.hpp @@ -23,6 +23,8 @@ #include <boost/mpl/bool.hpp> #include <boost/type_traits/is_floating_point.hpp> #include <boost/type_traits/is_array.hpp> +#include <boost/type_traits/is_reference.hpp> +#include <boost/type_traits/is_void.hpp> #include <boost/type_traits/conditional.hpp> #include <boost/utility/enable_if.hpp> @@ -50,6 +52,23 @@ struct tolerance_based_delegate; template <typename T> struct tolerance_based_delegate<T, false> : mpl::false_ {}; +// from https://stackoverflow.com/a/16509511/1617295 +template<typename T> +class is_abstract_class_or_function +{ + typedef char (&Two)[2]; + template<typename U> static char test(U(*)[1]); + template<typename U> static Two test(...); + +public: + static const bool value = + !is_reference<T>::value + && !is_void<T>::value + && (sizeof(test<T>(0)) == sizeof(Two)); +}; + +// warning: we cannot instanciate std::numeric_limits for incomplete types, we use is_abstract_class_or_function +// prior to the specialization below template <typename T> struct tolerance_based_delegate<T, true> : mpl::bool_< @@ -68,7 +87,7 @@ struct tolerance_based_delegate<T, true> * floating point (eg. boost.multiprecision). */ template <typename T> -struct tolerance_based : tolerance_based_delegate<T, !is_array<T>::value >::type {}; +struct tolerance_based : tolerance_based_delegate<T, !is_array<T>::value && !is_abstract_class_or_function<T>::value>::type {}; // ************************************************************************** // // ************** fpc::strength ************** // @@ -160,7 +179,7 @@ safe_fpt_division( FPT f1, FPT f2 ) return fpt_limits<FPT>::max_value(); // Avoid underflow. - if( (f1 == static_cast<FPT>(0)) || + if( (fpt_abs(f1) <= fpt_limits<FPT>::min_value()) || ((f2 > static_cast<FPT>(1)) && (f1 < f2*fpt_limits<FPT>::min_value())) ) return static_cast<FPT>(0); @@ -197,9 +216,11 @@ fraction_tolerance( percent_tolerance_t<FPT> tolerance ) /*!@brief Predicate for comparing floating point numbers * * This predicate is used to compare floating point numbers. In addition the comparison produces maximum - * related differnce, which can be used to generate detailed error message + * related difference, which can be used to generate detailed error message * The methods for comparing floating points are detailed in the documentation. The method is chosen * by the @ref boost::math::fpc::strength given at construction. + * + * This predicate is not suitable for comparing to 0 or to infinity. */ template<typename FPT> class close_at_tolerance { diff --git a/contrib/restricted/boost/test/include/boost/test/tools/fpc_op.hpp b/contrib/restricted/boost/test/include/boost/test/tools/fpc_op.hpp index b879d218f2..22bfeaa31d 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/fpc_op.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/fpc_op.hpp @@ -20,6 +20,7 @@ // Boost #include <boost/type_traits/common_type.hpp> +#include <boost/type_traits/is_arithmetic.hpp> #include <boost/utility/enable_if.hpp> #include <boost/test/detail/suppress_warnings.hpp> @@ -65,11 +66,33 @@ template <typename FPT, typename Lhs, typename Rhs, typename OP> inline assertion_result compare_fpv( Lhs const& lhs, Rhs const& rhs, OP* cmp_operator) { - bool result = cmp_operator->eval_direct(lhs, rhs); + assertion_result result_direct_compare = cmp_operator->eval_direct(lhs, rhs); if(fpctraits<OP>::equality_logical_disjunction) { - return result || compare_fpv<FPT>(lhs, rhs, (op::EQ<Lhs, Rhs>*)0); + // this look like this can be simplified, but combining result && compare_fpv + // looses the message in the return value of compare_fpv + if( result_direct_compare ) { + result_direct_compare.message() << "operation" << OP::forward() << "on arguments yields 'true'."; + return result_direct_compare; + } + // result || compare_fpv(EQ) + assertion_result result_eq = compare_fpv<FPT>(lhs, rhs, (op::EQ<Lhs, Rhs>*)0); + result_direct_compare = result_direct_compare || result_eq; + if( !result_eq ) { + result_direct_compare.message() << "operation" << op::EQ<Lhs, Rhs>::forward() << "on arguments yields 'false': " << result_eq.message() << "."; + } + return result_direct_compare; } - return result && compare_fpv<FPT>(lhs, rhs, (op::NE<Lhs, Rhs>*)0); + if( !result_direct_compare ) { + result_direct_compare.message() << "operation" << OP::forward() << " on arguments yields 'false'."; + return result_direct_compare; + } + // result && compare_fpv(NE) + assertion_result result_neq = compare_fpv<FPT>(lhs, rhs, (op::NE<Lhs, Rhs>*)0); + result_direct_compare = result_direct_compare && result_neq; + if( !result_neq ) { + result_direct_compare.message() << "operation" << op::NE<Lhs, Rhs>::forward() << "on arguments yields 'false': " << result_neq.message() << "."; + } + return result_direct_compare; } //____________________________________________________________________________// @@ -82,7 +105,7 @@ compare_fpv_near_zero( FPT const& fpv, op::EQ<Lhs,Rhs>* ) assertion_result ar( P( fpv ) ); if( !ar ) - ar.message() << "Absolute value exceeds tolerance [|" << fpv << "| > "<< fpc_tolerance<FPT>() << ']'; + ar.message() << "absolute value exceeds tolerance [|" << fpv << "| > "<< fpc_tolerance<FPT>() << ']'; return ar; } @@ -97,7 +120,7 @@ compare_fpv_near_zero( FPT const& fpv, op::NE<Lhs,Rhs>* ) assertion_result ar( !P( fpv ) ); if( !ar ) - ar.message() << "Absolute value is within tolerance [|" << fpv << "| < "<< fpc_tolerance<FPT>() << ']'; + ar.message() << "absolute value is within tolerance [|" << fpv << "| < "<< fpc_tolerance<FPT>() << ']'; return ar; } @@ -108,17 +131,17 @@ inline assertion_result compare_fpv( Lhs const& lhs, Rhs const& rhs, op::EQ<Lhs,Rhs>* ) { if( lhs == 0 ) { - return compare_fpv_near_zero( rhs, (op::EQ<Lhs,Rhs>*)0 ); + return compare_fpv_near_zero<FPT>( rhs, (op::EQ<Lhs,Rhs>*)0 ); } else if( rhs == 0) { - return compare_fpv_near_zero( lhs, (op::EQ<Lhs,Rhs>*)0 ); + return compare_fpv_near_zero<FPT>( lhs, (op::EQ<Lhs,Rhs>*)0 ); } else { fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_STRONG ); assertion_result ar( P( lhs, rhs ) ); if( !ar ) - ar.message() << "Relative difference exceeds tolerance [" + ar.message() << "relative difference exceeds tolerance [" << P.tested_rel_diff() << " > " << P.fraction_tolerance() << ']'; return ar; } @@ -131,17 +154,17 @@ inline assertion_result compare_fpv( Lhs const& lhs, Rhs const& rhs, op::NE<Lhs,Rhs>* ) { if( lhs == 0 ) { - return compare_fpv_near_zero( rhs, (op::NE<Lhs,Rhs>*)0 ); + return compare_fpv_near_zero<FPT>( rhs, (op::NE<Lhs,Rhs>*)0 ); } else if( rhs == 0 ) { - return compare_fpv_near_zero( lhs, (op::NE<Lhs,Rhs>*)0 ); + return compare_fpv_near_zero<FPT>( lhs, (op::NE<Lhs,Rhs>*)0 ); } else { fpc::close_at_tolerance<FPT> P( fpc_tolerance<FPT>(), fpc::FPC_WEAK ); assertion_result ar( !P( lhs, rhs ) ); if( !ar ) - ar.message() << "Relative difference is within tolerance [" + ar.message() << "relative difference is within tolerance [" << P.tested_rel_diff() << " < " << fpc_tolerance<FPT>() << ']'; return ar; @@ -150,14 +173,20 @@ compare_fpv( Lhs const& lhs, Rhs const& rhs, op::NE<Lhs,Rhs>* ) //____________________________________________________________________________// -#define DEFINE_FPV_COMPARISON( oper, name, rev ) \ +#define DEFINE_FPV_COMPARISON( oper, name, rev, name_inverse ) \ template<typename Lhs,typename Rhs> \ struct name<Lhs,Rhs,typename boost::enable_if_c< \ (fpc::tolerance_based<Lhs>::value && \ - fpc::tolerance_based<Rhs>::value)>::type> { \ + fpc::tolerance_based<Rhs>::value) || \ + (fpc::tolerance_based<Lhs>::value && \ + boost::is_arithmetic<Rhs>::value) || \ + (boost::is_arithmetic<Lhs>::value && \ + fpc::tolerance_based<Rhs>::value) \ + >::type> { \ public: \ typedef typename common_type<Lhs,Rhs>::type FPT; \ typedef name<Lhs,Rhs> OP; \ + typedef name_inverse<Lhs, Rhs> inverse; \ \ typedef assertion_result result_type; \ \ @@ -170,7 +199,11 @@ public: \ static assertion_result \ eval( Lhs const& lhs, Rhs const& rhs ) \ { \ - if( fpc_tolerance<FPT>() == FPT(0) ) \ + if( fpc_tolerance<FPT>() == FPT(0) \ + || (std::numeric_limits<Lhs>::has_infinity \ + && (lhs == std::numeric_limits<Lhs>::infinity())) \ + || (std::numeric_limits<Rhs>::has_infinity \ + && (rhs == std::numeric_limits<Rhs>::infinity()))) \ { \ return eval_direct( lhs, rhs ); \ } \ @@ -189,6 +222,8 @@ public: \ << tt_detail::print_helper( rhs ); \ } \ \ + static char const* forward() \ + { return " " #oper " "; } \ static char const* revert() \ { return " " #rev " "; } \ }; \ @@ -207,4 +242,3 @@ BOOST_TEST_FOR_EACH_COMP_OP( DEFINE_FPV_COMPARISON ) #include <boost/test/detail/enable_warnings.hpp> #endif // BOOST_TEST_TOOLS_FPC_OP_HPP_050915GER - diff --git a/contrib/restricted/boost/test/include/boost/test/tools/interface.hpp b/contrib/restricted/boost/test/include/boost/test/tools/interface.hpp index 5e84f1c6d4..e62ae946c0 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/interface.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/interface.hpp @@ -20,9 +20,6 @@ #ifdef BOOST_TEST_TOOLS_DEBUGGABLE #include <boost/test/debug.hpp> #endif -#ifdef BOOST_NO_CXX11_AUTO_DECLARATIONS -#include <boost/test/tools/detail/expression_holder.hpp> -#endif #include <boost/test/detail/pp_variadic.hpp> diff --git a/contrib/restricted/boost/test/include/boost/test/tools/old/impl.hpp b/contrib/restricted/boost/test/include/boost/test/tools/old/impl.hpp index 8f8363e141..7759adf788 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/old/impl.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/old/impl.hpp @@ -117,7 +117,7 @@ inline assertion_result equal_impl( char const* left, char* right ) { return equ inline assertion_result equal_impl( char* left, char* right ) { return equal_impl( static_cast<char const*>(left), static_cast<char const*>(right) ); } #if !defined( BOOST_NO_CWCHAR ) -assertion_result BOOST_TEST_DECL equal_impl( wchar_t const* left, wchar_t const* right ); +BOOST_TEST_DECL assertion_result equal_impl( wchar_t const* left, wchar_t const* right ); inline assertion_result equal_impl( wchar_t* left, wchar_t const* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); } inline assertion_result equal_impl( wchar_t const* left, wchar_t* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); } inline assertion_result equal_impl( wchar_t* left, wchar_t* right ) { return equal_impl( static_cast<wchar_t const*>(left), static_cast<wchar_t const*>(right) ); } diff --git a/contrib/restricted/boost/test/include/boost/test/tools/old/interface.hpp b/contrib/restricted/boost/test/include/boost/test/tools/old/interface.hpp index 2d6f8b78c0..1b23c291a3 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/old/interface.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/old/interface.hpp @@ -20,6 +20,8 @@ #include <boost/preprocessor/seq/size.hpp> #include <boost/preprocessor/seq/to_tuple.hpp> +#include <boost/core/ignore_unused.hpp> + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -95,7 +97,7 @@ do { //____________________________________________________________________________// -#define BOOST_CHECK_THROW_IMPL( S, E, P, postfix, TL ) \ +#define BOOST_CHECK_THROW_IMPL( S, E, P, postfix, TL ) \ do { \ try { \ BOOST_TEST_PASSPOINT(); \ @@ -103,9 +105,9 @@ do { BOOST_TEST_TOOL_IMPL( 2, false, "exception " BOOST_STRINGIZE(E) " expected but not raised", \ TL, CHECK_MSG, _ ); \ } catch( E const& ex ) { \ - ::boost::unit_test::ut_detail::ignore_unused_variable_warning( ex ); \ - BOOST_TEST_TOOL_IMPL( 2, P, \ - "exception \"" BOOST_STRINGIZE( E )"\" raised as expected" postfix, \ + boost::ignore_unused( ex ); \ + BOOST_TEST_TOOL_IMPL( 2, P, \ + "exception \"" BOOST_STRINGIZE( E )"\" raised as expected" postfix, \ TL, CHECK_MSG, _ ); \ } \ } while( ::boost::test_tools::tt_detail::dummy_cond() ) \ diff --git a/contrib/restricted/boost/test/include/boost/test/tools/output_test_stream.hpp b/contrib/restricted/boost/test/include/boost/test/tools/output_test_stream.hpp index 2abbf7b521..a6f71a8f55 100644 --- a/contrib/restricted/boost/test/include/boost/test/tools/output_test_stream.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tools/output_test_stream.hpp @@ -51,7 +51,7 @@ public: bool text_or_binary = true ); // Destructor - virtual ~output_test_stream(); + ~output_test_stream() BOOST_OVERRIDE; //! Checks if the stream is empty //! diff --git a/contrib/restricted/boost/test/include/boost/test/tree/auto_registration.hpp b/contrib/restricted/boost/test/include/boost/test/tree/auto_registration.hpp index a3fe32fda7..e9510be292 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/auto_registration.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/auto_registration.hpp @@ -37,9 +37,10 @@ namespace ut_detail { struct BOOST_TEST_DECL auto_test_unit_registrar { // Constructors - auto_test_unit_registrar( test_case* tc, decorator::collector& decorators, counter_t exp_fail = 0 ); - explicit auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector& decorators ); - explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector& decorators ); + auto_test_unit_registrar( test_case* tc, decorator::collector_t& decorators, counter_t exp_fail = 0 ); + explicit auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector_t& decorators ); + explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector_t& decorators ); + explicit auto_test_unit_registrar( boost::shared_ptr<test_unit_generator> tc_gen, decorator::collector_t& decorators ); explicit auto_test_unit_registrar( int ); }; diff --git a/contrib/restricted/boost/test/include/boost/test/tree/decorator.hpp b/contrib/restricted/boost/test/include/boost/test/tree/decorator.hpp index 27c46682a0..7381593c7a 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/decorator.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/decorator.hpp @@ -22,9 +22,7 @@ #include <boost/test/tree/fixture.hpp> #include <boost/test/tools/assertion_result.hpp> - #include <boost/test/utils/basic_cstring/basic_cstring.hpp> -#include <boost/test/utils/trivial_singleton.hpp> // Boost #include <boost/shared_ptr.hpp> @@ -46,35 +44,45 @@ class test_unit; namespace decorator { // ************************************************************************** // -// ************** decorator::collector ************** // +// ************** decorator::collector_t ************** // // ************************************************************************** // class base; typedef boost::shared_ptr<base> base_ptr; -class BOOST_TEST_DECL collector : public singleton<collector> { +class BOOST_TEST_DECL collector_t { + public: - collector& operator*( base const& d ); + collector_t& operator*( base const& d ); void store_in( test_unit& tu ); void reset(); + void stack(); + + std::vector<base_ptr> get_lazy_decorators() const; + + // singleton pattern without ctor + BOOST_TEST_SINGLETON_CONS_NO_CTOR( collector_t ) + private: - BOOST_TEST_SINGLETON_CONS( collector ) + // Class invariant: minimal size is 1. + collector_t() : m_tu_decorators_stack(1) {} // Data members - std::vector<base_ptr> m_tu_decorators; + std::vector< std::vector<base_ptr> > m_tu_decorators_stack; }; + // ************************************************************************** // -// ************** decorator::base ************** // +// ************** decorator::base ************** // // ************************************************************************** // class BOOST_TEST_DECL base { public: // composition interface - collector& operator*() const; + virtual collector_t& operator*() const; // application interface virtual void apply( test_unit& tu ) = 0; @@ -87,6 +95,30 @@ protected: }; // ************************************************************************** // +// ************** decorator::stack_decorator ************** // +// ************************************************************************** // + +//!@ A decorator that creates a new stack in the collector +//! +//! This decorator may be used in places where the currently accumulated decorators +//! in the collector should be applied to lower levels of the hierarchy rather +//! than the current one. This is for instance for dataset test cases, where the +//! macro does not let the user specify decorators for the underlying generated tests +//! (but rather on the main generator function), applying the stack_decorator at the +//! parent level lets us consume the decorator at the underlying test cases level. +class BOOST_TEST_DECL stack_decorator : public decorator::base { +public: + explicit stack_decorator() {} + + collector_t& operator*() const BOOST_OVERRIDE; + +private: + // decorator::base interface + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new stack_decorator()); } +}; + +// ************************************************************************** // // ************** decorator::label ************** // // ************************************************************************** // @@ -96,8 +128,8 @@ public: private: // decorator::base interface - virtual void apply( test_unit& tu ); - virtual base_ptr clone() const { return base_ptr(new label( m_label )); } + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new label( m_label )); } // Data members const_string m_label; @@ -113,8 +145,8 @@ public: private: // decorator::base interface - virtual void apply( test_unit& tu ); - virtual base_ptr clone() const { return base_ptr(new expected_failures( m_exp_fail )); } + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new expected_failures( m_exp_fail )); } // Data members counter_t m_exp_fail; @@ -130,8 +162,8 @@ public: private: // decorator::base interface - virtual void apply( test_unit& tu ); - virtual base_ptr clone() const { return base_ptr(new timeout( m_timeout )); } + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new timeout( m_timeout )); } // Data members unsigned m_timeout; @@ -147,8 +179,8 @@ public: private: // decorator::base interface - virtual void apply( test_unit& tu ); - virtual base_ptr clone() const { return base_ptr(new description( m_description )); } + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new description( m_description )); } // Data members const_string m_description; @@ -164,8 +196,8 @@ public: private: // decorator::base interface - virtual void apply( test_unit& tu ); - virtual base_ptr clone() const { return base_ptr(new depends_on( m_dependency )); } + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new depends_on( m_dependency )); } // Data members const_string m_dependency; @@ -184,8 +216,8 @@ template<bool condition> class enable_if : public enable_if_impl { private: // decorator::base interface - virtual void apply( test_unit& tu ) { this->apply_impl( tu, condition ); } - virtual base_ptr clone() const { return base_ptr(new enable_if<condition>()); } + void apply( test_unit& tu ) BOOST_OVERRIDE { this->apply_impl( tu, condition ); } + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new enable_if<condition>()); } }; typedef enable_if<true> enabled; @@ -202,8 +234,8 @@ public: private: // decorator::base interface - virtual void apply( test_unit& tu ); - virtual base_ptr clone() const { return base_ptr(new fixture_t( m_impl )); } + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new fixture_t( m_impl )); } // Data members test_unit_fixture_ptr m_impl; @@ -249,8 +281,8 @@ public: private: // decorator::base interface - virtual void apply( test_unit& tu ); - virtual base_ptr clone() const { return base_ptr(new precondition( m_precondition )); } + void apply( test_unit& tu ) BOOST_OVERRIDE; + base_ptr clone() const BOOST_OVERRIDE { return base_ptr(new precondition( m_precondition )); } // Data members predicate_t m_precondition; diff --git a/contrib/restricted/boost/test/include/boost/test/tree/fixture.hpp b/contrib/restricted/boost/test/include/boost/test/tree/fixture.hpp index 8e07b2aa1d..a297ad9e9b 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/fixture.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/fixture.hpp @@ -132,8 +132,8 @@ public: private: // Fixture interface - virtual void setup() { m_inst.reset( new F( m_arg ) ); setup_conditional(*m_inst); } - virtual void teardown() { teardown_conditional(*m_inst); m_inst.reset(); } + void setup() BOOST_OVERRIDE { m_inst.reset( new F( m_arg ) ); setup_conditional(*m_inst); } + void teardown() BOOST_OVERRIDE { teardown_conditional(*m_inst); m_inst.reset(); } // Data members scoped_ptr<F> m_inst; @@ -150,8 +150,8 @@ public: private: // Fixture interface - virtual void setup() { m_inst.reset( new F ); setup_conditional(*m_inst); } - virtual void teardown() { teardown_conditional(*m_inst); m_inst.reset(); } + void setup() BOOST_OVERRIDE { m_inst.reset( new F ); setup_conditional(*m_inst); } + void teardown() BOOST_OVERRIDE { teardown_conditional(*m_inst); m_inst.reset(); } // Data members scoped_ptr<F> m_inst; @@ -174,8 +174,8 @@ public: private: // Fixture interface - virtual void setup() { if( m_setup ) m_setup(); } - virtual void teardown() { if( m_teardown ) m_teardown(); } + void setup() BOOST_OVERRIDE { if( m_setup ) m_setup(); } + void teardown() BOOST_OVERRIDE { if( m_teardown ) m_teardown(); } // Data members boost::function<void ()> m_setup; diff --git a/contrib/restricted/boost/test/include/boost/test/tree/global_fixture.hpp b/contrib/restricted/boost/test/include/boost/test/tree/global_fixture.hpp index 7c96d34e89..54397d3cf1 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/global_fixture.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/global_fixture.hpp @@ -37,11 +37,19 @@ public: // Constructor global_configuration(); + /// Unregisters the global fixture from the framework + /// + /// This is called by the framework at shutdown time + void unregister_from_framework(); + // Dtor - virtual ~global_configuration(); + ~global_configuration() BOOST_OVERRIDE; // Happens after the framework global observer init has been done - virtual int priority() { return 1; } + int priority() BOOST_OVERRIDE { return 1; } + +private: + bool registered; }; @@ -56,8 +64,16 @@ public: // Constructor global_fixture(); + /// Unregisters the global fixture from the framework + /// + /// This is called by the framework at shutdown time + void unregister_from_framework(); + // Dtor - virtual ~global_fixture(); + ~global_fixture() BOOST_OVERRIDE; + +private: + bool registered; }; //____________________________________________________________________________// @@ -71,12 +87,12 @@ struct global_configuration_impl : public global_configuration { } // test observer interface - virtual void test_start( counter_t ) { + void test_start( counter_t, test_unit_id ) BOOST_OVERRIDE { m_configuration_observer = new F; } // test observer interface - virtual void test_finish() { + void test_finish() BOOST_OVERRIDE { if(m_configuration_observer) { delete m_configuration_observer; m_configuration_observer = 0; @@ -94,13 +110,13 @@ struct global_fixture_impl : public global_fixture { } // test fixture interface - virtual void setup() { + void setup() BOOST_OVERRIDE { m_fixture = new F; setup_conditional(*m_fixture); } // test fixture interface - virtual void teardown() { + void teardown() BOOST_OVERRIDE { if(m_fixture) { teardown_conditional(*m_fixture); } diff --git a/contrib/restricted/boost/test/include/boost/test/tree/observer.hpp b/contrib/restricted/boost/test/include/boost/test/tree/observer.hpp index bd6fc9bff5..0c0a4013af 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/observer.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/observer.hpp @@ -44,7 +44,8 @@ public: //! //! @param[in] number_of_test_cases indicates the number of test cases. Only active //! test cases are taken into account. - virtual void test_start( counter_t /* number_of_test_cases */ ) {} + //! @param[in] root_test_unit_id the ID root of the test tree currently being tested + virtual void test_start( counter_t /* number_of_test_cases */, test_unit_id /* root_test_unit_id */ ) {} //! Called after the framework ends executing the test cases //! @@ -72,6 +73,12 @@ public: virtual void test_unit_skipped( test_unit const& tu, const_string ) { test_unit_skipped( tu ); } virtual void test_unit_skipped( test_unit const& ) {} ///< backward compatibility + //! Called when the test timed out + //! + //! This function is called to signal that a test unit (case or suite) timed out. + //! A valid test unit is available through boost::unit_test::framework::current_test_unit + virtual void test_unit_timed_out( test_unit const& ) {} + //! Called when a test unit indicates a fatal error. //! //! A fatal error happens when @@ -79,14 +86,8 @@ public: //! - an unexpected exception is caught by the Boost.Test framework virtual void test_unit_aborted( test_unit const& ) {} - virtual void assertion_result( unit_test::assertion_result ar ) + virtual void assertion_result( unit_test::assertion_result /* ar */ ) { - switch( ar ) { - case AR_PASSED: assertion_result( true ); break; - case AR_FAILED: assertion_result( false ); break; - case AR_TRIGGERED: break; - default: break; - } } //! Called when an exception is intercepted @@ -101,8 +102,6 @@ public: virtual int priority() { return 0; } protected: - //! Deprecated - virtual void assertion_result( bool /* passed */ ) {} BOOST_TEST_PROTECTED_VIRTUAL ~test_observer() {} }; diff --git a/contrib/restricted/boost/test/include/boost/test/tree/test_case_counter.hpp b/contrib/restricted/boost/test/include/boost/test/tree/test_case_counter.hpp index a74f37f152..375288a06b 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/test_case_counter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/test_case_counter.hpp @@ -34,13 +34,19 @@ namespace unit_test { class test_case_counter : public test_tree_visitor { public: // Constructor - test_case_counter() : p_count( 0 ) {} + // @param ignore_disabled ignore the status when counting + test_case_counter(bool ignore_status = false) + : p_count( 0 ) + , m_ignore_status(ignore_status) + {} BOOST_READONLY_PROPERTY( counter_t, (test_case_counter)) p_count; private: // test tree visitor interface - virtual void visit( test_case const& tc ) { if( tc.is_enabled() ) ++p_count.value; } - virtual bool test_suite_start( test_suite const& ts ) { return ts.is_enabled(); } + void visit( test_case const& tc ) BOOST_OVERRIDE { if( m_ignore_status || tc.is_enabled() ) ++p_count.value; } + bool test_suite_start( test_suite const& ts ) BOOST_OVERRIDE { return m_ignore_status || ts.is_enabled(); } + + bool m_ignore_status; }; } // namespace unit_test diff --git a/contrib/restricted/boost/test/include/boost/test/tree/test_case_template.hpp b/contrib/restricted/boost/test/include/boost/test/tree/test_case_template.hpp index 83a13f00f5..e0395c4ce1 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/test_case_template.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/test_case_template.hpp @@ -16,11 +16,11 @@ #include <boost/test/detail/config.hpp> #include <boost/test/detail/global_typedef.hpp> #include <boost/test/detail/fwd_decl.hpp> -#include <boost/test/detail/workaround.hpp> +#include <boost/test/tree/test_unit.hpp> #include <boost/test/utils/class_properties.hpp> - #include <boost/test/tree/observer.hpp> +#include <boost/test/utils/algorithm.hpp> // Boost @@ -29,6 +29,10 @@ #include <boost/mpl/identity.hpp> #include <boost/type.hpp> #include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/is_volatile.hpp> +#include <boost/type_traits/is_lvalue_reference.hpp> +#include <boost/type_traits/is_rvalue_reference.hpp> +#include <boost/type_traits/remove_reference.hpp> #include <boost/function/function0.hpp> #if defined(BOOST_NO_TYPEID) || defined(BOOST_NO_RTTI) @@ -42,9 +46,9 @@ #include <list> // for std::list #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ - !defined(BOOST_NO_CXX11_HDR_TUPLE) && \ !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) - #include <tuple> + #include <type_traits> + #include <boost/mpl/is_sequence.hpp> #endif #include <boost/test/detail/suppress_warnings.hpp> @@ -90,8 +94,26 @@ struct generate_test_case_4_type { #else full_name += BOOST_CURRENT_FUNCTION; #endif - if( boost::is_const<TestType>::value ) + + // replacing ',' by ', ' first, and then removing any double space + static const std::string to_replace[] = { "class ", "struct ", ",", " ", " <", " >"}; + static const std::string replacement[] = { "", "" , ", ", " ", "<" , ">"}; + + full_name = unit_test::utils::replace_all_occurrences_of( + full_name, + to_replace, to_replace + sizeof(to_replace)/sizeof(to_replace[0]), + replacement, replacement + sizeof(replacement)/sizeof(replacement[0])); + + typedef typename boost::remove_reference<TestType>::type TestTypewoRef; + if( boost::is_const<TestTypewoRef>::value ) full_name += "_const"; + if( boost::is_volatile<TestTypewoRef>::value ) + full_name += "_volatile"; + if( boost::is_rvalue_reference<TestType>::value ) + full_name += "_refref"; + else if( boost::is_lvalue_reference<TestType>::value ) + full_name += "_ref"; + full_name += '>'; m_holder.m_test_cases.push_back( new test_case( ut_detail::normalize_test_case_name( full_name ), @@ -114,7 +136,7 @@ private: class template_test_case_gen_base : public test_unit_generator { public: - virtual test_unit* next() const + test_unit* next() const BOOST_OVERRIDE { if( m_test_cases.empty() ) return 0; @@ -129,7 +151,7 @@ public: mutable std::list<test_unit*> m_test_cases; }; -template<typename TestCaseTemplate,typename TestTypesList> +template<typename TestCaseTemplate,typename TestTypesList, typename enabler = void> class template_test_case_gen : public template_test_case_gen_base { public: // Constructor @@ -141,27 +163,24 @@ public: } }; -// adding support for tuple +// Describing template test cases with tuples #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) && \ - !defined(BOOST_NO_CXX11_HDR_TUPLE) && \ - !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) - -template<typename TestCaseTemplate, typename... tuple_parameter_pack> -class template_test_case_gen<TestCaseTemplate, std::tuple<tuple_parameter_pack...> > : public template_test_case_gen_base { - - template<int... Is> - struct seq { }; - - template<int N, int... Is> - struct gen_seq : gen_seq<N - 1, N - 1, Is...> { }; - - template<int... Is> - struct gen_seq<0, Is...> : seq<Is...> { }; - - template<typename tuple_t, typename F, int... Is> - void for_each(F &f, seq<Is...>) + !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) && \ + !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) + +template<typename TestCaseTemplate, + template <class ...> class C, + typename... parameter_pack> +class template_test_case_gen< + TestCaseTemplate, + C<parameter_pack...>, + typename std::enable_if<!boost::mpl::is_sequence<C<parameter_pack...>>::value>::type > + : public template_test_case_gen_base { + + template<typename F> + void for_each(F &f) { - auto l = { (f(mpl::identity<typename std::tuple_element<Is, tuple_t>::type>()), 0)... }; + auto l = { (f(mpl::identity<parameter_pack>()), 0)... }; (void)l; // silence warning } @@ -169,17 +188,19 @@ public: // Constructor template_test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line ) { - using tuple_t = std::tuple<tuple_parameter_pack...>; - using this_type = template_test_case_gen<TestCaseTemplate, tuple_t >; + using this_type = template_test_case_gen< + TestCaseTemplate, + C<parameter_pack...>, + typename std::enable_if<!boost::mpl::is_sequence<C<parameter_pack...>>::value>::type>; using single_test_gen = generate_test_case_4_type<this_type, TestCaseTemplate>; single_test_gen op( tc_name, tc_file, tc_line, *this ); - this->for_each<tuple_t>(op, gen_seq<sizeof...(tuple_parameter_pack)>()); + this->for_each(op); } }; -#endif /* C++11 variadic and tuples */ +#endif /* C++11 variadic, type alias */ } // namespace ut_detail } // unit_test diff --git a/contrib/restricted/boost/test/include/boost/test/tree/test_unit.hpp b/contrib/restricted/boost/test/include/boost/test/tree/test_unit.hpp index 273fa14ff3..0eab1d9941 100644 --- a/contrib/restricted/boost/test/include/boost/test/tree/test_unit.hpp +++ b/contrib/restricted/boost/test/include/boost/test/tree/test_unit.hpp @@ -20,6 +20,7 @@ #include <boost/test/tree/decorator.hpp> #include <boost/test/tree/fixture.hpp> +#include <boost/test/framework.hpp> #include <boost/test/tools/assertion_result.hpp> @@ -42,7 +43,7 @@ namespace boost { namespace unit_test { namespace framework { -class state; + class state; } // ************************************************************************** // @@ -113,8 +114,6 @@ protected: test_unit( const_string tu_name, const_string tc_file, std::size_t tc_line, test_unit_type t ); // Master test suite constructor explicit test_unit( const_string module_name ); - -private: }; // ************************************************************************** // @@ -175,11 +174,21 @@ public: void add( test_unit_generator const& gen, unsigned timeout = 0 ); /// @overload - void add( test_unit_generator const& gen, decorator::collector& decorators ); + void add( test_unit_generator const& gen, decorator::collector_t& decorators ); + + /// @overload + void add( boost::shared_ptr<test_unit_generator> gen_ptr, decorator::collector_t& decorators ); //! Removes a test from the test suite. void remove( test_unit_id id ); + + //! Generates all the delayed test_units from the generators + void generate( ); + //! Check for duplicates name in test cases + //! + //! Raises a setup_error if there are duplicates + void check_for_duplicate_test_cases(); // access methods test_unit_id get( const_string tu_name ) const; @@ -199,6 +208,8 @@ protected: test_unit_id_list m_children; children_per_rank m_ranked_children; ///< maps child sibling rank to list of children with that rank + + std::vector< std::pair<boost::shared_ptr<test_unit_generator>, std::vector<decorator::base_ptr> > > m_generators; /// lazy evaluation }; // ************************************************************************** // @@ -206,12 +217,17 @@ protected: // ************************************************************************** // class BOOST_TEST_DECL master_test_suite_t : public test_suite { -public: +private: master_test_suite_t(); - + master_test_suite_t(const master_test_suite_t&); // undefined + master_test_suite_t& operator=(master_test_suite_t const &); // undefined + +public: // Data members int argc; char** argv; + + friend BOOST_TEST_DECL master_test_suite_t& boost::unit_test::framework::master_test_suite(); }; // ************************************************************************** // diff --git a/contrib/restricted/boost/test/include/boost/test/unit_test_log.hpp b/contrib/restricted/boost/test/include/boost/test/unit_test_log.hpp index 6944ffa79a..27a1072701 100644 --- a/contrib/restricted/boost/test/include/boost/test/unit_test_log.hpp +++ b/contrib/restricted/boost/test/include/boost/test/unit_test_log.hpp @@ -22,7 +22,6 @@ #include <boost/test/detail/fwd_decl.hpp> #include <boost/test/utils/wrap_stringstream.hpp> -#include <boost/test/utils/trivial_singleton.hpp> #include <boost/test/utils/lazy_ostream.hpp> // Boost @@ -109,21 +108,22 @@ private: /// @see /// - boost::unit_test::test_observer /// - boost::unit_test::unit_test_log_formatter -class BOOST_TEST_DECL unit_test_log_t : public test_observer, public singleton<unit_test_log_t> { +class BOOST_TEST_DECL unit_test_log_t : public test_observer { public: // test_observer interface implementation - virtual void test_start( counter_t test_cases_amount ); - virtual void test_finish(); - virtual void test_aborted(); + void test_start( counter_t test_cases_amount, test_unit_id ) BOOST_OVERRIDE; + void test_finish() BOOST_OVERRIDE; + void test_aborted() BOOST_OVERRIDE; - virtual void test_unit_start( test_unit const& ); - virtual void test_unit_finish( test_unit const&, unsigned long elapsed ); - virtual void test_unit_skipped( test_unit const&, const_string ); - virtual void test_unit_aborted( test_unit const& ); + void test_unit_start( test_unit const& ) BOOST_OVERRIDE; + void test_unit_finish( test_unit const&, unsigned long elapsed ) BOOST_OVERRIDE; + void test_unit_skipped( test_unit const&, const_string ) BOOST_OVERRIDE; + void test_unit_aborted( test_unit const& ) BOOST_OVERRIDE; + void test_unit_timed_out( test_unit const& ) BOOST_OVERRIDE; - virtual void exception_caught( execution_exception const& ex ); + void exception_caught( execution_exception const& ex ) BOOST_OVERRIDE; - virtual int priority() { return 2; } + int priority() BOOST_OVERRIDE { return 2; } // log configuration methods //! Sets the stream for all loggers @@ -147,13 +147,15 @@ public: //! Sets the threshold level for all loggers/formatters. //! //! This will override the log level of all loggers, whether enabled or not. - void set_threshold_level( log_level ); + //! @return the minimum of the previous log level of all formatters (new in Boost 1.73) + log_level set_threshold_level( log_level ); //! Sets the threshold/log level of a specific format //! //! @note Has no effect if the specified format is not found //! @par Since Boost 1.62 - void set_threshold_level( output_format, log_level ); + //! @return the previous log level of the corresponding formatter (new in Boost 1.73) + log_level set_threshold_level( output_format, log_level ); //! Add a format to the set of loggers //! @@ -183,7 +185,7 @@ public: //! several loggers are active, the order of priority is CUSTOM, HRF, XML, and JUNIT. //! If (unit_test_log_formatter*)0 is given as argument, the custom logger (if any) is removed. //! - //! @note The ownership of the pointer is transfered to the Boost.Test framework. This call is equivalent to + //! @note The ownership of the pointer is transferred to the Boost.Test framework. This call is equivalent to //! - a call to @c add_formatter //! - a call to @c set_format(OF_CUSTOM_LOGGER) //! - a configuration of the newly added logger with a previously configured stream and log level. @@ -199,7 +201,7 @@ public: //! If (unit_test_log_formatter*)0 is given as argument, the custom logger (if any) is removed and //! no other action is performed. //! - //! @note The ownership of the pointer is transfered to the Boost.Test framework. + //! @note The ownership of the pointer is transferred to the Boost.Test framework. //! @par Since Boost 1.62 void add_formatter( unit_test_log_formatter* the_formatter ); @@ -215,12 +217,10 @@ public: ut_detail::entry_value_collector operator()( log_level ); // initiate entry collection + //! Prepares internal states after log levels, streams and format has been set up + void configure(); private: - // Implementation helpers - bool log_entry_start(output_format log_format); - void log_entry_context( log_level l ); - void clear_entry_context(); - + // Singleton BOOST_TEST_SINGLETON_CONS( unit_test_log_t ) }; // unit_test_log_t @@ -244,7 +244,7 @@ BOOST_TEST_SINGLETON_INST( unit_test_log ) (::boost::unit_test::unit_test_log \ << ::boost::unit_test::log::begin( \ "boost.test framework", \ - __LINE__ )) \ + 0 )) \ ( ::boost::unit_test::log_messages ) \ << BOOST_TEST_LAZY_MSG( M ) \ /**/ diff --git a/contrib/restricted/boost/test/include/boost/test/unit_test_log_formatter.hpp b/contrib/restricted/boost/test/include/boost/test/unit_test_log_formatter.hpp index 79b74e0849..6ec72cafa7 100644 --- a/contrib/restricted/boost/test/include/boost/test/unit_test_log_formatter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/unit_test_log_formatter.hpp @@ -139,8 +139,9 @@ public: /// Invoked when Unit Test Framework build information is requested /// - /// @param[in] os output stream to write a messages into - virtual void log_build_info( std::ostream& os ) = 0; + /// @param[in] os output stream to write a messages into + /// @param[in] log_build_info indicates if build info should be logged or not + virtual void log_build_info( std::ostream& os, bool log_build_info = true ) = 0; // @} // @name Test unit start/finish @@ -171,11 +172,16 @@ public: } /// Deprecated version of this interface + /// @deprecated virtual void test_unit_skipped( std::ostream& /* os */, test_unit const& /* tu */) {} /// Invoked when a test unit is aborted virtual void test_unit_aborted( std::ostream& /* os */, test_unit const& /* tu */) {} + /// Invoked when a test unit times-out + virtual void test_unit_timed_out( std::ostream& /* os */, test_unit const& /* tu */) {} + + // @} // @name Uncaught exception report @@ -319,4 +325,3 @@ protected: #include <boost/test/detail/enable_warnings.hpp> #endif // BOOST_TEST_UNIT_TEST_LOG_FORMATTER_HPP_071894GER - diff --git a/contrib/restricted/boost/test/include/boost/test/unit_test_monitor.hpp b/contrib/restricted/boost/test/include/boost/test/unit_test_monitor.hpp index 1f937fa674..3e7919a5aa 100644 --- a/contrib/restricted/boost/test/include/boost/test/unit_test_monitor.hpp +++ b/contrib/restricted/boost/test/include/boost/test/unit_test_monitor.hpp @@ -17,7 +17,6 @@ // Boost.Test #include <boost/test/execution_monitor.hpp> #include <boost/test/detail/fwd_decl.hpp> -#include <boost/test/utils/trivial_singleton.hpp> #include <boost/test/detail/suppress_warnings.hpp> @@ -30,11 +29,13 @@ namespace unit_test { // ************** unit_test_monitor ************** // // ************************************************************************** // -class BOOST_TEST_DECL unit_test_monitor_t : public singleton<unit_test_monitor_t>, public execution_monitor { +class BOOST_TEST_DECL unit_test_monitor_t :public execution_monitor { public: enum error_level { test_ok = 0, - precondition_failure = -1, + /// Indicates a failure to prepare the unit test (eg. fixture). Does not + /// account for tests skipped because of parent tests failed/skipped. + test_setup_failure = -1, unexpected_exception = -2, os_exception = -3, os_timeout = -4, @@ -44,9 +45,10 @@ public: static bool is_critical_error( error_level e ) { return e <= fatal_error; } // monitor method - error_level execute_and_translate( boost::function<void ()> const& func, unsigned timeout = 0 ); + // timeout is expressed in seconds + error_level execute_and_translate( boost::function<void ()> const& func, unsigned long int timeout_microseconds = 0 ); -private: + // singleton pattern BOOST_TEST_SINGLETON_CONS( unit_test_monitor_t ) }; diff --git a/contrib/restricted/boost/test/include/boost/test/unit_test_parameters.hpp b/contrib/restricted/boost/test/include/boost/test/unit_test_parameters.hpp index e01bbd7aed..e7e60d344f 100644 --- a/contrib/restricted/boost/test/include/boost/test/unit_test_parameters.hpp +++ b/contrib/restricted/boost/test/include/boost/test/unit_test_parameters.hpp @@ -112,11 +112,21 @@ public: if( stream_name == "stderr" ) { m_stream = &std::cerr; - m_cleaner.reset(); + if(cleaner_callback) { + m_cleaner = boost::make_shared<callback_cleaner>(cleaner_callback); + } + else { + m_cleaner.reset(); + } } else if( stream_name == "stdout" ) { m_stream = &std::cout; - m_cleaner.reset(); + if (cleaner_callback) { + m_cleaner = boost::make_shared<callback_cleaner>(cleaner_callback); + } + else { + m_cleaner.reset(); + } } else { m_cleaner = boost::make_shared<callback_cleaner>(cleaner_callback); diff --git a/contrib/restricted/boost/test/include/boost/test/unit_test_suite.hpp b/contrib/restricted/boost/test/include/boost/test/unit_test_suite.hpp index 13ff804b44..f74a4c47a5 100644 --- a/contrib/restricted/boost/test/include/boost/test/unit_test_suite.hpp +++ b/contrib/restricted/boost/test/include/boost/test/unit_test_suite.hpp @@ -13,6 +13,7 @@ #define BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER // Boost.Test +#include <boost/test/detail/config.hpp> #include <boost/test/framework.hpp> #include <boost/test/tree/auto_registration.hpp> #include <boost/test/tree/test_case_template.hpp> @@ -32,10 +33,12 @@ // ************** Non-auto (explicit) test case interface ************** // // ************************************************************************** // -#define BOOST_TEST_CASE( test_function ) \ +#define BOOST_TEST_CASE_NAME( test_function, test_name ) \ boost::unit_test::make_test_case( boost::function<void ()>(test_function), \ - BOOST_TEST_STRINGIZE( test_function ), \ + test_name , \ __FILE__, __LINE__ ) +#define BOOST_TEST_CASE( test_function ) \ +BOOST_TEST_CASE_NAME(test_function, BOOST_TEST_STRINGIZE( test_function) ) #define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \ boost::unit_test::make_test_case( (test_function), \ BOOST_TEST_STRINGIZE( test_function ), \ @@ -63,7 +66,7 @@ BOOST_AUTO_TU_REGISTRAR( suite_name )( \ #define BOOST_AUTO_TEST_SUITE_NO_DECOR( suite_name ) \ BOOST_AUTO_TEST_SUITE_WITH_DECOR( \ suite_name, \ - boost::unit_test::decorator::collector::instance() ) \ + boost::unit_test::decorator::collector_t::instance() ) \ /**/ #if BOOST_PP_VARIADICS @@ -167,7 +170,7 @@ void test_name::test_method() \ #define BOOST_FIXTURE_TEST_CASE_NO_DECOR( test_name, F ) \ BOOST_FIXTURE_TEST_CASE_WITH_DECOR( test_name, F, \ - boost::unit_test::decorator::collector::instance() ) \ + boost::unit_test::decorator::collector_t::instance() ) \ /**/ #if BOOST_PP_VARIADICS @@ -233,12 +236,15 @@ struct BOOST_AUTO_TC_INVOKER( test_name ) { \ template<typename TestType> \ static void run( boost::type<TestType>* = 0 ) \ { \ - BOOST_TEST_CHECKPOINT('"' << #test_name <<"\" fixture entry."); \ - test_name<TestType> t; boost::unit_test::setup_conditional(t); \ - BOOST_TEST_CHECKPOINT('"' << #test_name << "\" entry."); \ + BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture ctor"); \ + test_name<TestType> t; \ + BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture setup"); \ + boost::unit_test::setup_conditional(t); \ + BOOST_TEST_CHECKPOINT('"' << #test_name << "\" test entry"); \ t.test_method(); \ - BOOST_TEST_CHECKPOINT('"' << #test_name << "\" exit."); \ + BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture teardown");\ boost::unit_test::teardown_conditional(t); \ + BOOST_TEST_CHECKPOINT('"' << #test_name << "\" fixture dtor"); \ } \ }; \ \ @@ -246,7 +252,7 @@ BOOST_AUTO_TU_REGISTRAR( test_name )( \ boost::unit_test::ut_detail::template_test_case_gen< \ BOOST_AUTO_TC_INVOKER( test_name ),TL >( \ BOOST_STRINGIZE( test_name ), __FILE__, __LINE__ ), \ - boost::unit_test::decorator::collector::instance() ); \ + boost::unit_test::decorator::collector_t::instance() ); \ \ template<typename type_name> \ void test_name<type_name>::test_method() \ @@ -319,8 +325,8 @@ static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) // ************************************************************************** // #define BOOST_TEST_DECORATOR( D ) \ -static boost::unit_test::decorator::collector const& \ -BOOST_TEST_APPEND_UNIQUE_ID(decorator_collector) = D; \ +static boost::unit_test::decorator::collector_t const& \ +BOOST_TEST_APPEND_UNIQUE_ID(decorator_collector) BOOST_ATTRIBUTE_UNUSED = D; \ /**/ // ************************************************************************** // @@ -343,7 +349,7 @@ typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE; // ************************************************************************** // // Facility for having a unique name based on __LINE__ and __COUNTER__ (later if available) -#if defined(__COUNTER__) +#if defined(__COUNTER__) #define BOOST_TEST_INTERNAL_HAS_COUNTER #endif @@ -360,7 +366,7 @@ typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE; #define BOOST_AUTO_TU_REGISTRAR( test_name ) \ static boost::unit_test::ut_detail::auto_test_unit_registrar \ -BOOST_TEST_APPEND_UNIQUE_ID( BOOST_JOIN( test_name, _registrar ) ) \ +BOOST_TEST_APPEND_UNIQUE_ID( BOOST_JOIN( test_name, _registrar ) ) BOOST_ATTRIBUTE_UNUSED \ /**/ #define BOOST_AUTO_TC_INVOKER( test_name ) BOOST_JOIN( test_name, _invoker ) #define BOOST_AUTO_TC_UNIQUE_ID( test_name ) BOOST_JOIN( test_name, _id ) @@ -371,6 +377,12 @@ BOOST_TEST_APPEND_UNIQUE_ID( BOOST_JOIN( test_name, _registrar ) ) \ #if defined(BOOST_TEST_MAIN) +// initializing the master test suite name from the user defined macros +// this function should be seen exactly once. +#ifdef BOOST_TEST_MODULE +static const boost::unit_test::framework::impl::master_test_suite_name_setter mtsetter(BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" )); +#endif + #ifdef BOOST_TEST_ALTERNATIVE_INIT_API bool init_unit_test() { #else @@ -378,12 +390,6 @@ bool init_unit_test() { init_unit_test_suite( int, char* [] ) { #endif -#ifdef BOOST_TEST_MODULE - using namespace ::boost::unit_test; - assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 ); - -#endif - #ifdef BOOST_TEST_ALTERNATIVE_INIT_API return true; } diff --git a/contrib/restricted/boost/test/include/boost/test/utils/algorithm.hpp b/contrib/restricted/boost/test/include/boost/test/utils/algorithm.hpp index 7f16816c3a..d4be8565d4 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/algorithm.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/algorithm.hpp @@ -12,6 +12,8 @@ #ifndef BOOST_TEST_UTILS_ALGORITHM_HPP #define BOOST_TEST_UTILS_ALGORITHM_HPP +#include <boost/test/detail/config.hpp> + // STL #include <utility> #include <algorithm> // std::find diff --git a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring.hpp b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring.hpp index cec0214b73..158bfb20d1 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring.hpp @@ -26,6 +26,10 @@ // STL #include <string> +#if defined(BOOST_TEST_STRING_VIEW) +#include <string_view> +#endif + #include <boost/test/detail/suppress_warnings.hpp> //____________________________________________________________________________// @@ -39,7 +43,7 @@ namespace unit_test { // ************************************************************************** // template<typename CharT> -class basic_cstring { +class BOOST_SYMBOL_VISIBLE basic_cstring { typedef basic_cstring<CharT> self_type; public: // Subtypes @@ -163,7 +167,37 @@ private: // Data members iterator m_begin; iterator m_end; + static CharT null; +}; + +// ************************************************************************** // +// ************** cstring_string_view_helper ************** // +// ************************************************************************** // + + +#if defined(BOOST_TEST_STRING_VIEW) +// Helper for instanciating a subclass of cstring using a string_view. We do not +// change the API of cstring using BOOST_TEST_STRING_VIEW as the code should remain +// compatible between boost.test and test module using different compiler options. +//! @internal +template <class CharT, class string_view_t = std::basic_string_view<CharT>> +class BOOST_SYMBOL_VISIBLE stringview_cstring_helper : public basic_cstring<CharT> { +public: + stringview_cstring_helper(string_view_t const& sv) + : basic_cstring<CharT>(const_cast<CharT*>(sv.data()), sv.size()) + {} }; +#endif + + +// ************************************************************************** // +// ************** basic_cstring::impl ************** // +// ************************************************************************** // + +//____________________________________________________________________________// + +template<typename CharT> +CharT basic_cstring<CharT>::null = 0; //____________________________________________________________________________// @@ -171,7 +205,6 @@ template<typename CharT> inline typename basic_cstring<CharT>::pointer basic_cstring<CharT>::null_str() { - static CharT null = 0; return &null; } @@ -368,17 +401,22 @@ template<typename CharT> inline basic_cstring<CharT>& basic_cstring<CharT>::trim_right( basic_cstring exclusions ) { + if(!size()) { + return *this; + } + if( exclusions.is_empty() ) exclusions = default_trim_ex(); - iterator it; + iterator it = end(); - for( it = end()-1; it != begin()-1; --it ) { + do { + --it; if( self_type::traits_type::find( exclusions.begin(), exclusions.size(), *it ) == reinterpret_cast<pointer>(0) ) break; - } + } while(it != begin()); - return trim_right( it+1 ); + return trim_right( it + 1 ); } //____________________________________________________________________________// diff --git a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp index f0622263d1..0401e83215 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/basic_cstring_fwd.hpp @@ -16,13 +16,14 @@ #ifndef BOOST_TEST_UTILS_BASIC_CSTRING_FWD_HPP #define BOOST_TEST_UTILS_BASIC_CSTRING_FWD_HPP -#include <boost/detail/workaround.hpp> +#include <boost/test/detail/config.hpp> + namespace boost { namespace unit_test { -template<typename CharT> class basic_cstring; +template<typename CharT> class BOOST_SYMBOL_VISIBLE basic_cstring; typedef basic_cstring<char const> const_string; #if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041)) typedef const_string literal_string; @@ -32,9 +33,14 @@ typedef const_string const literal_string; typedef char const* const c_literal_string; +#if defined(BOOST_TEST_STRING_VIEW) +template <class CharT, class string_view_t> +class BOOST_SYMBOL_VISIBLE stringview_cstring_helper; +#endif + + } // namespace unit_test } // namespace boost #endif // BOOST_TEST_UTILS_BASIC_CSTRING_FWD_HPP - diff --git a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/bcs_char_traits.hpp b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/bcs_char_traits.hpp index eb77f474c7..05b6ffa6be 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/bcs_char_traits.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/bcs_char_traits.hpp @@ -39,7 +39,7 @@ template<typename CharT> struct bcs_base_char { typedef CharT type; }; template<> struct bcs_base_char<char const> { typedef char type; }; template<> struct bcs_base_char<unsigned char> { typedef char type; }; -#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) +#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551)) template<> struct bcs_base_char<unsigned char const> { typedef char type; }; #endif @@ -52,7 +52,7 @@ template<> struct bcs_base_char<wchar_t const> { typedef wchar_t type; template<typename CharT> struct bcs_char_traits_impl { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) +#if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) typedef CharT const const_char; #else typedef typename boost::add_const<CharT>::type const_char; diff --git a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/compare.hpp b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/compare.hpp index 2a256fc6be..0f728e6f4c 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/compare.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/basic_cstring/compare.hpp @@ -26,7 +26,7 @@ //____________________________________________________________________________// -# if defined(BOOST_NO_STDC_NAMESPACE) && !BOOST_WORKAROUND(__BORLANDC__, <= 0x570) +# if defined(BOOST_NO_STDC_NAMESPACE) && !BOOST_WORKAROUND(BOOST_BORLANDC, <= 0x570) namespace std { using ::toupper; } # endif @@ -82,7 +82,7 @@ public: typedef bool result_type; typedef basic_cstring<CharT> first_argument_type; typedef basic_cstring<CharT> second_argument_type; - + bool operator()( basic_cstring<CharT> x, basic_cstring<CharT> y ) const { return x.size() != y.size() diff --git a/contrib/restricted/boost/test/include/boost/test/utils/foreach.hpp b/contrib/restricted/boost/test/include/boost/test/utils/foreach.hpp index 68462ae719..ea1adc58cc 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/foreach.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/foreach.hpp @@ -26,7 +26,6 @@ // Boost #include <boost/type.hpp> #include <boost/mpl/bool.hpp> -#include <boost/test/detail/workaround.hpp> #include <boost/type_traits/is_const.hpp> diff --git a/contrib/restricted/boost/test/include/boost/test/utils/is_cstring.hpp b/contrib/restricted/boost/test/include/boost/test/utils/is_cstring.hpp index 12326b0418..ffec3657ac 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/is_cstring.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/is_cstring.hpp @@ -5,11 +5,8 @@ // See http://www.boost.org/libs/test for the library home page. // -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : defines the is_cstring type trait +//! @file +//! Defines the is_cstring type trait // *************************************************************************** #ifndef BOOST_TEST_UTILS_IS_CSTRING_HPP @@ -26,6 +23,10 @@ #include <boost/test/utils/basic_cstring/basic_cstring_fwd.hpp> #include <string> +#if defined(BOOST_TEST_STRING_VIEW) +#include <string_view> +#endif + //____________________________________________________________________________// namespace boost { @@ -53,16 +54,16 @@ template<> struct is_cstring_impl<wchar_t*> : public mpl::true_ {}; template <typename T, bool is_cstring = is_cstring_impl<typename boost::decay<T>::type>::value > -struct deduce_cstring_impl; +struct deduce_cstring_transform_impl; template <typename T, bool is_cstring > -struct deduce_cstring_impl<T&, is_cstring> : public deduce_cstring_impl<T, is_cstring>{}; +struct deduce_cstring_transform_impl<T&, is_cstring> : public deduce_cstring_transform_impl<T, is_cstring>{}; template <typename T, bool is_cstring > -struct deduce_cstring_impl<T const, is_cstring> : public deduce_cstring_impl<T, is_cstring>{}; +struct deduce_cstring_transform_impl<T const, is_cstring> : public deduce_cstring_transform_impl<T, is_cstring>{}; template <typename T> -struct deduce_cstring_impl<T, true> { +struct deduce_cstring_transform_impl<T, true> { typedef typename boost::add_const< typename boost::remove_pointer< typename boost::decay<T>::type @@ -72,7 +73,7 @@ struct deduce_cstring_impl<T, true> { }; template <typename T> -struct deduce_cstring_impl< T, false > { +struct deduce_cstring_transform_impl< T, false > { typedef typename boost::remove_const< typename boost::remove_reference<T>::type @@ -80,10 +81,21 @@ struct deduce_cstring_impl< T, false > { }; template <typename T> -struct deduce_cstring_impl< std::basic_string<T, std::char_traits<T> >, false > { +struct deduce_cstring_transform_impl< std::basic_string<T, std::char_traits<T> >, false > { typedef boost::unit_test::basic_cstring<typename boost::add_const<T>::type> type; }; +#if defined(BOOST_TEST_STRING_VIEW) +template <typename T> +struct deduce_cstring_transform_impl< std::basic_string_view<T, std::char_traits<T> >, false > { +private: + using sv_t = std::basic_string_view<T, std::char_traits<T> > ; + +public: + using type = stringview_cstring_helper<typename boost::add_const<T>::type, sv_t>; +}; +#endif + } // namespace ut_detail template<typename T> @@ -98,16 +110,21 @@ struct is_cstring_comparable< T, true > : public mpl::true_ {}; template<typename T> struct is_cstring_comparable< std::basic_string<T, std::char_traits<T> >, false > : public mpl::true_ {}; +#if defined(BOOST_TEST_STRING_VIEW) +template<typename T> +struct is_cstring_comparable< std::basic_string_view<T, std::char_traits<T> >, false > : public mpl::true_ {}; +#endif + template<typename T> struct is_cstring_comparable< boost::unit_test::basic_cstring<T>, false > : public mpl::true_ {}; template <class T> -struct deduce_cstring { +struct deduce_cstring_transform { typedef typename boost::remove_const< typename boost::remove_reference<T>::type >::type U; - typedef typename ut_detail::deduce_cstring_impl<typename boost::decay<U>::type>::type type; + typedef typename ut_detail::deduce_cstring_transform_impl<typename boost::decay<U>::type>::type type; }; } // namespace unit_test diff --git a/contrib/restricted/boost/test/include/boost/test/utils/is_forward_iterable.hpp b/contrib/restricted/boost/test/include/boost/test/utils/is_forward_iterable.hpp index 1c9108054b..d6d8dd8a85 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/is_forward_iterable.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/is_forward_iterable.hpp @@ -17,7 +17,7 @@ defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) // this feature works with VC2012 upd 5 while BOOST_NO_CXX11_TRAILING_RESULT_TYPES is defined - #if !defined(BOOST_MSVC) || BOOST_MSVC_FULL_VER < 170061030 /* VC2012 upd 5 */ + #if !defined(BOOST_MSVC) || BOOST_MSVC_FULL_VER < 170061232 /* VC2012 upd 5 */ #define BOOST_TEST_FWD_ITERABLE_CXX03 #endif #endif @@ -204,7 +204,7 @@ struct bt_iterator_traits< T, true >{ BOOST_STATIC_ASSERT((is_forward_iterable<T>::value)); #if defined(BOOST_TEST_FWD_ITERABLE_CXX03) || \ - (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061030)) + (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061232)) typedef typename T::const_iterator const_iterator; typedef typename std::iterator_traits<const_iterator>::value_type value_type; #else @@ -224,7 +224,7 @@ struct bt_iterator_traits< T, true >{ } #if defined(BOOST_TEST_FWD_ITERABLE_CXX03) || \ - (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061030)) + (defined(BOOST_MSVC) && (BOOST_MSVC_FULL_VER <= 170061232)) static std::size_t size(T const& container) { return container.size(); diff --git a/contrib/restricted/boost/test/include/boost/test/utils/iterator/input_iterator_facade.hpp b/contrib/restricted/boost/test/include/boost/test/utils/iterator/input_iterator_facade.hpp index d695ee3a87..2658283e4e 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/iterator/input_iterator_facade.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/iterator/input_iterator_facade.hpp @@ -29,7 +29,7 @@ namespace utils { class input_iterator_core_access { -#if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) +#if defined(BOOST_NO_MEMBER_TEMPLATE_FRIENDS) || BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x551)) public: #else template <class I, class V, class R, class TC> friend class input_iterator_facade; diff --git a/contrib/restricted/boost/test/include/boost/test/utils/lazy_ostream.hpp b/contrib/restricted/boost/test/include/boost/test/utils/lazy_ostream.hpp index 26bd8ed385..2d1edbed8e 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/lazy_ostream.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/lazy_ostream.hpp @@ -13,6 +13,7 @@ // Boost.Test #include <boost/test/detail/config.hpp> +#include <boost/test/tools/detail/print_helper.hpp> // STL #include <iosfwd> @@ -28,14 +29,22 @@ namespace boost { namespace unit_test { -class lazy_ostream { +class BOOST_TEST_DECL lazy_ostream { public: virtual ~lazy_ostream() {} - static lazy_ostream& instance() { static lazy_ostream inst; return inst; } + static lazy_ostream& instance() { return inst; } + #if !defined(BOOST_EMBTC) + friend std::ostream& operator<<( std::ostream& ostr, lazy_ostream const& o ) { return o( ostr ); } + #else + + friend std::ostream& operator<<( std::ostream& ostr, lazy_ostream const& o ); + + #endif + // access method bool empty() const { return m_empty; } @@ -47,8 +56,15 @@ protected: private: // Data members bool m_empty; + static lazy_ostream inst; }; +#if defined(BOOST_EMBTC) + + inline std::ostream& operator<<( std::ostream& ostr, lazy_ostream const& o ) { return o( ostr ); } + +#endif + //____________________________________________________________________________// template<typename PrevType, typename T, typename StorageT=T const&> @@ -61,9 +77,9 @@ public: { } - virtual std::ostream& operator()( std::ostream& ostr ) const + std::ostream& operator()( std::ostream& ostr ) const BOOST_OVERRIDE { - return m_prev(ostr) << m_value; + return m_prev(ostr) << test_tools::tt_detail::print_helper(m_value); } private: // Data members diff --git a/contrib/restricted/boost/test/include/boost/test/utils/named_params.hpp b/contrib/restricted/boost/test/include/boost/test/utils/named_params.hpp index 50de5bfba0..26dac798fc 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/named_params.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/named_params.hpp @@ -126,7 +126,7 @@ report_access_to_invalid_parameter( bool v ) struct nil { template<typename T> -#if defined(__GNUC__) || defined(__HP_aCC) || defined(__EDG__) || defined(__SUNPRO_CC) +#if defined(__GNUC__) || defined(__HP_aCC) || defined(__EDG__) || defined(__SUNPRO_CC) || defined(BOOST_EMBTC) operator T() const #else operator T const&() const diff --git a/contrib/restricted/boost/test/include/boost/test/utils/rtti.hpp b/contrib/restricted/boost/test/include/boost/test/utils/rtti.hpp index b230692d80..84225b0921 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/rtti.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/rtti.hpp @@ -17,6 +17,7 @@ // C Runtime #include <cstddef> +#include <boost/test/detail/config.hpp> namespace boost { namespace rtti { @@ -30,7 +31,7 @@ typedef std::ptrdiff_t id_t; namespace rtti_detail { template<typename T> -struct rttid_holder { +struct BOOST_TEST_DECL rttid_holder { static id_t id() { return reinterpret_cast<id_t>( &inst() ); } private: @@ -44,7 +45,7 @@ private: //____________________________________________________________________________// template<typename T> -inline id_t +BOOST_TEST_DECL inline id_t type_id() { return rtti_detail::rttid_holder<T>::id(); diff --git a/contrib/restricted/boost/test/include/boost/test/utils/runtime/argument_factory.hpp b/contrib/restricted/boost/test/include/boost/test/utils/runtime/argument_factory.hpp index f3448f8cc4..e281cf93f7 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/runtime/argument_factory.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/runtime/argument_factory.hpp @@ -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> diff --git a/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/argv_traverser.hpp b/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/argv_traverser.hpp index 10fb67bde4..476eaae2a0 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/argv_traverser.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/argv_traverser.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> @@ -47,7 +48,7 @@ public: /// Returns new argc int remainder() { - return m_argc; + return static_cast<int>(m_argc); } /// Returns true, if we reached end on input diff --git a/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/parser.hpp b/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/parser.hpp index a57091b474..9e8601f517 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/parser.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/runtime/cla/parser.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,7 +328,7 @@ public: } void - usage(std::ostream& ostr, + usage(std::ostream& ostr, cstring param_name = cstring(), bool use_color = true) { @@ -299,13 +340,13 @@ public: param->usage( ostr, m_negation_prefix ); } else { - ostr << "\n The program '" << m_program_name << "' is a Boost.test module containing unit tests."; - + 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]... "; @@ -318,7 +359,7 @@ public: ostr << "\n\n Use\n "; { - + BOOST_TEST_SCOPE_SETCOLOR( use_color, ostr, term_attr::BRIGHT, term_color::GREEN ); ostr << m_program_name << " --help"; } @@ -331,8 +372,8 @@ public: } void - help(std::ostream& ostr, - parameters_store const& parameters, + help(std::ostream& ostr, + parameters_store const& parameters, cstring param_name, bool use_color = true) { @@ -390,10 +431,10 @@ public: ostr << "\n\n The following parameters are supported:\n"; - BOOST_TEST_FOREACH( - parameters_store::storage_type::value_type const&, - v, - parameters.all() ) + BOOST_TEST_FOREACH( + parameters_store::storage_type::value_type const&, + v, + parameters.all() ) { basic_param_ptr param = v.second; ostr << "\n"; diff --git a/contrib/restricted/boost/test/include/boost/test/utils/runtime/errors.hpp b/contrib/restricted/boost/test/include/boost/test/utils/runtime/errors.hpp index 5b263d21c5..a33af62648 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/runtime/errors.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/runtime/errors.hpp @@ -37,11 +37,11 @@ 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 {} + ~param_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {} - virtual const char * what() const BOOST_NOEXCEPT_OR_NOTHROW + const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE { return msg.c_str(); } @@ -55,25 +55,25 @@ 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 {} + ~init_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {} }; -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 {} + ~input_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {} }; //____________________________________________________________________________// 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 {} + ~specific_param_error() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {} public: @@ -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 ) @@ -166,12 +166,12 @@ public: : specific_param_error<ambiguous_param,input_error>( "" ) , m_amb_candidates( amb_candidates ) {} #endif - ~ambiguous_param() BOOST_NOEXCEPT_OR_NOTHROW {} + ~ambiguous_param() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {} 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 ) @@ -182,7 +182,7 @@ public: : specific_param_error<unrecognized_param,input_error>( "" ) , m_typo_candidates( type_candidates ) {} #endif - ~unrecognized_param() BOOST_NOEXCEPT_OR_NOTHROW {} + ~unrecognized_param() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {} std::vector<cstring> m_typo_candidates; }; diff --git a/contrib/restricted/boost/test/include/boost/test/utils/runtime/modifier.hpp b/contrib/restricted/boost/test/include/boost/test/utils/runtime/modifier.hpp index f4f5a42baa..78c8817e7c 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/runtime/modifier.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/runtime/modifier.hpp @@ -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> diff --git a/contrib/restricted/boost/test/include/boost/test/utils/runtime/parameter.hpp b/contrib/restricted/boost/test/include/boost/test/utils/runtime/parameter.hpp index 420b60264d..4509107653 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/runtime/parameter.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/runtime/parameter.hpp @@ -27,7 +27,7 @@ #include <boost/test/utils/setcolor.hpp> // Boost -#include <boost/function/function2.hpp> +#include <boost/function.hpp> #include <boost/algorithm/cxx11/all_of.hpp> // STL @@ -322,15 +322,15 @@ public: } private: - virtual basic_param_ptr clone() const + basic_param_ptr clone() const BOOST_OVERRIDE { return basic_param_ptr( new parameter( *this ) ); } - virtual void produce_argument( cstring token, bool , arguments_store& store ) const + void produce_argument( cstring token, bool , arguments_store& store ) const BOOST_OVERRIDE { m_arg_factory.produce_argument( token, this->p_name, store ); } - virtual void produce_default( arguments_store& store ) const + void produce_default( arguments_store& store ) const BOOST_OVERRIDE { if( !this->p_has_default_value ) return; @@ -366,12 +366,12 @@ public: } private: - virtual basic_param_ptr clone() const + basic_param_ptr clone() const BOOST_OVERRIDE { return basic_param_ptr( new option( *this ) ); } - virtual void produce_argument( cstring token, bool negative_form, arguments_store& store ) const + void produce_argument( cstring token, bool negative_form, arguments_store& store ) const BOOST_OVERRIDE { if( token.empty() ) store.set( p_name, !negative_form ); @@ -383,11 +383,11 @@ private: } } - virtual void produce_default( arguments_store& store ) const + void produce_default( arguments_store& store ) const BOOST_OVERRIDE { m_arg_factory.produce_default( p_name, store ); } - virtual void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring negation_prefix_, bool use_color = true ) const + void cla_name_help( std::ostream& ostr, cstring cla_tag, cstring negation_prefix_, bool use_color = true ) const BOOST_OVERRIDE { namespace utils = unit_test::utils; namespace ut_detail = unit_test::ut_detail; @@ -398,7 +398,7 @@ private: } ostr << cla_tag; } - virtual void value_help( std::ostream& ostr ) const + void value_help( std::ostream& ostr ) const BOOST_OVERRIDE { if( p_value_hint.empty() ) ostr << "<boolean value>"; @@ -441,12 +441,12 @@ public: } private: - virtual basic_param_ptr clone() const + basic_param_ptr clone() const BOOST_OVERRIDE { return basic_param_ptr( new enum_parameter( *this ) ); } - virtual void value_help( std::ostream& ostr ) const + void value_help( std::ostream& ostr ) const BOOST_OVERRIDE { if( this->p_value_hint.empty() ) { ostr << "<"; @@ -498,7 +498,7 @@ public: bool is_empty() const { return m_parameters.empty(); } /// Returns map of all the registered parameter storage_type const& all() const { return m_parameters; } - /// Returns true if parameter with psecified name is registered + /// Returns true if parameter with specified name is registered bool has( cstring name ) const { return m_parameters.find( name ) != m_parameters.end(); diff --git a/contrib/restricted/boost/test/include/boost/test/utils/setcolor.hpp b/contrib/restricted/boost/test/include/boost/test/utils/setcolor.hpp index 91b068ae6f..c09e188f7c 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/setcolor.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/setcolor.hpp @@ -18,9 +18,12 @@ // Boost.Test #include <boost/test/detail/config.hpp> +#include <boost/core/ignore_unused.hpp> + // STL #include <iostream> #include <cstdio> +#include <cassert> #include <boost/test/detail/suppress_warnings.hpp> @@ -76,18 +79,38 @@ struct term_color { enum _ { #ifndef _WIN32 class setcolor { public: + typedef int state; + // Constructor - explicit setcolor( term_attr::_ attr = term_attr::NORMAL, + explicit setcolor( bool is_color_output = false, + term_attr::_ attr = term_attr::NORMAL, term_color::_ fg = term_color::ORIGINAL, - term_color::_ bg = term_color::ORIGINAL ) + term_color::_ bg = term_color::ORIGINAL, + state* /* unused */= NULL) + : m_is_color_output(is_color_output) + { + m_command_size = std::sprintf( m_control_command, "%c[%c;3%c;4%cm", + 0x1B, + static_cast<char>(attr + '0'), + static_cast<char>(fg + '0'), + static_cast<char>(bg + '0')); + } + + explicit setcolor(bool is_color_output, + state* /* unused */) + : m_is_color_output(is_color_output) { - m_command_size = std::sprintf( m_control_command, "%c[%d;%d;%dm", 0x1B, attr, fg + 30, bg + 40 ); + m_command_size = std::sprintf(m_control_command, "%c[%c;3%c;4%cm", + 0x1B, + static_cast<char>(term_attr::NORMAL + '0'), + static_cast<char>(term_color::ORIGINAL + '0'), + static_cast<char>(term_color::ORIGINAL + '0')); } friend std::ostream& operator<<( std::ostream& os, setcolor const& sc ) { - if (&os == &std::cout || &os == &std::cerr) { + if (sc.m_is_color_output && (&os == &std::cout || &os == &std::cerr)) { return os.write( sc.m_control_command, sc.m_command_size ); } return os; @@ -95,6 +118,7 @@ public: private: // Data members + bool m_is_color_output; char m_control_command[13]; int m_command_size; }; @@ -105,6 +129,9 @@ class setcolor { protected: void set_console_color(std::ostream& os, WORD *attributes = NULL) const { + if (!m_is_color_output || m_state_saved) { + return; + } DWORD console_type; if (&os == &std::cout) { console_type = STD_OUTPUT_HANDLE; @@ -120,16 +147,30 @@ protected: if(hConsole == INVALID_HANDLE_VALUE || hConsole == NULL ) return; - if(attributes != NULL) { - SetConsoleTextAttribute(hConsole, *attributes); + state console_attributes; + if(attributes != NULL || (m_restore_state && m_s)) { + if (attributes != NULL) { + console_attributes = *attributes; + } + else { + console_attributes = *m_s; + *m_s = state(); + } + SetConsoleTextAttribute(hConsole, console_attributes); return; } CONSOLE_SCREEN_BUFFER_INFO consoleInfo; GetConsoleScreenBufferInfo(hConsole, &consoleInfo); - //if(!has_written_console_ext) { - saved_attributes = consoleInfo.wAttributes; - //} + console_attributes = consoleInfo.wAttributes; + + if (!m_state_saved && m_s) { + assert(!m_restore_state); + // we can save the state only the first time this object is used + // for modifying the console. + *m_s = console_attributes; + m_state_saved = true; + } WORD fg_attr = 0; switch(m_fg) @@ -158,9 +199,9 @@ protected: case term_color::YELLOW: fg_attr = FOREGROUND_RED | FOREGROUND_GREEN; break; - case term_color::ORIGINAL: + case term_color::ORIGINAL: default: - fg_attr = saved_attributes & (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); + fg_attr = console_attributes & (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE); break; } @@ -182,9 +223,9 @@ protected: case term_color::BLUE: bg_attr = BACKGROUND_BLUE; break; - case term_color::ORIGINAL: + case term_color::ORIGINAL: default: - bg_attr = saved_attributes & (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE); + bg_attr = console_attributes & (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE); break; } @@ -201,22 +242,39 @@ protected: break; } - SetConsoleTextAttribute(hConsole, fg_attr | bg_attr | text_attr); - - //has_written_console_ext = true; + SetConsoleTextAttribute(hConsole, fg_attr | bg_attr | text_attr); return; } public: + typedef WORD state; + // Constructor explicit setcolor( + bool is_color_output = false, term_attr::_ attr = term_attr::NORMAL, term_color::_ fg = term_color::ORIGINAL, - term_color::_ bg = term_color::ORIGINAL ) - : /*has_written_console_ext(false) - , */m_attr(attr) + term_color::_ bg = term_color::ORIGINAL, + state* s = NULL) + : m_is_color_output(is_color_output) + , m_attr(attr) , m_fg(fg) , m_bg(bg) + , m_s(s) + , m_restore_state(false) + , m_state_saved(false) + {} + + explicit setcolor( + bool is_color_output, + state* s) + : m_is_color_output(is_color_output) + , m_attr(term_attr::NORMAL) + , m_fg(term_color::ORIGINAL) + , m_bg(term_color::ORIGINAL) + , m_s(s) + , m_restore_state(true) + , m_state_saved(false) {} friend std::ostream& @@ -227,14 +285,16 @@ public: } private: + bool m_is_color_output; term_attr::_ m_attr; term_color::_ m_fg; term_color::_ m_bg; - -protected: - // Data members - mutable WORD saved_attributes; - //mutable bool has_written_console_ext; + state* m_s; + // indicates that the instance has been initialized to restore a previously + // stored state + bool m_restore_state; + // indicates the first time we pull and set the console information. + mutable bool m_state_saved; }; #endif @@ -242,50 +302,29 @@ protected: // ************** scope_setcolor ************** // // ************************************************************************** // -#ifndef _WIN32 - struct scope_setcolor { - scope_setcolor() : m_os( 0 ) {} - explicit scope_setcolor( std::ostream& os, - term_attr::_ attr = term_attr::NORMAL, - term_color::_ fg = term_color::ORIGINAL, - term_color::_ bg = term_color::ORIGINAL ) - : m_os( &os ) - { - os << setcolor( attr, fg, bg ); - } - ~scope_setcolor() - { - if( m_os ) - *m_os << setcolor(); - } -private: - scope_setcolor(const scope_setcolor& r); - scope_setcolor& operator=(const scope_setcolor& r); - // Data members - std::ostream* m_os; -}; - -#else - -struct scope_setcolor : setcolor { - scope_setcolor() : m_os( 0 ) {} - explicit scope_setcolor( + scope_setcolor() + : m_os( 0 ) + , m_state() + , m_is_color_output(false) + {} + + explicit scope_setcolor( + bool is_color_output, std::ostream& os, term_attr::_ attr = term_attr::NORMAL, term_color::_ fg = term_color::ORIGINAL, term_color::_ bg = term_color::ORIGINAL ) - : - setcolor(attr, fg, bg), - m_os( &os ) + : m_os( &os ) + , m_is_color_output(is_color_output) { - os << *this; + os << setcolor(is_color_output, attr, fg, bg, &m_state); } ~scope_setcolor() { if (m_os) { - set_console_color(*m_os, &this->saved_attributes); + *m_os << setcolor(m_is_color_output, &m_state); } } private: @@ -293,17 +332,14 @@ private: scope_setcolor& operator=(const scope_setcolor& r); // Data members std::ostream* m_os; + setcolor::state m_state; + bool m_is_color_output; }; -#endif - -#define BOOST_TEST_SCOPE_SETCOLOR( is_color_output, os, attr, color ) \ - utils::scope_setcolor const sc( \ - os, \ - is_color_output ? utils::attr : utils::term_attr::NORMAL, \ - is_color_output ? utils::color : utils::term_color::ORIGINAL);\ - ut_detail::ignore_unused_variable_warning( sc ) \ +#define BOOST_TEST_SCOPE_SETCOLOR( is_color_output, os, attr, color ) \ + utils::scope_setcolor const sc(is_color_output, os, utils::attr, utils::color); \ + boost::ignore_unused( sc ) \ /**/ } // namespace utils diff --git a/contrib/restricted/boost/test/include/boost/test/utils/timer.hpp b/contrib/restricted/boost/test/include/boost/test/utils/timer.hpp new file mode 100644 index 0000000000..78dfa70828 --- /dev/null +++ b/contrib/restricted/boost/test/include/boost/test/utils/timer.hpp @@ -0,0 +1,165 @@ +// (C) Copyright Raffi Enficiaud 2019. +// 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) + +// See http://www.boost.org/libs/test for the library home page. +// +// Description : timer and elapsed types +// *************************************************************************** + +#ifndef BOOST_TEST_UTILS_TIMER_HPP +#define BOOST_TEST_UTILS_TIMER_HPP + +#include <boost/config.hpp> +#include <boost/cstdint.hpp> +#include <utility> +#include <ctime> + +# if defined(_WIN32) || defined(__CYGWIN__) +# define BOOST_TEST_TIMER_WINDOWS_API +# elif defined(__MACH__) && defined(__APPLE__)// && !defined(CLOCK_MONOTONIC) +# // we compile for all macs the same, CLOCK_MONOTONIC introduced in 10.12 +# define BOOST_TEST_TIMER_MACH_API +# else +# define BOOST_TEST_TIMER_POSIX_API +# if !defined(CLOCK_MONOTONIC) +# error "CLOCK_MONOTONIC not defined" +# endif +# endif + +# if defined(BOOST_TEST_TIMER_WINDOWS_API) +# include <windows.h> +# elif defined(BOOST_TEST_TIMER_MACH_API) +# include <mach/mach_time.h> +//# include <mach/mach.h> /* host_get_clock_service, mach_... */ +# else +# include <sys/time.h> +# endif + +# ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::clock_t; using ::clock; } +# endif + +namespace boost { +namespace unit_test { +namespace timer { + + struct elapsed_time + { + typedef boost::int_least64_t nanosecond_type; + + nanosecond_type wall; + nanosecond_type system; + void clear() { + wall = 0; + system = 0; + } + }; + + inline double + microsecond_wall_time( elapsed_time const& elapsed ) + { + return elapsed.wall / 1E3; + } + + inline double + second_wall_time( elapsed_time const& elapsed ) + { + return elapsed.wall / 1E9; + } + + namespace details { + #if defined(BOOST_TEST_TIMER_WINDOWS_API) + elapsed_time::nanosecond_type get_tick_freq() { + LARGE_INTEGER freq; + ::QueryPerformanceFrequency( &freq ); + return static_cast<elapsed_time::nanosecond_type>(freq.QuadPart); + } + #elif defined(BOOST_TEST_TIMER_MACH_API) + std::pair<elapsed_time::nanosecond_type, elapsed_time::nanosecond_type> get_time_base() { + mach_timebase_info_data_t timebase; + if(mach_timebase_info(&timebase) == 0) + return std::pair<elapsed_time::nanosecond_type, elapsed_time::nanosecond_type>(timebase.numer, timebase.denom); + return std::pair<elapsed_time::nanosecond_type, elapsed_time::nanosecond_type>(0, 1); + } + #endif + } + + //! Simple timing class + //! + //! This class measures the wall clock time. + class timer + { + public: + timer() + { + restart(); + } + void restart() + { + _start_time_clock = std::clock(); + #if defined(BOOST_TEST_TIMER_WINDOWS_API) + ::QueryPerformanceCounter(&_start_time_wall); + #elif defined(BOOST_TEST_TIMER_MACH_API) + _start_time_wall = mach_absolute_time(); + #else + if( ::clock_gettime( CLOCK_MONOTONIC, &_start_time_wall ) != 0 ) + { + _start_time_wall.tv_nsec = -1; + _start_time_wall.tv_sec = -1; + } + #endif + } + + // return elapsed time in seconds + elapsed_time elapsed() const + { + typedef elapsed_time::nanosecond_type nanosecond_type; + static const double clock_to_nano_seconds = 1E9 / CLOCKS_PER_SEC; + elapsed_time return_value; + + // processor / system time + return_value.system = static_cast<nanosecond_type>(double(std::clock() - _start_time_clock) * clock_to_nano_seconds); + +#if defined(BOOST_TEST_TIMER_WINDOWS_API) + static const nanosecond_type tick_per_sec = details::get_tick_freq(); + LARGE_INTEGER end_time; + ::QueryPerformanceCounter(&end_time); + return_value.wall = static_cast<nanosecond_type>(((end_time.QuadPart - _start_time_wall.QuadPart) * 1E9) / tick_per_sec); +#elif defined(BOOST_TEST_TIMER_MACH_API) + static std::pair<nanosecond_type, nanosecond_type> timebase = details::get_time_base(); + nanosecond_type clock = mach_absolute_time() - _start_time_wall; + return_value.wall = static_cast<nanosecond_type>((clock * timebase.first) / timebase.second); +#else + struct timespec end_time; + return_value.wall = 0; + if( ::clock_gettime( CLOCK_MONOTONIC, &end_time ) == 0 ) + { + return_value.wall = static_cast<nanosecond_type>((end_time.tv_sec - _start_time_wall.tv_sec) * 1E9 + (end_time.tv_nsec - _start_time_wall.tv_nsec)); + } +#endif + + return return_value; + } + + private: + std::clock_t _start_time_clock; + #if defined(BOOST_TEST_TIMER_WINDOWS_API) + LARGE_INTEGER _start_time_wall; + #elif defined(BOOST_TEST_TIMER_MACH_API) + elapsed_time::nanosecond_type _start_time_wall; + #else + struct timespec _start_time_wall; + #endif + }; + + +//____________________________________________________________________________// + +} // namespace timer +} // namespace unit_test +} // namespace boost + +#endif // BOOST_TEST_UTILS_TIMER_HPP + diff --git a/contrib/restricted/boost/test/include/boost/test/utils/trivial_singleton.hpp b/contrib/restricted/boost/test/include/boost/test/utils/trivial_singleton.hpp deleted file mode 100644 index ac612b6393..0000000000 --- a/contrib/restricted/boost/test/include/boost/test/utils/trivial_singleton.hpp +++ /dev/null @@ -1,79 +0,0 @@ -// (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) - -// See http://www.boost.org/libs/test for the library home page. -// -// File : $RCSfile$ -// -// Version : $Revision$ -// -// Description : simple helpers for creating cusom output manipulators -// *************************************************************************** - -#ifndef BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP -#define BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP - -// Boost.Test -#include <boost/config.hpp> -#include <boost/detail/workaround.hpp> - -// Boost -#include <boost/test/detail/suppress_warnings.hpp> - -//____________________________________________________________________________// - -namespace boost { -namespace unit_test { - -// ************************************************************************** // -// ************** singleton ************** // -// ************************************************************************** // - -template<typename Derived> -class singleton { -public: - static Derived& instance() { static Derived the_inst; return the_inst; } - - BOOST_DELETED_FUNCTION(singleton(singleton const&)) - BOOST_DELETED_FUNCTION(singleton& operator=(singleton const&)) - -protected: - BOOST_DEFAULTED_FUNCTION(singleton(), {}) - BOOST_DEFAULTED_FUNCTION(~singleton(), {}) -}; - -//____________________________________________________________________________// - -#define BOOST_TEST_SINGLETON_CONS( type ) \ -friend class boost::unit_test::singleton<type>; \ -type() {} \ -/**/ - -#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042)) - -#define BOOST_TEST_SINGLETON_INST( inst ) \ -template class unit_test::singleton< BOOST_JOIN( inst, _t ) > ; \ -namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); } - -#elif defined(__APPLE_CC__) && defined(__GNUC__) && __GNUC__ < 4 -#define BOOST_TEST_SINGLETON_INST( inst ) \ -static BOOST_JOIN( inst, _t)& inst = BOOST_JOIN (inst, _t)::instance(); - -#else - -#define BOOST_TEST_SINGLETON_INST( inst ) \ -namespace { BOOST_JOIN( inst, _t)& inst = BOOST_JOIN( inst, _t)::instance(); } - -#endif - -//____________________________________________________________________________// - -} // namespace unit_test -} // namespace boost - - -#include <boost/test/detail/enable_warnings.hpp> - -#endif // BOOST_TEST_UTILS_TRIVIAL_SIGNLETON_HPP diff --git a/contrib/restricted/boost/test/include/boost/test/utils/xml_printer.hpp b/contrib/restricted/boost/test/include/boost/test/utils/xml_printer.hpp index ffaf8fcc05..7892f9c4ce 100644 --- a/contrib/restricted/boost/test/include/boost/test/utils/xml_printer.hpp +++ b/contrib/restricted/boost/test/include/boost/test/utils/xml_printer.hpp @@ -16,6 +16,7 @@ #define BOOST_TEST_UTILS_XML_PRINTER_HPP // Boost.Test +#include <boost/test/detail/global_typedef.hpp> #include <boost/test/utils/basic_cstring/basic_cstring.hpp> #include <boost/test/utils/custom_manip.hpp> #include <boost/test/utils/foreach.hpp> @@ -26,6 +27,7 @@ // STL #include <iostream> +#include <map> #include <boost/test/detail/suppress_warnings.hpp> diff --git a/contrib/restricted/boost/timer/include/boost/timer.hpp b/contrib/restricted/boost/timer/include/boost/timer.hpp deleted file mode 100644 index f3ddb41f6c..0000000000 --- a/contrib/restricted/boost/timer/include/boost/timer.hpp +++ /dev/null @@ -1,75 +0,0 @@ -// boost timer.hpp header file ---------------------------------------------// - -// Copyright Beman Dawes 1994-99. 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) - -// See http://www.boost.org/libs/timer for documentation. - -// Revision History -// 01 Apr 01 Modified to use new <boost/limits.hpp> header. (JMaddock) -// 12 Jan 01 Change to inline implementation to allow use without library -// builds. See docs for more rationale. (Beman Dawes) -// 25 Sep 99 elapsed_max() and elapsed_min() added (John Maddock) -// 16 Jul 99 Second beta -// 6 Jul 99 Initial boost version - -#ifndef BOOST_TIMER_HPP -#define BOOST_TIMER_HPP - -#include <boost/config/header_deprecated.hpp> -BOOST_HEADER_DEPRECATED( "the facilities in <boost/timer/timer.hpp>" ) - -#include <boost/config.hpp> -#include <ctime> -#include <boost/limits.hpp> - -# ifdef BOOST_NO_STDC_NAMESPACE - namespace std { using ::clock_t; using ::clock; } -# endif - - -namespace boost { - -// timer -------------------------------------------------------------------// - -// A timer object measures elapsed time. - -// It is recommended that implementations measure wall clock rather than CPU -// time since the intended use is performance measurement on systems where -// total elapsed time is more important than just process or CPU time. - -// Warnings: The maximum measurable elapsed time may well be only 596.5+ hours -// due to implementation limitations. The accuracy of timings depends on the -// accuracy of timing information provided by the underlying platform, and -// this varies a great deal from platform to platform. - -class timer -{ - public: - timer() { _start_time = std::clock(); } // postcondition: elapsed()==0 -// timer( const timer& src ); // post: elapsed()==src.elapsed() -// ~timer(){} -// timer& operator=( const timer& src ); // post: elapsed()==src.elapsed() - void restart() { _start_time = std::clock(); } // post: elapsed()==0 - double elapsed() const // return elapsed time in seconds - { return double(std::clock() - _start_time) / CLOCKS_PER_SEC; } - - double elapsed_max() const // return estimated maximum value for elapsed() - // Portability warning: elapsed_max() may return too high a value on systems - // where std::clock_t overflows or resets at surprising values. - { - return (double((std::numeric_limits<std::clock_t>::max)()) - - double(_start_time)) / double(CLOCKS_PER_SEC); - } - - double elapsed_min() const // return minimum value for elapsed() - { return double(1)/double(CLOCKS_PER_SEC); } - - private: - std::clock_t _start_time; -}; // timer - -} // namespace boost - -#endif // BOOST_TIMER_HPP |