]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/test/include/boost/test/impl/xml_log_formatter.ipp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / impl / xml_log_formatter.ipp
CommitLineData
7c673cae
FG
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)
5
6// See http://www.boost.org/libs/test for the library home page.
7//
8// File : $RCSfile$
9//
10// Version : $Revision$
11//
12// Description : implements OF_XML Log formatter
13// ***************************************************************************
14
15#ifndef BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
16#define BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER
17
18// Boost.Test
19#include <boost/test/output/xml_log_formatter.hpp>
20#include <boost/test/execution_monitor.hpp>
21#include <boost/test/framework.hpp>
22#include <boost/test/tree/test_unit.hpp>
23#include <boost/test/utils/basic_cstring/io.hpp>
24#include <boost/test/utils/xml_printer.hpp>
25
26// Boost
27#include <boost/version.hpp>
28
29// STL
30#include <iostream>
31
32#include <boost/test/detail/suppress_warnings.hpp>
33
34//____________________________________________________________________________//
35
36namespace boost {
37namespace unit_test {
38namespace output {
39
40static const_string tu_type_name( test_unit const& tu )
41{
42 return tu.p_type == TUT_CASE ? "TestCase" : "TestSuite";
43}
44
45// ************************************************************************** //
46// ************** xml_log_formatter ************** //
47// ************************************************************************** //
48
49void
50xml_log_formatter::log_start( std::ostream& ostr, counter_t )
51{
52 ostr << "<TestLog>";
53}
54
55//____________________________________________________________________________//
56
57void
58xml_log_formatter::log_finish( std::ostream& ostr )
59{
60 ostr << "</TestLog>";
61}
62
63//____________________________________________________________________________//
64
65void
66xml_log_formatter::log_build_info( std::ostream& ostr )
67{
68 ostr << "<BuildInfo"
69 << " platform" << utils::attr_value() << BOOST_PLATFORM
70 << " compiler" << utils::attr_value() << BOOST_COMPILER
71 << " stl" << utils::attr_value() << BOOST_STDLIB
72 << " boost=\"" << BOOST_VERSION/100000 << "."
73 << BOOST_VERSION/100 % 1000 << "."
74 << BOOST_VERSION % 100 << '\"'
75 << "/>";
76}
77
78//____________________________________________________________________________//
79
80void
81xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu )
82{
83 ostr << "<" << tu_type_name( tu ) << " name" << utils::attr_value() << tu.p_name.get();
84
85 if( !tu.p_file_name.empty() )
86 ostr << BOOST_TEST_L( " file" ) << utils::attr_value() << tu.p_file_name
87 << BOOST_TEST_L( " line" ) << utils::attr_value() << tu.p_line_num;
88
89 ostr << ">";
90}
91
92//____________________________________________________________________________//
93
94void
95xml_log_formatter::test_unit_finish( std::ostream& ostr, test_unit const& tu, unsigned long elapsed )
96{
97 if( tu.p_type == TUT_CASE )
98 ostr << "<TestingTime>" << elapsed << "</TestingTime>";
99
100 ostr << "</" << tu_type_name( tu ) << ">";
101}
102
103//____________________________________________________________________________//
104
105void
106xml_log_formatter::test_unit_skipped( std::ostream& ostr, test_unit const& tu, const_string reason )
107{
108 ostr << "<" << tu_type_name( tu )
109 << " name" << utils::attr_value() << tu.p_name
110 << " skipped" << utils::attr_value() << "yes"
111 << " reason" << utils::attr_value() << reason
112 << "/>";
113}
114
115//____________________________________________________________________________//
116
117void
118xml_log_formatter::log_exception_start( std::ostream& ostr, log_checkpoint_data const& checkpoint_data, execution_exception const& ex )
119{
120 execution_exception::location const& loc = ex.where();
121
122 ostr << "<Exception file" << utils::attr_value() << loc.m_file_name
123 << " line" << utils::attr_value() << loc.m_line_num;
124
125 if( !loc.m_function.is_empty() )
126 ostr << " function" << utils::attr_value() << loc.m_function;
127
128 ostr << ">" << utils::cdata() << ex.what();
129
130 if( !checkpoint_data.m_file_name.is_empty() ) {
131 ostr << "<LastCheckpoint file" << utils::attr_value() << checkpoint_data.m_file_name
132 << " line" << utils::attr_value() << checkpoint_data.m_line_num
133 << ">"
134 << utils::cdata() << checkpoint_data.m_message
135 << "</LastCheckpoint>";
136 }
137}
138
139//____________________________________________________________________________//
140
141void
142xml_log_formatter::log_exception_finish( std::ostream& ostr )
143{
144 ostr << "</Exception>";
145}
146
147//____________________________________________________________________________//
148
149void
150xml_log_formatter::log_entry_start( std::ostream& ostr, log_entry_data const& entry_data, log_entry_types let )
151{
152 static literal_string xml_tags[] = { "Info", "Message", "Warning", "Error", "FatalError" };
153
154 m_curr_tag = xml_tags[let];
155 ostr << '<' << m_curr_tag
156 << BOOST_TEST_L( " file" ) << utils::attr_value() << entry_data.m_file_name
157 << BOOST_TEST_L( " line" ) << utils::attr_value() << entry_data.m_line_num
158 << BOOST_TEST_L( "><![CDATA[" );
159
160 m_value_closed = false;
161}
162
163//____________________________________________________________________________//
164
165void
166xml_log_formatter::log_entry_value( std::ostream& ostr, const_string value )
167{
168 utils::print_escaped_cdata( ostr, value );
169}
170
171//____________________________________________________________________________//
172
173void
174xml_log_formatter::log_entry_finish( std::ostream& ostr )
175{
176 if( !m_value_closed ) {
177 ostr << BOOST_TEST_L( "]]>" );
178 m_value_closed = true;
179 }
180
181 ostr << BOOST_TEST_L( "</" ) << m_curr_tag << BOOST_TEST_L( ">" );
182
183 m_curr_tag.clear();
184}
185
186//____________________________________________________________________________//
187
188void
189xml_log_formatter::entry_context_start( std::ostream& ostr, log_level )
190{
191 if( !m_value_closed ) {
192 ostr << BOOST_TEST_L( "]]>" );
193 m_value_closed = true;
194 }
195
196 ostr << BOOST_TEST_L( "<Context>" );
197}
198
199//____________________________________________________________________________//
200
201void
202xml_log_formatter::entry_context_finish( std::ostream& ostr )
203{
204 ostr << BOOST_TEST_L( "</Context>" );
205}
206
207//____________________________________________________________________________//
208
209void
210xml_log_formatter::log_entry_context( std::ostream& ostr, const_string context_descr )
211{
212 ostr << BOOST_TEST_L( "<Frame>" ) << utils::cdata() << context_descr << BOOST_TEST_L( "</Frame>" );
213}
214
215//____________________________________________________________________________//
216
217} // namespace output
218} // namespace unit_test
219} // namespace boost
220
221#include <boost/test/detail/enable_warnings.hpp>
222
223#endif // BOOST_TEST_XML_LOG_FORMATTER_IPP_020105GER