31
|
1 |
// (C) Copyright Gennadiy Rozental 2005.
|
|
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: compiler_log_formatter.ipp,v $
|
|
9 |
//
|
|
10 |
// Version : $Revision: 1.4 $
|
|
11 |
//
|
|
12 |
// Description : implements compiler like Log formatter
|
|
13 |
// ***************************************************************************
|
|
14 |
|
|
15 |
#ifndef BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
|
|
16 |
#define BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
|
|
17 |
|
|
18 |
// Boost.Test
|
|
19 |
#include <boost/test/output/compiler_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>
|
|
23 |
|
|
24 |
// Boost
|
|
25 |
#include <boost/version.hpp>
|
|
26 |
|
|
27 |
// STL
|
|
28 |
#include <iostream>
|
|
29 |
|
|
30 |
#include <boost/test/detail/suppress_warnings.hpp>
|
|
31 |
|
|
32 |
//____________________________________________________________________________//
|
|
33 |
|
|
34 |
namespace boost {
|
|
35 |
|
|
36 |
namespace unit_test {
|
|
37 |
|
|
38 |
namespace output {
|
|
39 |
|
|
40 |
// ************************************************************************** //
|
|
41 |
// ************** compiler_log_formatter ************** //
|
|
42 |
// ************************************************************************** //
|
|
43 |
|
|
44 |
EXPORT_C void
|
|
45 |
compiler_log_formatter::log_start( std::ostream& output, counter_t test_cases_amount )
|
|
46 |
{
|
|
47 |
if( test_cases_amount > 0 )
|
|
48 |
output << "Running " << test_cases_amount << " test "
|
|
49 |
<< (test_cases_amount > 1 ? "cases" : "case") << "...\n";
|
|
50 |
}
|
|
51 |
|
|
52 |
//____________________________________________________________________________//
|
|
53 |
|
|
54 |
EXPORT_C void
|
|
55 |
compiler_log_formatter::log_finish( std::ostream& )
|
|
56 |
{
|
|
57 |
// do nothing
|
|
58 |
}
|
|
59 |
|
|
60 |
//____________________________________________________________________________//
|
|
61 |
|
|
62 |
EXPORT_C void
|
|
63 |
compiler_log_formatter::log_build_info( std::ostream& output )
|
|
64 |
{
|
|
65 |
output << "Platform: " << BOOST_PLATFORM << '\n'
|
|
66 |
<< "Compiler: " << BOOST_COMPILER << '\n'
|
|
67 |
<< "STL : " << BOOST_STDLIB << '\n'
|
|
68 |
<< "Boost : " << BOOST_VERSION/100000 << "."
|
|
69 |
<< BOOST_VERSION/100 % 1000 << "."
|
|
70 |
<< BOOST_VERSION % 100 << std::endl;
|
|
71 |
}
|
|
72 |
|
|
73 |
//____________________________________________________________________________//
|
|
74 |
|
|
75 |
EXPORT_C void
|
|
76 |
compiler_log_formatter::test_unit_start( std::ostream& output, test_unit const& tu )
|
|
77 |
{
|
|
78 |
output << "Entering test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl;
|
|
79 |
}
|
|
80 |
|
|
81 |
//____________________________________________________________________________//
|
|
82 |
|
|
83 |
EXPORT_C void
|
|
84 |
compiler_log_formatter::test_unit_finish( std::ostream& output, test_unit const& tu, unsigned long elapsed )
|
|
85 |
{
|
|
86 |
output << "Leaving test " << tu.p_type_name << " \"" << tu.p_name << "\"";
|
|
87 |
|
|
88 |
if( elapsed > 0 ) {
|
|
89 |
output << "; testing time: ";
|
|
90 |
if( elapsed % 1000 == 0 )
|
|
91 |
output << elapsed/1000 << "ms";
|
|
92 |
else
|
|
93 |
output << elapsed << "mks";
|
|
94 |
}
|
|
95 |
|
|
96 |
output << std::endl;
|
|
97 |
}
|
|
98 |
|
|
99 |
//____________________________________________________________________________//
|
|
100 |
|
|
101 |
EXPORT_C void
|
|
102 |
compiler_log_formatter::test_unit_skipped( std::ostream& output, test_unit const& tu )
|
|
103 |
{
|
|
104 |
output << "Test " << tu.p_type_name << " \"" << tu.p_name << "\"" << "is skipped" << std::endl;
|
|
105 |
}
|
|
106 |
|
|
107 |
//____________________________________________________________________________//
|
|
108 |
|
|
109 |
EXPORT_C void
|
|
110 |
compiler_log_formatter::log_exception( std::ostream& output, log_checkpoint_data const& checkpoint_data, const_string explanation )
|
|
111 |
{
|
|
112 |
print_prefix( output, BOOST_TEST_L( "unknown location" ), 0 );
|
|
113 |
output << "fatal error in \"" << framework::current_test_case().p_name << "\": ";
|
|
114 |
|
|
115 |
if( !explanation.is_empty() )
|
|
116 |
output << explanation;
|
|
117 |
else
|
|
118 |
output << "uncaught exception, system error or abort requested";
|
|
119 |
|
|
120 |
|
|
121 |
if( !checkpoint_data.m_file_name.is_empty() ) {
|
|
122 |
output << '\n';
|
|
123 |
print_prefix( output, checkpoint_data.m_file_name, checkpoint_data.m_line_num );
|
|
124 |
output << "last checkpoint";
|
|
125 |
if( !checkpoint_data.m_message.empty() )
|
|
126 |
output << ": " << checkpoint_data.m_message;
|
|
127 |
}
|
|
128 |
|
|
129 |
output << std::endl;
|
|
130 |
}
|
|
131 |
|
|
132 |
//____________________________________________________________________________//
|
|
133 |
|
|
134 |
EXPORT_C void
|
|
135 |
compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data const& entry_data, log_entry_types let )
|
|
136 |
{
|
|
137 |
switch( let ) {
|
|
138 |
case BOOST_UTL_ET_INFO:
|
|
139 |
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
|
|
140 |
output << "info: ";
|
|
141 |
break;
|
|
142 |
case BOOST_UTL_ET_MESSAGE:
|
|
143 |
break;
|
|
144 |
case BOOST_UTL_ET_WARNING:
|
|
145 |
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
|
|
146 |
output << "warning in \"" << framework::current_test_case().p_name << "\": ";
|
|
147 |
break;
|
|
148 |
case BOOST_UTL_ET_ERROR:
|
|
149 |
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
|
|
150 |
output << "error in \"" << framework::current_test_case().p_name << "\": ";
|
|
151 |
break;
|
|
152 |
case BOOST_UTL_ET_FATAL_ERROR:
|
|
153 |
print_prefix( output, entry_data.m_file_name, entry_data.m_line_num );
|
|
154 |
output << "fatal error in \"" << framework::current_test_case().p_name << "\": ";
|
|
155 |
break;
|
|
156 |
}
|
|
157 |
}
|
|
158 |
|
|
159 |
//____________________________________________________________________________//
|
|
160 |
|
|
161 |
EXPORT_C void
|
|
162 |
compiler_log_formatter::log_entry_value( std::ostream& output, const_string value )
|
|
163 |
{
|
|
164 |
output << value;
|
|
165 |
}
|
|
166 |
|
|
167 |
//____________________________________________________________________________//
|
|
168 |
|
|
169 |
EXPORT_C void
|
|
170 |
compiler_log_formatter::log_entry_finish( std::ostream& output )
|
|
171 |
{
|
|
172 |
output << std::endl;
|
|
173 |
}
|
|
174 |
|
|
175 |
//____________________________________________________________________________//
|
|
176 |
|
|
177 |
EXPORT_C void
|
|
178 |
compiler_log_formatter::print_prefix( std::ostream& output, const_string file, std::size_t line )
|
|
179 |
{
|
|
180 |
output << file << '(' << line << "): ";
|
|
181 |
}
|
|
182 |
|
|
183 |
//____________________________________________________________________________//
|
|
184 |
|
|
185 |
} // namespace ouptut
|
|
186 |
|
|
187 |
} // namespace unit_test
|
|
188 |
|
|
189 |
} // namespace boost
|
|
190 |
|
|
191 |
//____________________________________________________________________________//
|
|
192 |
|
|
193 |
#include <boost/test/detail/enable_warnings.hpp>
|
|
194 |
|
|
195 |
// ***************************************************************************
|
|
196 |
// Revision History :
|
|
197 |
//
|
|
198 |
// $Log: compiler_log_formatter.ipp,v $
|
|
199 |
// Revision 1.4 2005/12/14 05:26:32 rogeeff
|
|
200 |
// report aborted test units
|
|
201 |
//
|
|
202 |
// Revision 1.3 2005/02/21 10:09:26 rogeeff
|
|
203 |
// exception logging changes so that it produce a string recognizable by compiler as an error
|
|
204 |
//
|
|
205 |
// Revision 1.2 2005/02/20 08:27:06 rogeeff
|
|
206 |
// This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
|
|
207 |
//
|
|
208 |
// Revision 1.1 2005/02/01 08:59:38 rogeeff
|
|
209 |
// supplied_log_formatters split
|
|
210 |
// change formatters interface to simplify result interface
|
|
211 |
//
|
|
212 |
// ***************************************************************************
|
|
213 |
|
|
214 |
#endif // BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
|