]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/test/include/boost/test/output/junit_log_formatter.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / test / include / boost / test / output / junit_log_formatter.hpp
CommitLineData
7c673cae
FG
1// (C) Copyright 2016 Raffi Enficiaud.
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
9///@brief Contains the definition of the Junit log formatter (OF_JUNIT)
10// ***************************************************************************
11
12#ifndef BOOST_TEST_JUNIT_LOG_FORMATTER__
13#define BOOST_TEST_JUNIT_LOG_FORMATTER__
14
15// Boost.Test
16#include <boost/test/detail/global_typedef.hpp>
17#include <boost/test/unit_test_log_formatter.hpp>
18#include <boost/test/tree/test_unit.hpp>
19
20//#include <boost/test/results_collector.hpp>
21
22// STL
23#include <cstddef> // std::size_t
24#include <map>
25#include <list>
26
27#include <boost/test/detail/suppress_warnings.hpp>
28
29//____________________________________________________________________________//
30
31namespace boost {
32namespace unit_test {
33namespace output {
34
35
36 namespace junit_impl {
37
38 // helper for the JUnit logger
39 struct junit_log_helper
40 {
41 struct assertion_entry {
42
43 enum log_entry_t {
44 log_entry_info,
45 log_entry_error,
46 log_entry_failure
47 };
48
49 assertion_entry() : sealed(false)
50 {}
51
52 std::string logentry_message;
53 std::string logentry_type; // the one that will get expanded in the final junit (failure, error)
54 std::string output; // additional information/message generated by the assertion
55
56 log_entry_t log_entry; // the type associated to the assertion (or error)
57
58 bool sealed; // indicates if the entry can accept additional information
59 };
60
61 std::string system_out; // sysout: additional information
62 std::string system_err; // syserr: additional information
63
64 // list of failure, errors and messages (assertions message and the full log)
65 std::vector< assertion_entry > assertion_entries;
66
67 };
68 }
69
70// ************************************************************************** //
71// ************** junit_log_formatter ************** //
72// ************************************************************************** //
73
74/// JUnit logger class
75class junit_log_formatter : public unit_test_log_formatter {
76public:
77
78 junit_log_formatter() : m_display_build_info(false)
79 {
80 this->m_log_level = log_successful_tests;
81 }
82
83 // Formatter interface
84 void log_start( std::ostream&, counter_t test_cases_amount );
85 void log_finish( std::ostream& );
86 void log_build_info( std::ostream& );
87
88 void test_unit_start( std::ostream&, test_unit const& tu );
89 void test_unit_finish( std::ostream&, test_unit const& tu, unsigned long elapsed );
90 void test_unit_skipped( std::ostream&, test_unit const& tu, const_string reason );
91 void test_unit_aborted( std::ostream& os, test_unit const& tu );
92
93 void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const& ex );
94 void log_exception_finish( std::ostream& );
95
96 void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types let );
97
98 using unit_test_log_formatter::log_entry_value; // bring base class functions into overload set
99 void log_entry_value( std::ostream&, const_string value );
100 void log_entry_finish( std::ostream& );
101
102 void entry_context_start( std::ostream&, log_level );
103 void log_entry_context( std::ostream&, const_string );
104 void entry_context_finish( std::ostream& );
105
106 //! Discards changes in the log level
107 virtual void set_log_level(log_level )
108 {
109 }
110
111 //! Instead of a regular stream, returns a file name corresponding to
112 //! the current master test suite. If the file already exists, adds an index
113 //! to it.
114 virtual std::string get_default_stream_description() const;
115
116
117private:
118 typedef std::map<test_unit_id, junit_impl::junit_log_helper> map_trace_t;
119 map_trace_t map_tests;
120
121 std::list<test_unit_id> list_path_to_root;
122 test_unit_id root_id;
123 bool m_display_build_info;
124 bool m_is_last_assertion_or_error; // true if failure, false if error
125
126 friend class junit_result_helper;
127};
128
129} // namespace output
130} // namespace unit_test
131} // namespace boost
132
133#include <boost/test/detail/enable_warnings.hpp>
134
135#endif // BOOST_TEST_JUNIT_LOG_FORMATTER__