[Boost-bugs] [Boost C++ Libraries] #3978: Failed to completely redirect TestLog to file, bugfix appended

Subject: [Boost-bugs] [Boost C++ Libraries] #3978: Failed to completely redirect TestLog to file, bugfix appended
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-04 14:46:46


#3978: Failed to completely redirect TestLog to file, bugfix appended
-----------------------------+----------------------------------------------
 Reporter: phu@… | Owner: rogeeff
     Type: Bugs | Status: new
Milestone: Boost 1.43.0 | Component: test
  Version: Boost 1.42.0 | Severity: Problem
 Keywords: |
-----------------------------+----------------------------------------------
 Hi

 when using the following suggested global fixture with XML format,
 the final tag </TestLog> gets lost and ends up in cout instead of the
 file.

 I tracked the bug and suggest the following patch, which fixed the
 problem.
 (The problem is, that the global fixture is applied before the logger but
 is removed before the logger is finished.)



 used fixture:

 {{{
 struct TestSuiteConfig {
     TestSuiteConfig()
     : test_log( "testresults.log" )
     {
         boost::unit_test::unit_test_log.set_format( boost::unit_test::XML
 );
         boost::unit_test::unit_test_log.set_stream( test_log );
     }

     ~TestSuiteConfig()
     {
         boost::unit_test::unit_test_log.set_stream( std::cout );
     }

     std::ofstream test_log;
 };

 BOOST_GLOBAL_FIXTURE( TestSuiteConfig );

 }}}

 applied changes (on version 1.40, but 1.42 is still the same):
 {{{
 Index: boost/test/impl/framework.ipp
 ===================================================================
 --- framework.ipp (revision 801)
 +++ framework.ipp (revision 802)
 @@ -445,8 +445,9 @@
      }

      if( call_start_finish ) {
 - BOOST_TEST_FOREACH( test_observer*, to, s_frk_impl().m_observers
 )
 - to->test_finish();
 + for( framework_impl::observer_store::reverse_iterator to =
 s_frk_impl().m_observers.rbegin(); to != s_frk_impl().m_observers.rend();
 ++to)
 + (*to)->test_finish();
      }

      s_frk_impl().m_test_in_progress = was_in_progress;

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3978>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:02 UTC