diff options
Diffstat (limited to 'boost/test/impl/xml_log_formatter.ipp')
-rw-r--r-- | boost/test/impl/xml_log_formatter.ipp | 82 |
1 files changed, 63 insertions, 19 deletions
diff --git a/boost/test/impl/xml_log_formatter.ipp b/boost/test/impl/xml_log_formatter.ipp index 6c0127bb57..286cd60005 100644 --- a/boost/test/impl/xml_log_formatter.ipp +++ b/boost/test/impl/xml_log_formatter.ipp @@ -1,6 +1,6 @@ -// (C) Copyright Gennadiy Rozental 2005-2008. +// (C) Copyright Gennadiy Rozental 2005-2014. // Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at +// (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. @@ -9,7 +9,7 @@ // // Version : $Revision$ // -// Description : implements XML Log formatter +// Description : implements OF_XML Log formatter // *************************************************************************** #ifndef BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER @@ -17,10 +17,10 @@ // Boost.Test #include <boost/test/output/xml_log_formatter.hpp> -#include <boost/test/unit_test_suite_impl.hpp> +#include <boost/test/execution_monitor.hpp> #include <boost/test/framework.hpp> +#include <boost/test/tree/test_unit.hpp> #include <boost/test/utils/basic_cstring/io.hpp> - #include <boost/test/utils/xml_printer.hpp> // Boost @@ -34,14 +34,12 @@ //____________________________________________________________________________// namespace boost { - namespace unit_test { - namespace output { static const_string tu_type_name( test_unit const& tu ) { - return tu.p_type == tut_case ? "TestCase" : "TestSuite"; + return tu.p_type == TUT_CASE ? "TestCase" : "TestSuite"; } // ************************************************************************** // @@ -82,7 +80,13 @@ xml_log_formatter::log_build_info( std::ostream& ostr ) void xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu ) { - ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get() << ">"; + ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get(); + + if( !tu.p_file_name.get().empty() ) + ostr << BOOST_TEST_L( " file" ) << attr_value() << tu.p_file_name + << BOOST_TEST_L( " line" ) << attr_value() << tu.p_line_num; + + ostr << ">"; } //____________________________________________________________________________// @@ -90,27 +94,28 @@ xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu ) void xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, unsigned long elapsed ) { - if( tu.p_type == tut_case ) + if( tu.p_type == TUT_CASE ) ostr << "<TestingTime>" << elapsed << "</TestingTime>"; - + ostr << "</" << tu_type_name( tu ) << ">"; } //____________________________________________________________________________// void -xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu ) +xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu, const_string reason ) { ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get() << " skipped" << attr_value() << "yes" + << " reason" << attr_value() << reason << "/>"; } - + //____________________________________________________________________________// void -xml_log_formatter::log_exception( std::ostream& ostr, log_checkpoint_data const& checkpoint_data, execution_exception const& ex ) +xml_log_formatter::log_exception_start( std::ostream& ostr, log_checkpoint_data const& checkpoint_data, execution_exception const& ex ) { execution_exception::location const& loc = ex.where(); @@ -129,7 +134,13 @@ xml_log_formatter::log_exception( std::ostream& ostr, log_checkpoint_data const& << cdata() << checkpoint_data.m_message << "</LastCheckpoint>"; } +} + +//____________________________________________________________________________// +void +xml_log_formatter::log_exception_finish( std::ostream& ostr ) +{ ostr << "</Exception>"; } @@ -145,6 +156,8 @@ xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& en << BOOST_TEST_L( " file" ) << attr_value() << entry_data.m_file_name << BOOST_TEST_L( " line" ) << attr_value() << entry_data.m_line_num << BOOST_TEST_L( "><![CDATA[" ); + + m_value_closed = false; } //____________________________________________________________________________// @@ -152,7 +165,7 @@ xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& en void xml_log_formatter::log_entry_value( std::ostream& ostr, const_string value ) { - ostr << value; + print_escaped_cdata( ostr, value ); } //____________________________________________________________________________// @@ -160,21 +173,52 @@ xml_log_formatter::log_entry_value( std::ostream& ostr, const_string value ) void xml_log_formatter::log_entry_finish( std::ostream& ostr ) { - ostr << BOOST_TEST_L( "]]></" ) << m_curr_tag << BOOST_TEST_L( ">" ); + if( !m_value_closed ) { + ostr << BOOST_TEST_L( "]]>" ); + m_value_closed = true; + } + + ostr << BOOST_TEST_L( "</" ) << m_curr_tag << BOOST_TEST_L( ">" ); m_curr_tag.clear(); } //____________________________________________________________________________// -} // namespace output +void +xml_log_formatter::entry_context_start( std::ostream& ostr, log_level ) +{ + if( !m_value_closed ) { + ostr << BOOST_TEST_L( "]]>" ); + m_value_closed = true; + } -} // namespace unit_test + ostr << BOOST_TEST_L( "<Context>" ); -} // namespace boost +} + +//____________________________________________________________________________// + +void +xml_log_formatter::entry_context_finish( std::ostream& ostr ) +{ + ostr << BOOST_TEST_L( "</Context>" ); +} //____________________________________________________________________________// +void +xml_log_formatter::log_entry_context( std::ostream& ostr, const_string context_descr ) +{ + ostr << BOOST_TEST_L( "<Frame>" ) << cdata() << context_descr << BOOST_TEST_L( "</Frame>" ); +} + +//____________________________________________________________________________// + +} // namespace output +} // namespace unit_test +} // namespace boost + #include <boost/test/detail/enable_warnings.hpp> #endif // BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER |