Opened 13 years ago

Closed 12 years ago

Last modified 7 years ago

#3978 closed Bugs (fixed)

Failed to completely redirect TestLog to file, bugfix appended

Reported by: phu@… Owned by: Gennadiy Rozental
Milestone: Boost 1.59.0 Component: test
Version: Boost 1.42.0 Severity: Problem
Keywords: Cc:

Description

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;

Change History (3)

comment:1 by Steven Watanabe, 12 years ago

Resolution: fixed
Status: newclosed

(In [62805]) Call test_finish/test_unit_finish in the reverse order from test_start/test_unit_start. Fixes #3978

comment:2 by Philipp Huber <phu@…>, 12 years ago

somehow, that fix has not made it into boost 1.43, hope it will be in in 1.44.

comment:3 by Raffi Enficiaud, 7 years ago

Milestone: Boost 1.43.0Boost 1.59.0
Note: See TracTickets for help on using tickets.