|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81193 - in trunk/boost/test: . impl tree
From: gennadiy.rozental_at_[hidden]
Date: 2012-11-05 04:03:27
Author: rogeeff
Date: 2012-11-05 04:03:26 EST (Mon, 05 Nov 2012)
New Revision: 81193
URL: http://svn.boost.org/trac/boost/changeset/81193
Log:
New feature: framework::current_auto_test_suite
To be used to manually register test units in a middle of automatically registered test suite
Fixes #7000
Text files modified:
trunk/boost/test/framework.hpp | 1 +
trunk/boost/test/impl/framework.ipp | 30 ++++++++++++++++++++++++------
trunk/boost/test/impl/test_tree.ipp | 26 +++++++-------------------
trunk/boost/test/tree/auto_registration.hpp | 3 ---
4 files changed, 32 insertions(+), 28 deletions(-)
Modified: trunk/boost/test/framework.hpp
==============================================================================
--- trunk/boost/test/framework.hpp (original)
+++ trunk/boost/test/framework.hpp 2012-11-05 04:03:26 EST (Mon, 05 Nov 2012)
@@ -84,6 +84,7 @@
// Master test suite access
BOOST_TEST_DECL master_test_suite_t& master_test_suite();
+BOOST_TEST_DECL test_suite& current_auto_test_suite( test_suite* ts = 0, bool push_or_pop = true );
// constant access methods
BOOST_TEST_DECL test_case const& current_test_case();
Modified: trunk/boost/test/impl/framework.ipp
==============================================================================
--- trunk/boost/test/impl/framework.ipp (original)
+++ trunk/boost/test/impl/framework.ipp 2012-11-05 04:03:26 EST (Mon, 05 Nov 2012)
@@ -322,14 +322,16 @@
class framework_impl : public test_tree_visitor {
public:
framework_impl()
- : m_master_test_suite( 0 )
- , m_curr_test_case( INV_TEST_UNIT_ID )
+ : m_curr_test_case( INV_TEST_UNIT_ID )
, m_next_test_case_id( MIN_TEST_CASE_ID )
, m_next_test_suite_id( MIN_TEST_SUITE_ID )
, m_is_initialized( false )
, m_test_in_progress( false )
, m_context_idx( 0 )
- {}
+ {
+ m_master_test_suite = new master_test_suite_t;
+ m_auto_test_suites.push_back( m_master_test_suite );
+ }
~framework_impl() { clear(); }
@@ -460,6 +462,8 @@
typedef std::vector<context_frame> context_data;
master_test_suite_t* m_master_test_suite;
+ std::vector<test_suite*> m_auto_test_suites;
+
test_unit_id m_curr_test_case;
test_unit_store m_test_units;
@@ -949,15 +953,29 @@
master_test_suite_t&
master_test_suite()
{
- if( !s_frk_impl().m_master_test_suite )
- s_frk_impl().m_master_test_suite = new master_test_suite_t;
-
return *s_frk_impl().m_master_test_suite;
}
//____________________________________________________________________________//
// ************************************************************************** //
+// ************** current_auto_test_suite ************** //
+// ************************************************************************** //
+
+test_suite&
+current_auto_test_suite( test_suite* ts, bool push_or_pop )
+{
+ if( !push_or_pop )
+ s_frk_impl().m_auto_test_suites.pop_back();
+ else if( ts )
+ s_frk_impl().m_auto_test_suites.push_back( ts );
+
+ return *s_frk_impl().m_auto_test_suites.back();
+}
+
+//____________________________________________________________________________//
+
+// ************************************************************************** //
// ************** current_test_case ************** //
// ************************************************************************** //
Modified: trunk/boost/test/impl/test_tree.ipp
==============================================================================
--- trunk/boost/test/impl/test_tree.ipp (original)
+++ trunk/boost/test/impl/test_tree.ipp 2012-11-05 04:03:26 EST (Mon, 05 Nov 2012)
@@ -284,7 +284,7 @@
auto_test_unit_registrar::auto_test_unit_registrar( test_case* tc, decorator::collector* decorators, counter_t exp_fail )
{
- curr_ts_store().back()->add( tc, exp_fail );
+ framework::current_auto_test_suite().add( tc, exp_fail );
if( decorators )
decorators->store_in( *tc );
@@ -294,30 +294,30 @@
auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators )
{
- test_unit_id id = curr_ts_store().back()->get( ts_name );
+ test_unit_id id = framework::current_auto_test_suite().get( ts_name );
test_suite* ts;
if( id != INV_TEST_UNIT_ID ) {
ts = &framework::get<test_suite>( id );
- BOOST_ASSERT( ts->p_parent_id == curr_ts_store().back()->p_id );
+ BOOST_ASSERT( ts->p_parent_id == framework::current_auto_test_suite().p_id );
}
else {
ts = new test_suite( ts_name );
- curr_ts_store().back()->add( ts );
+ framework::current_auto_test_suite().add( ts );
}
if( decorators )
decorators->store_in( *ts );
- curr_ts_store().push_back( ts );
+ framework::current_auto_test_suite( ts );
}
//____________________________________________________________________________//
auto_test_unit_registrar::auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector* /*decorators*/ )
{
- curr_ts_store().back()->add( tc_gen );
+ framework::current_auto_test_suite().add( tc_gen );
// !! ?? if( decorators )
// decorators->apply( *tc );
@@ -327,19 +327,7 @@
auto_test_unit_registrar::auto_test_unit_registrar( int )
{
- if( curr_ts_store().size() == 0 )
- return; // report error?
-
- curr_ts_store().pop_back();
-}
-
-//____________________________________________________________________________//
-
-std::list<test_suite*>&
-auto_test_unit_registrar::curr_ts_store()
-{
- static std::list<test_suite*> inst( 1, &framework::master_test_suite() );
- return inst;
+ framework::current_auto_test_suite( 0, false );
}
//____________________________________________________________________________//
Modified: trunk/boost/test/tree/auto_registration.hpp
==============================================================================
--- trunk/boost/test/tree/auto_registration.hpp (original)
+++ trunk/boost/test/tree/auto_registration.hpp 2012-11-05 04:03:26 EST (Mon, 05 Nov 2012)
@@ -41,9 +41,6 @@
explicit auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators );
explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector* decorators );
explicit auto_test_unit_registrar( int );
-
-private:
- static std::list<test_suite*>& curr_ts_store();
};
} // namespace ut_detail
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk