source: NonGTP/Boost/boost/test/impl/compiler_log_formatter.ipp @ 857

Revision 857, 6.9 KB checked in by igarcia, 19 years ago (diff)
Line 
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.3 $
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.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
34namespace boost {
35
36namespace unit_test {
37
38namespace output {
39
40// ************************************************************************** //
41// **************            compiler_log_formatter            ************** //
42// ************************************************************************** //
43
44void
45compiler_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
54void
55compiler_log_formatter::log_finish( std::ostream& )
56{
57    // do nothing
58}
59
60//____________________________________________________________________________//
61
62void
63compiler_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
75void
76compiler_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
83void
84compiler_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
101void
102compiler_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
109void
110compiler_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_message.empty() ) {
122        output << '\n';
123        print_prefix( output, checkpoint_data.m_file, checkpoint_data.m_line );
124        output << "last checkpoint: " << checkpoint_data.m_message;
125    }
126   
127    output << std::endl;
128}
129
130//____________________________________________________________________________//
131
132void
133compiler_log_formatter::log_entry_start( std::ostream& output, log_entry_data const& entry_data, log_entry_types let )
134{
135    switch( let ) {
136        case BOOST_UTL_ET_INFO:
137            print_prefix( output, entry_data.m_file, entry_data.m_line );
138            output << "info: ";
139            break;
140        case BOOST_UTL_ET_MESSAGE:
141            break;
142        case BOOST_UTL_ET_WARNING:
143            print_prefix( output, entry_data.m_file, entry_data.m_line );
144            output << "warning in \"" << framework::current_test_case().p_name << "\": ";
145            break;
146        case BOOST_UTL_ET_ERROR:
147            print_prefix( output, entry_data.m_file, entry_data.m_line );
148            output << "error in \"" << framework::current_test_case().p_name << "\": ";
149            break;
150        case BOOST_UTL_ET_FATAL_ERROR:
151            print_prefix( output, entry_data.m_file, entry_data.m_line );
152            output << "fatal error in \"" << framework::current_test_case().p_name << "\": ";
153            break;
154    }
155}
156
157//____________________________________________________________________________//
158
159void
160compiler_log_formatter::log_entry_value( std::ostream& output, const_string value )
161{
162    output << value;
163}
164
165//____________________________________________________________________________//
166
167void
168compiler_log_formatter::log_entry_finish( std::ostream& output )
169{
170    output << std::endl;
171}
172
173//____________________________________________________________________________//
174
175void
176compiler_log_formatter::print_prefix( std::ostream& output, const_string file, std::size_t line )
177{
178    output << file << '(' << line << "): ";
179}
180
181//____________________________________________________________________________//
182
183} // namespace ouptut
184
185} // namespace unit_test
186
187} // namespace boost
188
189//____________________________________________________________________________//
190
191#include <boost/test/detail/enable_warnings.hpp>
192
193// ***************************************************************************
194//  Revision History :
195//
196//  $Log: compiler_log_formatter.ipp,v $
197//  Revision 1.3  2005/02/21 10:09:26  rogeeff
198//  exception logging changes so that it produce a string recognizable by compiler as an error
199//
200//  Revision 1.2  2005/02/20 08:27:06  rogeeff
201//  This a major update for Boost.Test framework. See release docs for complete list of fixes/updates
202//
203//  Revision 1.1  2005/02/01 08:59:38  rogeeff
204//  supplied_log_formatters split
205//  change formatters interface to simplify result interface
206//
207// ***************************************************************************
208
209#endif // BOOST_TEST_COMPILER_LOG_FORMATTER_IPP_020105GER
Note: See TracBrowser for help on using the repository browser.