1 // (C) Copyright Gennadiy Rozental 2001.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 // See http://www.boost.org/libs/test for the library home page.
10 // Version : $Revision$
12 // Description : implements framework API - main driver for the test
13 // ***************************************************************************
15 #ifndef BOOST_TEST_FRAMEWORK_IPP_021005GER
16 #define BOOST_TEST_FRAMEWORK_IPP_021005GER
19 #include <boost/test/framework.hpp>
20 #include <boost/test/execution_monitor.hpp>
21 #include <boost/test/debug.hpp>
22 #include <boost/test/unit_test_parameters.hpp>
24 #include <boost/test/unit_test_log.hpp>
25 #include <boost/test/unit_test_log_formatter.hpp>
26 #include <boost/test/unit_test_monitor.hpp>
27 #include <boost/test/results_collector.hpp>
28 #include <boost/test/progress_monitor.hpp>
29 #include <boost/test/results_reporter.hpp>
30 #include <boost/test/test_framework_init_observer.hpp>
32 #include <boost/test/tree/observer.hpp>
33 #include <boost/test/tree/test_unit.hpp>
34 #include <boost/test/tree/visitor.hpp>
35 #include <boost/test/tree/traverse.hpp>
36 #include <boost/test/tree/test_case_counter.hpp>
38 #if BOOST_TEST_SUPPORT_TOKEN_ITERATOR
39 #include <boost/test/utils/iterator/token_iterator.hpp>
42 #include <boost/test/utils/foreach.hpp>
43 #include <boost/test/utils/basic_cstring/io.hpp>
44 #include <boost/test/utils/basic_cstring/compare.hpp>
46 #include <boost/test/detail/global_typedef.hpp>
47 #include <boost/test/detail/throw_exception.hpp>
50 #include <boost/timer.hpp>
51 #include <boost/bind.hpp>
60 #ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE
64 #ifdef BOOST_NO_STDC_NAMESPACE
65 namespace std { using ::time; using ::srand; }
68 #include <boost/test/detail/suppress_warnings.hpp>
70 //____________________________________________________________________________//
78 // ************************************************************************** //
79 // ************** order detection helpers ************** //
80 // ************************************************************************** //
83 order_info() : depth(-1) {}
86 std::vector<test_unit_id> dependant_siblings;
89 typedef std::set<test_unit_id> tu_id_set;
90 typedef std::map<test_unit_id,order_info> order_info_per_tu; // !! ?? unordered map
92 //____________________________________________________________________________//
95 get_tu_parent( test_unit_id tu_id )
97 return framework::get( tu_id, TUT_ANY ).p_parent_id;
100 //____________________________________________________________________________//
103 tu_depth( test_unit_id tu_id, test_unit_id master_tu_id, order_info_per_tu& tuoi )
105 if( tu_id == master_tu_id )
108 order_info& info = tuoi[tu_id];
110 if( info.depth == -1 )
111 info.depth = tu_depth( get_tu_parent( tu_id ), master_tu_id, tuoi ) + 1;
116 //____________________________________________________________________________//
119 collect_dependant_siblings( test_unit_id from, test_unit_id to, test_unit_id master_tu_id, order_info_per_tu& tuoi )
121 int from_depth = tu_depth( from, master_tu_id, tuoi );
122 int to_depth = tu_depth( to, master_tu_id, tuoi );
124 while(from_depth > to_depth) {
125 from = get_tu_parent( from );
129 while(from_depth < to_depth) {
130 to = get_tu_parent( to );
135 test_unit_id from_parent = get_tu_parent( from );
136 test_unit_id to_parent = get_tu_parent( to );
137 if( from_parent == to_parent )
143 tuoi[from].dependant_siblings.push_back( to );
146 //____________________________________________________________________________//
149 assign_sibling_rank( test_unit_id tu_id, order_info_per_tu& tuoi )
151 test_unit& tu = framework::get( tu_id, TUT_ANY );
153 BOOST_TEST_SETUP_ASSERT( tu.p_sibling_rank != (std::numeric_limits<counter_t>::max)(),
154 "Cyclic dependency detected involving test unit \"" + tu.full_name() + "\"" );
156 if( tu.p_sibling_rank != 0 )
157 return tu.p_sibling_rank;
159 order_info const& info = tuoi[tu_id];
161 // indicate in progress
162 tu.p_sibling_rank.value = (std::numeric_limits<counter_t>::max)();
164 counter_t new_rank = 1;
165 BOOST_TEST_FOREACH( test_unit_id, sibling_id, info.dependant_siblings )
166 new_rank = (std::max)(new_rank, assign_sibling_rank( sibling_id, tuoi ) + 1);
168 return tu.p_sibling_rank.value = new_rank;
171 //____________________________________________________________________________//
173 // ************************************************************************** //
174 // ************** test_init call wrapper ************** //
175 // ************************************************************************** //
178 invoke_init_func( init_unit_test_func init_func )
180 #ifdef BOOST_TEST_ALTERNATIVE_INIT_API
181 BOOST_TEST_I_ASSRT( (*init_func)(), std::runtime_error( "test module initialization failed" ) );
183 test_suite* manual_test_units = (*init_func)( framework::master_test_suite().argc, framework::master_test_suite().argv );
185 if( manual_test_units )
186 framework::master_test_suite().add( manual_test_units );
190 // ************************************************************************** //
191 // ************** name_filter ************** //
192 // ************************************************************************** //
194 class name_filter : public test_tree_visitor {
196 component( const_string name ) // has to be implicit
200 else if( first_char( name ) == '*' && last_char( name ) == '*' ) {
202 m_name = name.substr( 1, name.size()-1 );
204 else if( first_char( name ) == '*' ) {
205 m_kind = SFK_TRAILING;
206 m_name = name.substr( 1 );
208 else if( last_char( name ) == '*' ) {
209 m_kind = SFK_LEADING;
210 m_name = name.substr( 0, name.size()-1 );
218 bool pass( test_unit const& tu ) const
220 const_string name( tu.p_name );
227 return name.substr( 0, m_name.size() ) == m_name;
229 return name.size() >= m_name.size() && name.substr( name.size() - m_name.size() ) == m_name;
231 return name.find( m_name ) != const_string::npos;
233 return m_name == tu.p_name.get();
236 enum kind { SFK_ALL, SFK_LEADING, SFK_TRAILING, SFK_SUBSTR, SFK_MATCH };
244 name_filter( test_unit_id_list& targ_list, const_string filter_expr ) : m_targ_list( targ_list ), m_depth( 0 )
246 #ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
247 utils::string_token_iterator tit( filter_expr, (utils::dropped_delimeters = "/",
248 utils::kept_delimeters = utils::dt_none) );
250 while( tit != utils::string_token_iterator() ) {
251 m_components.push_back(
252 std::vector<component>( utils::string_token_iterator( *tit, (utils::dropped_delimeters = ",",
253 utils::kept_delimeters = utils::dt_none) ),
254 utils::string_token_iterator() ) );
262 bool filter_unit( test_unit const& tu )
264 // skip master test suite
268 // corresponding name filters are at level m_depth-1
269 std::vector<component> const& filters = m_components[m_depth-1];
272 using namespace boost::placeholders;
273 return std::find_if( filters.begin(), filters.end(), bind( &component::pass, _1, boost::ref(tu) ) ) != filters.end();
276 // test_tree_visitor interface
277 virtual void visit( test_case const& tc )
279 // make sure we only accept test cases if we match last component of the filter
280 if( m_depth == m_components.size() && filter_unit( tc ) )
281 m_targ_list.push_back( tc.p_id ); // found a test case
283 virtual bool test_suite_start( test_suite const& ts )
285 if( !filter_unit( ts ) )
288 if( m_depth < m_components.size() ) {
293 m_targ_list.push_back( ts.p_id ); // found a test suite
297 virtual void test_suite_finish( test_suite const& /*ts*/ )
303 typedef std::vector<std::vector<component> > components_per_level;
305 components_per_level m_components;
306 test_unit_id_list& m_targ_list;
310 // ************************************************************************** //
311 // ************** label_filter ************** //
312 // ************************************************************************** //
314 class label_filter : public test_tree_visitor {
316 label_filter( test_unit_id_list& targ_list, const_string label )
317 : m_targ_list( targ_list )
322 // test_tree_visitor interface
323 virtual bool visit( test_unit const& tu )
325 if( tu.has_label( m_label ) ) {
326 // found a test unit; add it to list of tu to enable with children and stop recursion in case of suites
327 m_targ_list.push_back( tu.p_id );
335 test_unit_id_list& m_targ_list;
336 const_string m_label;
339 // ************************************************************************** //
340 // ************** set_run_status ************** //
341 // ************************************************************************** //
343 class set_run_status : public test_tree_visitor {
345 explicit set_run_status( test_unit::run_status rs, test_unit_id_list* dep_collector = 0 )
347 , m_dep_collector( dep_collector )
351 // test_tree_visitor interface
352 virtual bool visit( test_unit const& tu )
354 const_cast<test_unit&>(tu).p_run_status.value = m_new_status == test_unit::RS_INVALID ? tu.p_default_status : m_new_status;
356 if( m_dep_collector ) {
357 BOOST_TEST_FOREACH( test_unit_id, dep_id, tu.p_dependencies.get() ) {
358 test_unit const& dep = framework::get( dep_id, TUT_ANY );
360 if( dep.p_run_status == tu.p_run_status )
363 BOOST_TEST_FRAMEWORK_MESSAGE( "Including test " << dep.p_type_name << ' ' << dep.full_name() <<
364 " as a dependency of test " << tu.p_type_name << ' ' << tu.full_name() );
366 m_dep_collector->push_back( dep_id );
373 test_unit::run_status m_new_status;
374 test_unit_id_list* m_dep_collector;
377 // ************************************************************************** //
378 // ************** parse_filters ************** //
379 // ************************************************************************** //
382 add_filtered_test_units( test_unit_id master_tu_id, const_string filter, test_unit_id_list& targ )
384 // Choose between two kinds of filters
385 if( filter[0] == '@' ) {
386 filter.trim_left( 1 );
387 label_filter lf( targ, filter );
388 traverse_test_tree( master_tu_id, lf, true );
391 name_filter nf( targ, filter );
392 traverse_test_tree( master_tu_id, nf, true );
396 //____________________________________________________________________________//
399 parse_filters( test_unit_id master_tu_id, test_unit_id_list& tu_to_enable, test_unit_id_list& tu_to_disable )
401 // 10. collect tu to enable and disable based on filters
402 bool had_selector_filter = false;
404 std::vector<std::string> const& filters = runtime_config::get<std::vector<std::string> >( runtime_config::btrt_run_filters );
406 BOOST_TEST_FOREACH( const_string, filter, filters ) {
407 BOOST_TEST_SETUP_ASSERT( !filter.is_empty(), "Invalid filter specification" );
409 // each --run_test command may also be separated by a ':' (environment variable)
410 utils::string_token_iterator t_filter_it( filter, (utils::dropped_delimeters = ":",
411 utils::kept_delimeters = utils::dt_none) );
413 while( t_filter_it != utils::string_token_iterator() ) {
414 const_string filter_token = *t_filter_it;
416 enum { SELECTOR, ENABLER, DISABLER } filter_type = SELECTOR;
418 // 11. Deduce filter type
419 if( filter_token[0] == '!' || filter_token[0] == '+' ) {
420 filter_type = filter_token[0] == '+' ? ENABLER : DISABLER;
421 filter_token.trim_left( 1 );
422 BOOST_TEST_SETUP_ASSERT( !filter_token.is_empty(), "Invalid filter specification" );
425 had_selector_filter |= filter_type == SELECTOR;
427 // 12. Add test units to corresponding list
428 switch( filter_type ) {
430 case ENABLER: add_filtered_test_units( master_tu_id, filter_token, tu_to_enable ); break;
431 case DISABLER: add_filtered_test_units( master_tu_id, filter_token, tu_to_disable ); break;
438 return had_selector_filter;
441 //____________________________________________________________________________//
443 #ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE
445 // a poor man's implementation of random_shuffle
446 template< class RandomIt, class RandomFunc >
447 void random_shuffle( RandomIt first, RandomIt last, RandomFunc &r )
449 typedef typename std::iterator_traits<RandomIt>::difference_type difference_type;
450 difference_type n = last - first;
451 for (difference_type i = n-1; i > 0; --i) {
452 difference_type j = r(i+1);
455 swap(first[i], first[j]);
463 // A simple handle for registering the global fixtures to the master test suite
464 // without deleting an existing static object (the global fixture itself) when the program
465 // terminates (shared_ptr).
466 class global_fixture_handle : public test_unit_fixture {
468 global_fixture_handle(test_unit_fixture* fixture) : m_global_fixture(fixture) {}
469 ~global_fixture_handle() {}
471 virtual void setup() {
472 m_global_fixture->setup();
474 virtual void teardown() {
475 m_global_fixture->teardown();
479 test_unit_fixture* m_global_fixture;
485 // ************************************************************************** //
486 // ************** framework::state ************** //
487 // ************************************************************************** //
489 unsigned const TIMEOUT_EXCEEDED = static_cast<unsigned>( -1 );
494 : m_curr_test_unit( INV_TEST_UNIT_ID )
495 , m_next_test_case_id( MIN_TEST_CASE_ID )
496 , m_next_test_suite_id( MIN_TEST_SUITE_ID )
497 , m_test_in_progress( false )
500 , m_report_sink( std::cerr )
504 ~state() { clear(); }
508 while( !m_test_units.empty() ) {
509 test_unit_store::value_type const& tu = *m_test_units.begin();
510 test_unit const* tu_ptr = tu.second;
512 // the delete will erase this element from map
513 if( ut_detail::test_id_2_unit_type( tu.second->p_id ) == TUT_SUITE )
514 delete static_cast<test_suite const*>(tu_ptr);
516 delete static_cast<test_case const*>(tu_ptr);
520 void set_tu_id( test_unit& tu, test_unit_id id ) { tu.p_id.value = id; }
522 //////////////////////////////////////////////////////////////////
524 // Validates the dependency graph and deduces the sibling dependency rank for each child
525 void deduce_siblings_order( test_unit_id tu_id, test_unit_id master_tu_id, impl::order_info_per_tu& tuoi )
527 test_unit& tu = framework::get( tu_id, TUT_ANY );
529 // collect all sibling dependancy from tu own list
530 BOOST_TEST_FOREACH( test_unit_id, dep_id, tu.p_dependencies.get() )
531 collect_dependant_siblings( tu_id, dep_id, master_tu_id, tuoi );
533 if( tu.p_type != TUT_SUITE )
536 test_suite& ts = static_cast<test_suite&>(tu);
538 // recursive call to children first
539 BOOST_TEST_FOREACH( test_unit_id, chld_id, ts.m_children )
540 deduce_siblings_order( chld_id, master_tu_id, tuoi );
542 ts.m_ranked_children.clear();
543 BOOST_TEST_FOREACH( test_unit_id, chld_id, ts.m_children ) {
544 counter_t rank = assign_sibling_rank( chld_id, tuoi );
545 ts.m_ranked_children.insert( std::make_pair( rank, chld_id ) );
549 //////////////////////////////////////////////////////////////////
551 // Finalize default run status:
552 // 1) inherit run status from parent where applicable
553 // 2) if any of test units in test suite enabled enable it as well
554 bool finalize_default_run_status( test_unit_id tu_id, test_unit::run_status parent_status )
556 test_unit& tu = framework::get( tu_id, TUT_ANY );
558 if( tu.p_default_status == test_suite::RS_INHERIT )
559 tu.p_default_status.value = parent_status;
561 // go through list of children
562 if( tu.p_type == TUT_SUITE ) {
563 bool has_enabled_child = false;
564 BOOST_TEST_FOREACH( test_unit_id, chld_id, static_cast<test_suite const&>(tu).m_children )
565 has_enabled_child |= finalize_default_run_status( chld_id, tu.p_default_status );
567 tu.p_default_status.value = has_enabled_child ? test_suite::RS_ENABLED : test_suite::RS_DISABLED;
570 return tu.p_default_status == test_suite::RS_ENABLED;
573 //////////////////////////////////////////////////////////////////
575 bool finalize_run_status( test_unit_id tu_id )
577 test_unit& tu = framework::get( tu_id, TUT_ANY );
579 // go through list of children
580 if( tu.p_type == TUT_SUITE ) {
581 bool has_enabled_child = false;
582 BOOST_TEST_FOREACH( test_unit_id, chld_id, static_cast<test_suite const&>(tu).m_children)
583 has_enabled_child |= finalize_run_status( chld_id );
585 tu.p_run_status.value = has_enabled_child ? test_suite::RS_ENABLED : test_suite::RS_DISABLED;
588 return tu.is_enabled();
591 //////////////////////////////////////////////////////////////////
593 void deduce_run_status( test_unit_id master_tu_id )
595 using namespace framework::impl;
596 test_unit_id_list tu_to_enable;
597 test_unit_id_list tu_to_disable;
599 // 10. If there are any filters supplied, figure out lists of test units to enable/disable
600 bool had_selector_filter = !runtime_config::get<std::vector<std::string> >( runtime_config::btrt_run_filters ).empty() &&
601 parse_filters( master_tu_id, tu_to_enable, tu_to_disable );
603 // 20. Set the stage: either use default run status or disable all test units
604 set_run_status initial_setter( had_selector_filter ? test_unit::RS_DISABLED : test_unit::RS_INVALID );
605 traverse_test_tree( master_tu_id, initial_setter, true );
607 // 30. Apply all selectors and enablers.
608 while( !tu_to_enable.empty() ) {
609 test_unit& tu = framework::get( tu_to_enable.back(), TUT_ANY );
611 tu_to_enable.pop_back();
613 // 35. Ignore test units which already enabled
614 if( tu.is_enabled() )
617 // set new status and add all dependencies into tu_to_enable
618 set_run_status enabler( test_unit::RS_ENABLED, &tu_to_enable );
619 traverse_test_tree( tu.p_id, enabler, true );
622 // 40. Apply all disablers
623 while( !tu_to_disable.empty() ) {
624 test_unit const& tu = framework::get( tu_to_disable.back(), TUT_ANY );
626 tu_to_disable.pop_back();
628 // 35. Ignore test units which already disabled
629 if( !tu.is_enabled() )
632 set_run_status disabler( test_unit::RS_DISABLED );
633 traverse_test_tree( tu.p_id, disabler, true );
636 // 50. Make sure parents of enabled test units are also enabled
637 finalize_run_status( master_tu_id );
640 //////////////////////////////////////////////////////////////////
642 typedef unit_test_monitor_t::error_level execution_result;
644 // Random generator using the std::rand function (seeded prior to the call)
645 struct random_generator_helper {
646 size_t operator()(size_t i) const {
647 return std::rand() % i;
651 // Executes the test tree with the root at specified test unit
652 execution_result execute_test_tree( test_unit_id tu_id,
653 unsigned timeout = 0,
654 random_generator_helper const * const p_random_generator = 0)
656 test_unit const& tu = framework::get( tu_id, TUT_ANY );
658 execution_result result = unit_test_monitor_t::test_ok;
660 if( !tu.is_enabled() )
663 // 10. Check preconditions, including zero time left for execution and
664 // successful execution of all dependencies
665 if( timeout == TIMEOUT_EXCEEDED ) {
666 // notify all observers about skipped test unit
667 BOOST_TEST_FOREACH( test_observer*, to, m_observers )
668 to->test_unit_skipped( tu, "timeout for the test unit is exceeded" );
670 return unit_test_monitor_t::os_timeout;
672 else if( timeout == 0 || timeout > tu.p_timeout ) // deduce timeout for this test unit
673 timeout = tu.p_timeout;
675 test_tools::assertion_result const precondition_res = tu.check_preconditions();
676 if( !precondition_res ) {
677 // notify all observers about skipped test unit
678 BOOST_TEST_FOREACH( test_observer*, to, m_observers )
679 to->test_unit_skipped( tu, precondition_res.message() );
681 return unit_test_monitor_t::precondition_failure;
684 // 20. Notify all observers about the start of the test unit
685 BOOST_TEST_FOREACH( test_observer*, to, m_observers )
686 to->test_unit_start( tu );
688 // 30. Execute setup fixtures if any; any failure here leads to test unit abortion
689 BOOST_TEST_FOREACH( test_unit_fixture_ptr, F, tu.p_fixtures.get() ) {
690 ut_detail::test_unit_id_restore restore_current_test_unit(m_curr_test_unit, tu.p_id);
691 result = unit_test_monitor.execute_and_translate( boost::bind( &test_unit_fixture::setup, F ) );
692 if( result != unit_test_monitor_t::test_ok )
694 test_results const& test_rslt = unit_test::results_collector.results( m_curr_test_unit );
695 if( test_rslt.aborted() ) {
696 result = unit_test_monitor_t::precondition_failure;
701 // This is the time we are going to spend executing the test unit
702 unsigned long elapsed = 0;
704 if( result == unit_test_monitor_t::test_ok ) {
705 // 40. We are going to time the execution
706 boost::timer tu_timer;
708 if( tu.p_type == TUT_SUITE ) {
709 test_suite const& ts = static_cast<test_suite const&>( tu );
711 if( runtime_config::get<unsigned>( runtime_config::btrt_random_seed ) == 0 ) {
712 typedef std::pair<counter_t,test_unit_id> value_type;
714 BOOST_TEST_FOREACH( value_type, chld, ts.m_ranked_children ) {
715 unsigned chld_timeout = child_timeout( timeout, tu_timer.elapsed() );
717 result = (std::min)( result, execute_test_tree( chld.second, chld_timeout ) );
719 if( unit_test_monitor.is_critical_error( result ) )
724 // Go through ranges of chldren with the same dependency rank and shuffle them
725 // independently. Execute each subtree in this order
726 test_unit_id_list children_with_the_same_rank;
728 typedef test_suite::children_per_rank::const_iterator it_type;
729 it_type it = ts.m_ranked_children.begin();
730 while( it != ts.m_ranked_children.end() ) {
731 children_with_the_same_rank.clear();
733 std::pair<it_type,it_type> range = ts.m_ranked_children.equal_range( it->first );
735 while( it != range.second ) {
736 children_with_the_same_rank.push_back( it->second );
740 const random_generator_helper& rand_gen = p_random_generator ? *p_random_generator : random_generator_helper();
742 #ifdef BOOST_NO_CXX98_RANDOM_SHUFFLE
743 impl::random_shuffle( children_with_the_same_rank.begin(), children_with_the_same_rank.end(), rand_gen );
745 std::random_shuffle( children_with_the_same_rank.begin(), children_with_the_same_rank.end(), rand_gen );
748 BOOST_TEST_FOREACH( test_unit_id, chld, children_with_the_same_rank ) {
749 unsigned chld_timeout = child_timeout( timeout, tu_timer.elapsed() );
751 result = (std::min)( result, execute_test_tree( chld, chld_timeout, &rand_gen ) );
753 if( unit_test_monitor.is_critical_error( result ) )
759 elapsed = static_cast<unsigned long>( tu_timer.elapsed() * 1e6 );
762 test_case const& tc = static_cast<test_case const&>( tu );
767 // setup current test case
768 ut_detail::test_unit_id_restore restore_current_test_unit(m_curr_test_unit, tc.p_id);
770 // execute the test case body
771 result = unit_test_monitor.execute_and_translate( tc.p_test_func, timeout );
772 elapsed = static_cast<unsigned long>( tu_timer.elapsed() * 1e6 );
774 // cleanup leftover context
777 // restore state (scope exit) and abort if necessary
781 // if run error is critical skip teardown, who knows what the state of the program at this point
782 if( !unit_test_monitor.is_critical_error( result ) ) {
783 // execute teardown fixtures if any in reverse order
784 BOOST_TEST_REVERSE_FOREACH( test_unit_fixture_ptr, F, tu.p_fixtures.get() ) {
785 ut_detail::test_unit_id_restore restore_current_test_unit(m_curr_test_unit, tu.p_id);
786 result = (std::min)( result, unit_test_monitor.execute_and_translate( boost::bind( &test_unit_fixture::teardown, F ), 0 ) );
788 if( unit_test_monitor.is_critical_error( result ) )
793 // notify all observers about abortion
794 if( unit_test_monitor.is_critical_error( result ) ) {
795 BOOST_TEST_FOREACH( test_observer*, to, m_observers )
799 // notify all observers about completion
800 BOOST_TEST_REVERSE_FOREACH( test_observer*, to, m_observers )
801 to->test_unit_finish( tu, elapsed );
806 //////////////////////////////////////////////////////////////////
808 unsigned child_timeout( unsigned tu_timeout, double elapsed )
810 if( tu_timeout == 0U )
813 unsigned elpsed_sec = static_cast<unsigned>(elapsed); // rounding to number of whole seconds
815 return tu_timeout > elpsed_sec ? tu_timeout - elpsed_sec : TIMEOUT_EXCEEDED;
818 struct priority_order {
819 bool operator()( test_observer* lhs, test_observer* rhs ) const
821 return (lhs->priority() < rhs->priority()) || ((lhs->priority() == rhs->priority()) && (lhs < rhs));
826 typedef std::map<test_unit_id,test_unit*> test_unit_store;
827 typedef std::set<test_observer*,priority_order> observer_store;
828 struct context_frame {
829 context_frame( std::string const& d, int id, bool sticky )
832 , is_sticky( sticky )
839 typedef std::vector<context_frame> context_data;
841 master_test_suite_t* m_master_test_suite;
842 std::vector<test_suite*> m_auto_test_suites;
844 test_unit_id m_curr_test_unit;
845 test_unit_store m_test_units;
847 test_unit_id m_next_test_case_id;
848 test_unit_id m_next_test_suite_id;
850 bool m_test_in_progress;
852 observer_store m_observers;
853 context_data m_context;
856 std::set<test_unit_fixture*> m_global_fixtures;
858 boost::execution_monitor m_aux_em;
860 std::map<output_format, runtime_config::stream_holder> m_log_sinks;
861 runtime_config::stream_holder m_report_sink;
864 //____________________________________________________________________________//
869 #if defined(__CYGWIN__)
870 framework::state& s_frk_state() { static framework::state* the_inst = 0; if(!the_inst) the_inst = new framework::state; return *the_inst; }
872 framework::state& s_frk_state() { static framework::state the_inst; return the_inst; }
878 setup_for_execution( test_unit const& tu )
880 s_frk_state().deduce_run_status( tu.p_id );
883 struct sum_to_first_only {
884 sum_to_first_only() : is_first(true) {}
885 template <class T, class U>
886 T operator()(T const& l_, U const& r_) {
889 return l_ + r_.first;
891 return l_ + ", " + r_.first;
903 #ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
904 bool has_combined_logger = runtime_config::has( runtime_config::btrt_combined_logger )
905 && !runtime_config::get< std::vector<std::string> >( runtime_config::btrt_combined_logger ).empty();
907 bool has_combined_logger = false;
910 if( !has_combined_logger ) {
911 unit_test_log.set_threshold_level( runtime_config::get<log_level>( runtime_config::btrt_log_level ) );
912 const output_format format = runtime_config::get<output_format>( runtime_config::btrt_log_format );
913 unit_test_log.set_format( format );
915 runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
916 if( runtime_config::has( runtime_config::btrt_log_sink ) )
917 stream_logger.setup( runtime_config::get<std::string>( runtime_config::btrt_log_sink ) );
918 unit_test_log.set_stream( stream_logger.ref() );
923 const std::vector<std::string>& v_output_format = runtime_config::get< std::vector<std::string> >( runtime_config::btrt_combined_logger ) ;
925 static const std::pair<const char*, log_level> all_log_levels[] = {
926 std::make_pair( "all" , log_successful_tests ),
927 std::make_pair( "success" , log_successful_tests ),
928 std::make_pair( "test_suite" , log_test_units ),
929 std::make_pair( "unit_scope" , log_test_units ),
930 std::make_pair( "message" , log_messages ),
931 std::make_pair( "warning" , log_warnings ),
932 std::make_pair( "error" , log_all_errors ),
933 std::make_pair( "cpp_exception" , log_cpp_exception_errors ),
934 std::make_pair( "system_error" , log_system_errors ),
935 std::make_pair( "fatal_error" , log_fatal_errors ),
936 std::make_pair( "nothing" , log_nothing )
939 static const std::pair<const char*, output_format> all_formats[] = {
940 std::make_pair( "HRF" , OF_CLF ),
941 std::make_pair( "CLF" , OF_CLF ),
942 std::make_pair( "XML" , OF_XML ),
943 std::make_pair( "JUNIT", OF_JUNIT )
947 bool is_first = true;
949 BOOST_TEST_FOREACH( const_string, current_multi_config, v_output_format ) {
951 #ifdef BOOST_TEST_SUPPORT_TOKEN_ITERATOR
953 // ':' may be used for file names: C:/tmp/mylogsink.xml
954 // we merge the tokens that start with / or \ with the previous one.
955 std::vector<std::string> v_processed_tokens;
958 utils::string_token_iterator current_config( current_multi_config, (utils::dropped_delimeters = ":",
959 utils::kept_delimeters = utils::dt_none) );
961 for( ; current_config != utils::string_token_iterator() ; ++current_config) {
962 std::string str_copy(current_config->begin(), current_config->end());
963 if( ( str_copy[0] == '\\' || str_copy[0] == '/' )
964 && v_processed_tokens.size() > 0) {
965 v_processed_tokens.back() += ":" + str_copy; // ':' has been eaten up
968 v_processed_tokens.push_back(str_copy);
973 BOOST_TEST_FOREACH( std::string const&, current_config, v_processed_tokens ) {
975 utils::string_token_iterator current_format_specs( current_config, (utils::keep_empty_tokens,
976 utils::dropped_delimeters = ",",
977 utils::kept_delimeters = utils::dt_none) );
979 output_format format = OF_INVALID ; // default
980 if( current_format_specs != utils::string_token_iterator() &&
981 current_format_specs->size() ) {
983 for(size_t elem=0; elem < sizeof(all_formats)/sizeof(all_formats[0]); elem++) {
984 if(const_string(all_formats[elem].first) == *current_format_specs) {
985 format = all_formats[elem].second;
991 BOOST_TEST_I_ASSRT( format != OF_INVALID,
992 boost::runtime::access_to_missing_argument()
993 << "Unable to determine the logger type from '"
995 << "'. Possible choices are: "
996 << std::accumulate(all_formats,
997 all_formats + sizeof(all_formats)/sizeof(all_formats[0]),
1002 // activates this format
1004 unit_test_log.set_format( format );
1007 unit_test_log.add_format( format );
1011 unit_test_log_formatter * const formatter = unit_test_log.get_formatter(format);
1012 BOOST_TEST_SETUP_ASSERT( formatter, "Logger setup error" );
1014 log_level formatter_log_level = invalid_log_level;
1015 ++current_format_specs ;
1016 if( !current_format_specs->size() ) {
1017 formatter_log_level = formatter->get_log_level(); // default log level given by the formatter
1019 else if( current_format_specs != utils::string_token_iterator() ) {
1021 for(size_t elem=0; elem < sizeof(all_log_levels)/sizeof(all_log_levels[0]); elem++) {
1022 if(const_string(all_log_levels[elem].first) == *current_format_specs) {
1023 formatter_log_level = all_log_levels[elem].second;
1030 BOOST_TEST_I_ASSRT( formatter_log_level != invalid_log_level,
1031 boost::runtime::access_to_missing_argument()
1032 << "Unable to determine the log level from '"
1034 << "'. Possible choices are: "
1035 << std::accumulate(all_log_levels,
1036 all_log_levels + sizeof(all_log_levels)/sizeof(all_log_levels[0]),
1038 sum_to_first_only())
1041 unit_test_log.set_threshold_level( format, formatter_log_level );
1043 runtime_config::stream_holder& stream_logger = s_frk_state().m_log_sinks[format];
1044 if( ++current_format_specs != utils::string_token_iterator() &&
1045 current_format_specs->size() ) {
1046 stream_logger.setup( *current_format_specs );
1049 stream_logger.setup( formatter->get_default_stream_description() );
1051 unit_test_log.set_stream( format, stream_logger.ref() );
1054 } // for each logger
1056 } // if/else new logger API
1057 } // BOOST_TEST_I_TRY
1058 BOOST_TEST_I_CATCH( boost::runtime::init_error, ex ) {
1059 BOOST_TEST_SETUP_ASSERT( false, ex.msg );
1061 BOOST_TEST_I_CATCH( boost::runtime::input_error, ex ) {
1062 std::cerr << ex.msg << "\n\n";
1064 BOOST_TEST_I_THROW( framework::nothing_to_test( boost::exit_exception_failure ) );
1070 //____________________________________________________________________________//
1074 //____________________________________________________________________________//
1076 // ************************************************************************** //
1077 // ************** framework::init ************** //
1078 // ************************************************************************** //
1081 init( init_unit_test_func init_func, int argc, char* argv[] )
1083 using namespace impl;
1085 // 10. Set up runtime parameters
1086 runtime_config::init( argc, argv );
1088 // 20. Set the desired log level, format and sink
1089 impl::setup_loggers();
1091 // 30. Set the desired report level, format and sink
1092 results_reporter::set_level( runtime_config::get<report_level>( runtime_config::btrt_report_level ) );
1093 results_reporter::set_format( runtime_config::get<output_format>( runtime_config::btrt_report_format ) );
1095 if( runtime_config::has( runtime_config::btrt_report_sink ) )
1096 s_frk_state().m_report_sink.setup( runtime_config::get<std::string>( runtime_config::btrt_report_sink ) );
1097 results_reporter::set_stream( s_frk_state().m_report_sink.ref() );
1099 // 40. Register default test observers
1100 register_observer( results_collector );
1101 register_observer( unit_test_log );
1102 register_observer( framework_init_observer );
1104 if( runtime_config::get<bool>( runtime_config::btrt_show_progress ) ) {
1105 progress_monitor.set_stream( std::cout ); // defaults to stdout
1106 register_observer( progress_monitor );
1109 // 50. Set up memory leak detection
1110 unsigned long detect_mem_leak = runtime_config::get<unsigned long>( runtime_config::btrt_detect_mem_leaks );
1111 if( detect_mem_leak > 0 ) {
1112 debug::detect_memory_leaks( true, runtime_config::get<std::string>( runtime_config::btrt_report_mem_leaks ) );
1113 debug::break_memory_alloc( (long)detect_mem_leak );
1116 // 60. Initialize master unit test suite
1117 master_test_suite().argc = argc;
1118 master_test_suite().argv = argv;
1120 // 70. Invoke test module initialization routine
1122 s_frk_state().m_aux_em.vexecute( boost::bind( &impl::invoke_init_func, init_func ) );
1124 BOOST_TEST_I_CATCH( execution_exception, ex ) {
1125 BOOST_TEST_SETUP_ASSERT( false, ex.what() );
1129 //____________________________________________________________________________//
1132 finalize_setup_phase( test_unit_id master_tu_id )
1134 if( master_tu_id == INV_TEST_UNIT_ID )
1135 master_tu_id = master_test_suite().p_id;
1137 // 10. Apply all decorators to the auto test units
1138 class apply_decorators : public test_tree_visitor {
1140 // test_tree_visitor interface
1141 virtual bool visit( test_unit const& tu )
1143 BOOST_TEST_FOREACH( decorator::base_ptr, d, tu.p_decorators.get() )
1144 d->apply( const_cast<test_unit&>(tu) );
1149 traverse_test_tree( master_tu_id, ad, true );
1151 // 20. Finalize setup phase
1152 impl::order_info_per_tu tuoi;
1153 impl::s_frk_state().deduce_siblings_order( master_tu_id, master_tu_id, tuoi );
1154 impl::s_frk_state().finalize_default_run_status( master_tu_id, test_unit::RS_INVALID );
1157 // ************************************************************************** //
1158 // ************** test_in_progress ************** //
1159 // ************************************************************************** //
1164 return impl::s_frk_state().m_test_in_progress;
1167 //____________________________________________________________________________//
1169 // ************************************************************************** //
1170 // ************** framework::shutdown ************** //
1171 // ************************************************************************** //
1176 // eliminating some fake memory leak reports. See for more details:
1177 // http://connect.microsoft.com/VisualStudio/feedback/details/106937/memory-leaks-reported-by-debug-crt-inside-typeinfo-name
1179 # if BOOST_WORKAROUND(BOOST_MSVC, <= 1600 ) && !defined(_DLL) && defined(_DEBUG)
1180 # if BOOST_WORKAROUND(BOOST_MSVC, < 1600 )
1182 #define _MemPtr memPtr
1184 __type_info_node* pNode = __type_info_root_node._Next;
1185 __type_info_node* tmpNode = &__type_info_root_node;
1187 for( ; pNode!=NULL; pNode = tmpNode ) {
1188 tmpNode = pNode->_Next;
1189 delete pNode->_MemPtr;
1192 # if BOOST_WORKAROUND(BOOST_MSVC, < 1600 )
1199 //____________________________________________________________________________//
1201 // ************************************************************************** //
1202 // ************** register_test_unit ************** //
1203 // ************************************************************************** //
1206 register_test_unit( test_case* tc )
1208 BOOST_TEST_SETUP_ASSERT( tc->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test case already registered" ) );
1210 test_unit_id new_id = impl::s_frk_state().m_next_test_case_id;
1212 BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_CASE_ID, BOOST_TEST_L( "too many test cases" ) );
1214 typedef state::test_unit_store::value_type map_value_type;
1216 impl::s_frk_state().m_test_units.insert( map_value_type( new_id, tc ) );
1217 impl::s_frk_state().m_next_test_case_id++;
1219 impl::s_frk_state().set_tu_id( *tc, new_id );
1222 //____________________________________________________________________________//
1224 // ************************************************************************** //
1225 // ************** register_test_unit ************** //
1226 // ************************************************************************** //
1229 register_test_unit( test_suite* ts )
1231 BOOST_TEST_SETUP_ASSERT( ts->p_id == INV_TEST_UNIT_ID, BOOST_TEST_L( "test suite already registered" ) );
1233 test_unit_id new_id = impl::s_frk_state().m_next_test_suite_id;
1235 BOOST_TEST_SETUP_ASSERT( new_id != MAX_TEST_SUITE_ID, BOOST_TEST_L( "too many test suites" ) );
1237 typedef state::test_unit_store::value_type map_value_type;
1239 impl::s_frk_state().m_test_units.insert( map_value_type( new_id, ts ) );
1240 impl::s_frk_state().m_next_test_suite_id++;
1242 impl::s_frk_state().set_tu_id( *ts, new_id );
1245 //____________________________________________________________________________//
1247 // ************************************************************************** //
1248 // ************** deregister_test_unit ************** //
1249 // ************************************************************************** //
1252 deregister_test_unit( test_unit* tu )
1254 impl::s_frk_state().m_test_units.erase( tu->p_id );
1257 //____________________________________________________________________________//
1259 // ************************************************************************** //
1260 // ************** clear ************** //
1261 // ************************************************************************** //
1266 impl::s_frk_state().clear();
1269 //____________________________________________________________________________//
1271 // ************************************************************************** //
1272 // ************** register_observer ************** //
1273 // ************************************************************************** //
1276 register_observer( test_observer& to )
1278 impl::s_frk_state().m_observers.insert( &to );
1281 //____________________________________________________________________________//
1283 // ************************************************************************** //
1284 // ************** deregister_observer ************** //
1285 // ************************************************************************** //
1288 deregister_observer( test_observer& to )
1290 impl::s_frk_state().m_observers.erase( &to );
1293 //____________________________________________________________________________//
1295 // ************************************************************************** //
1296 // ************** register_global_fixture ************** //
1297 // ************************************************************************** //
1300 register_global_fixture( test_unit_fixture& tuf )
1302 impl::s_frk_state().m_global_fixtures.insert( &tuf );
1305 //____________________________________________________________________________//
1307 // ************************************************************************** //
1308 // ************** deregister_global_fixture ************** //
1309 // ************************************************************************** //
1312 deregister_global_fixture( test_unit_fixture &tuf )
1314 impl::s_frk_state().m_global_fixtures.erase( &tuf );
1317 //____________________________________________________________________________//
1319 // ************************************************************************** //
1320 // ************** add_context ************** //
1321 // ************************************************************************** //
1324 add_context( ::boost::unit_test::lazy_ostream const& context_descr, bool sticky )
1326 std::stringstream buffer;
1327 context_descr( buffer );
1328 int res_idx = impl::s_frk_state().m_context_idx++;
1330 impl::s_frk_state().m_context.push_back( state::context_frame( buffer.str(), res_idx, sticky ) );
1335 //____________________________________________________________________________//
1337 // ************************************************************************** //
1338 // ************** clear_context ************** //
1339 // ************************************************************************** //
1341 struct frame_with_id {
1342 explicit frame_with_id( int id ) : m_id( id ) {}
1344 bool operator()( state::context_frame const& f )
1346 return f.frame_id == m_id;
1351 //____________________________________________________________________________//
1354 clear_context( int frame_id )
1356 if( frame_id == -1 ) { // clear all non sticky frames
1357 for( int i=static_cast<int>(impl::s_frk_state().m_context.size())-1; i>=0; i-- )
1358 if( !impl::s_frk_state().m_context[i].is_sticky )
1359 impl::s_frk_state().m_context.erase( impl::s_frk_state().m_context.begin()+i );
1362 else { // clear specific frame
1363 state::context_data::iterator it =
1364 std::find_if( impl::s_frk_state().m_context.begin(), impl::s_frk_state().m_context.end(), frame_with_id( frame_id ) );
1366 if( it != impl::s_frk_state().m_context.end() ) // really an internal error if this is not true
1367 impl::s_frk_state().m_context.erase( it );
1371 //____________________________________________________________________________//
1373 // ************************************************************************** //
1374 // ************** get_context ************** //
1375 // ************************************************************************** //
1380 return context_generator();
1383 //____________________________________________________________________________//
1385 // ************************************************************************** //
1386 // ************** context_generator ************** //
1387 // ************************************************************************** //
1390 context_generator::is_empty() const
1392 return impl::s_frk_state().m_context.empty();
1395 //____________________________________________________________________________//
1398 context_generator::next() const
1400 return m_curr_frame < impl::s_frk_state().m_context.size() ? impl::s_frk_state().m_context[m_curr_frame++].descr : const_string();
1403 //____________________________________________________________________________//
1405 // ************************************************************************** //
1406 // ************** master_test_suite ************** //
1407 // ************************************************************************** //
1409 master_test_suite_t&
1412 if( !impl::s_frk_state().m_master_test_suite )
1413 impl::s_frk_state().m_master_test_suite = new master_test_suite_t;
1415 return *impl::s_frk_state().m_master_test_suite;
1418 //____________________________________________________________________________//
1420 // ************************************************************************** //
1421 // ************** current_auto_test_suite ************** //
1422 // ************************************************************************** //
1425 current_auto_test_suite( test_suite* ts, bool push_or_pop )
1427 if( impl::s_frk_state().m_auto_test_suites.empty() )
1428 impl::s_frk_state().m_auto_test_suites.push_back( &framework::master_test_suite() );
1431 impl::s_frk_state().m_auto_test_suites.pop_back();
1433 impl::s_frk_state().m_auto_test_suites.push_back( ts );
1435 return *impl::s_frk_state().m_auto_test_suites.back();
1438 //____________________________________________________________________________//
1440 // ************************************************************************** //
1441 // ************** current_test_case ************** //
1442 // ************************************************************************** //
1447 return get<test_case>( impl::s_frk_state().m_curr_test_unit );
1454 return *impl::s_frk_state().m_test_units[impl::s_frk_state().m_curr_test_unit];
1457 //____________________________________________________________________________//
1460 current_test_case_id()
1462 return impl::s_frk_state().m_curr_test_unit;
1465 //____________________________________________________________________________//
1467 // ************************************************************************** //
1468 // ************** framework::get ************** //
1469 // ************************************************************************** //
1472 get( test_unit_id id, test_unit_type t )
1474 test_unit* res = impl::s_frk_state().m_test_units[id];
1476 BOOST_TEST_I_ASSRT( (res->p_type & t) != 0, internal_error( "Invalid test unit type" ) );
1481 //____________________________________________________________________________//
1483 // ************************************************************************** //
1484 // ************** framework::run ************** //
1485 // ************************************************************************** //
1487 template <class Cont>
1488 struct swap_on_delete {
1489 swap_on_delete(Cont& c1, Cont& c2) : m_c1(c1), m_c2(c2){}
1499 run( test_unit_id id, bool continue_test )
1501 if( id == INV_TEST_UNIT_ID )
1502 id = master_test_suite().p_id;
1504 // Figure out run status for execution phase
1505 impl::s_frk_state().deduce_run_status( id );
1507 test_case_counter tcc;
1508 traverse_test_tree( id, tcc );
1510 BOOST_TEST_SETUP_ASSERT( tcc.p_count != 0 , runtime_config::get<std::vector<std::string> >( runtime_config::btrt_run_filters ).empty()
1511 ? BOOST_TEST_L( "test tree is empty" )
1512 : BOOST_TEST_L( "no test cases matching filter or all test cases were disabled" ) );
1514 bool was_in_progress = framework::test_in_progress();
1515 bool call_start_finish = !continue_test || !was_in_progress;
1516 bool init_ok = true;
1517 const_string setup_error;
1519 if( call_start_finish ) {
1520 // indicates the framework that no test is in progress now if observers need to be notified
1521 impl::s_frk_state().m_test_in_progress = false;
1522 // unit_test::framework_init_observer will get cleared first
1523 BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers ) {
1525 ut_detail::test_unit_id_restore restore_current_test_unit(impl::s_frk_state().m_curr_test_unit, id);
1526 unit_test_monitor_t::error_level result = unit_test_monitor.execute_and_translate( boost::bind( &test_observer::test_start, to, tcc.p_count ) );
1528 if( result != unit_test_monitor_t::test_ok ) {
1532 if( unit_test::framework_init_observer.has_failed() ) {
1538 BOOST_TEST_I_CATCH( execution_exception, ex ) {
1540 // log only the first error
1542 setup_error = ex.what();
1544 // break; // we should continue otherwise loggers may have improper structure (XML start missing for instance)
1551 // attaching the global fixtures to the main entry point
1552 test_unit& entry_test_unit = framework::get( id, TUT_ANY );
1553 std::vector<test_unit_fixture_ptr> v_saved_fixture(entry_test_unit.p_fixtures.value.begin(),
1554 entry_test_unit.p_fixtures.value.end());
1556 BOOST_TEST_FOREACH( test_unit_fixture*, tuf, impl::s_frk_state().m_global_fixtures ) {
1557 entry_test_unit.p_fixtures.value.insert( entry_test_unit.p_fixtures.value.begin(),
1558 test_unit_fixture_ptr(new impl::global_fixture_handle(tuf)) );
1561 swap_on_delete< std::vector<test_unit_fixture_ptr> > raii_fixture(v_saved_fixture, entry_test_unit.p_fixtures.value);
1563 // now work in progress
1564 impl::s_frk_state().m_test_in_progress = true;
1565 unsigned seed = runtime_config::get<unsigned>( runtime_config::btrt_random_seed );
1570 seed = static_cast<unsigned>( std::rand() ^ std::time( 0 ) ); // better init using std::rand() ^ ...
1572 BOOST_TEST_FRAMEWORK_MESSAGE( "Test cases order is shuffled using seed: " << seed );
1576 // executing the test tree
1577 impl::s_frk_state().execute_test_tree( id );
1579 // removing previously added global fixtures: dtor raii_fixture
1582 impl::s_frk_state().m_test_in_progress = false;
1584 unit_test::framework_init_observer.clear();
1585 if( call_start_finish ) {
1586 // indicates the framework that no test is in progress anymore if observers need to be notified
1587 // and this is a teardown, so assertions should not raise any exception otherwise an exception
1588 // might be raised in a dtor of a global fixture
1589 impl::s_frk_state().m_test_in_progress = false;
1590 BOOST_TEST_REVERSE_FOREACH( test_observer*, to, impl::s_frk_state().m_observers ) {
1591 ut_detail::test_unit_id_restore restore_current_test_unit(impl::s_frk_state().m_curr_test_unit, id);
1596 impl::s_frk_state().m_test_in_progress = was_in_progress;
1598 // propagates the init/teardown error if any
1599 BOOST_TEST_SETUP_ASSERT( init_ok && !unit_test::framework_init_observer.has_failed(), setup_error );
1602 //____________________________________________________________________________//
1605 run( test_unit const* tu, bool continue_test )
1607 run( tu->p_id, continue_test );
1610 //____________________________________________________________________________//
1612 // ************************************************************************** //
1613 // ************** assertion_result ************** //
1614 // ************************************************************************** //
1617 assertion_result( unit_test::assertion_result ar )
1619 BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers )
1620 to->assertion_result( ar );
1623 //____________________________________________________________________________//
1625 // ************************************************************************** //
1626 // ************** exception_caught ************** //
1627 // ************************************************************************** //
1630 exception_caught( execution_exception const& ex )
1632 BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers )
1633 to->exception_caught( ex );
1636 //____________________________________________________________________________//
1638 // ************************************************************************** //
1639 // ************** test_unit_aborted ************** //
1640 // ************************************************************************** //
1643 test_unit_aborted( test_unit const& tu )
1645 BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers )
1646 to->test_unit_aborted( tu );
1649 // ************************************************************************** //
1650 // ************** test_aborted ************** //
1651 // ************************************************************************** //
1656 BOOST_TEST_FOREACH( test_observer*, to, impl::s_frk_state().m_observers )
1657 to->test_aborted( );
1661 //____________________________________________________________________________//
1663 } // namespace framework
1664 } // namespace unit_test
1665 } // namespace boost
1667 #include <boost/test/detail/enable_warnings.hpp>
1669 #endif // BOOST_TEST_FRAMEWORK_IPP_021005GER