1
// (C) Copyright Gennadiy Rozental 2005-2008.
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: 57992 $
12
// Description : implements XML Log formatter
13
// ***************************************************************************
15
#ifndef BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
16
#define BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
19
#include <boost/test/output/xml_log_formatter.hpp>
20
#include <boost/test/unit_test_suite_impl.hpp>
21
#include <boost/test/framework.hpp>
22
#include <boost/test/utils/basic_cstring/io.hpp>
24
#include <boost/test/utils/xml_printer.hpp>
27
#include <boost/version.hpp>
32
#include <boost/test/detail/suppress_warnings.hpp>
34
//____________________________________________________________________________//
42
static const_string tu_type_name( test_unit const& tu )
44
return tu.p_type == tut_case ? "TestCase" : "TestSuite";
47
// ************************************************************************** //
48
// ************** xml_log_formatter ************** //
49
// ************************************************************************** //
52
xml_log_formatter::log_start( std::ostream& ostr, counter_t )
57
//____________________________________________________________________________//
60
xml_log_formatter::log_finish( std::ostream& ostr )
65
//____________________________________________________________________________//
68
xml_log_formatter::log_build_info( std::ostream& ostr )
71
<< " platform" << attr_value() << BOOST_PLATFORM
72
<< " compiler" << attr_value() << BOOST_COMPILER
73
<< " stl" << attr_value() << BOOST_STDLIB
74
<< " boost=\"" << BOOST_VERSION/100000 << "."
75
<< BOOST_VERSION/100 % 1000 << "."
76
<< BOOST_VERSION % 100 << '\"'
80
//____________________________________________________________________________//
83
xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu )
85
ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get() << ">";
88
//____________________________________________________________________________//
91
xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, unsigned long elapsed )
93
if( tu.p_type == tut_case )
94
ostr << "<TestingTime>" << elapsed << "</TestingTime>";
96
ostr << "</" << tu_type_name( tu ) << ">";
99
//____________________________________________________________________________//
102
xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu )
104
ostr << "<" << tu_type_name( tu )
105
<< " name" << attr_value() << tu.p_name.get()
106
<< " skipped" << attr_value() << "yes"
110
//____________________________________________________________________________//
113
xml_log_formatter::log_exception( std::ostream& ostr, log_checkpoint_data const& checkpoint_data, execution_exception const& ex )
115
execution_exception::location const& loc = ex.where();
117
ostr << "<Exception file" << attr_value() << loc.m_file_name
118
<< " line" << attr_value() << loc.m_line_num;
120
if( !loc.m_function.is_empty() )
121
ostr << " function" << attr_value() << loc.m_function;
123
ostr << ">" << cdata() << ex.what();
125
if( !checkpoint_data.m_file_name.is_empty() ) {
126
ostr << "<LastCheckpoint file" << attr_value() << checkpoint_data.m_file_name
127
<< " line" << attr_value() << checkpoint_data.m_line_num
129
<< cdata() << checkpoint_data.m_message
130
<< "</LastCheckpoint>";
133
ostr << "</Exception>";
136
//____________________________________________________________________________//
139
xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& entry_data, log_entry_types let )
141
static literal_string xml_tags[] = { "Info", "Message", "Warning", "Error", "FatalError" };
143
m_curr_tag = xml_tags[let];
144
ostr << '<' << m_curr_tag
145
<< BOOST_TEST_L( " file" ) << attr_value() << entry_data.m_file_name
146
<< BOOST_TEST_L( " line" ) << attr_value() << entry_data.m_line_num
147
<< BOOST_TEST_L( "><![CDATA[" );
150
//____________________________________________________________________________//
153
xml_log_formatter::log_entry_value( std::ostream& ostr, const_string value )
158
//____________________________________________________________________________//
161
xml_log_formatter::log_entry_finish( std::ostream& ostr )
163
ostr << BOOST_TEST_L( "]]></" ) << m_curr_tag << BOOST_TEST_L( ">" );
168
//____________________________________________________________________________//
170
} // namespace output
172
} // namespace unit_test
176
//____________________________________________________________________________//
178
#include <boost/test/detail/enable_warnings.hpp>
180
#endif // BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER