|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57857 - in trunk/boost/test: detail impl
From: gennadiy.rozental_at_[hidden]
Date: 2009-11-23 00:57:28
Author: rogeeff
Date: 2009-11-23 00:57:27 EST (Mon, 23 Nov 2009)
New Revision: 57857
URL: http://svn.boost.org/trac/boost/changeset/57857
Log:
support for log_sink and report_sink is added
Text files modified:
trunk/boost/test/detail/unit_test_parameters.hpp | 5 ++++
trunk/boost/test/impl/progress_monitor.ipp | 4 ++
trunk/boost/test/impl/results_reporter.ipp | 6 +++-
trunk/boost/test/impl/unit_test_log.ipp | 7 +----
trunk/boost/test/impl/unit_test_parameters.ipp | 49 ++++++++++++++++++++++++++++++++++++++-
5 files changed, 61 insertions(+), 10 deletions(-)
Modified: trunk/boost/test/detail/unit_test_parameters.hpp
==============================================================================
--- trunk/boost/test/detail/unit_test_parameters.hpp (original)
+++ trunk/boost/test/detail/unit_test_parameters.hpp 2009-11-23 00:57:27 EST (Mon, 23 Nov 2009)
@@ -20,6 +20,9 @@
#include <boost/test/detail/suppress_warnings.hpp>
+// STL
+#include <iosfwd>
+
//____________________________________________________________________________//
namespace boost {
@@ -48,6 +51,8 @@
bool BOOST_TEST_DECL detect_fp_exceptions();
output_format BOOST_TEST_DECL report_format();
output_format BOOST_TEST_DECL log_format();
+std::ostream* BOOST_TEST_DECL report_sink();
+std::ostream* BOOST_TEST_DECL log_sink();
long BOOST_TEST_DECL detect_memory_leaks();
int BOOST_TEST_DECL random_seed();
Modified: trunk/boost/test/impl/progress_monitor.ipp
==============================================================================
--- trunk/boost/test/impl/progress_monitor.ipp (original)
+++ trunk/boost/test/impl/progress_monitor.ipp 2009-11-23 00:57:27 EST (Mon, 23 Nov 2009)
@@ -19,6 +19,8 @@
#include <boost/test/progress_monitor.hpp>
#include <boost/test/unit_test_suite_impl.hpp>
+#include <boost/test/detail/unit_test_parameters.hpp>
+
// Boost
#include <boost/progress.hpp>
#include <boost/scoped_ptr.hpp>
@@ -40,7 +42,7 @@
struct progress_monitor_impl {
// Constructor
progress_monitor_impl()
- : m_stream( &std::cout )
+ : m_stream( runtime_config::log_sink() )
{}
std::ostream* m_stream;
Modified: trunk/boost/test/impl/results_reporter.ipp
==============================================================================
--- trunk/boost/test/impl/results_reporter.ipp (original)
+++ trunk/boost/test/impl/results_reporter.ipp 2009-11-23 00:57:27 EST (Mon, 23 Nov 2009)
@@ -23,6 +23,8 @@
#include <boost/test/output/plain_report_formatter.hpp>
#include <boost/test/output/xml_report_formatter.hpp>
+#include <boost/test/detail/unit_test_parameters.hpp>
+
// Boost
#include <boost/scoped_ptr.hpp>
#include <boost/io/ios_state.hpp>
@@ -50,8 +52,8 @@
struct results_reporter_impl : test_tree_visitor {
// Constructor
results_reporter_impl()
- : m_output( &std::cerr )
- , m_stream_state_saver( new io_saver_type( std::cerr ) )
+ : m_output( runtime_config::report_sink() )
+ , m_stream_state_saver( new io_saver_type( *m_output ) )
, m_report_level( CONFIRMATION_REPORT )
, m_formatter( new output::plain_report_formatter )
{}
Modified: trunk/boost/test/impl/unit_test_log.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_log.ipp (original)
+++ trunk/boost/test/impl/unit_test_log.ipp 2009-11-23 00:57:27 EST (Mon, 23 Nov 2009)
@@ -33,9 +33,6 @@
#include <boost/io/ios_state.hpp>
typedef ::boost::io::ios_base_all_saver io_saver_type;
-// STL
-#include <iostream>
-
#include <boost/test/detail/suppress_warnings.hpp>
//____________________________________________________________________________//
@@ -89,8 +86,8 @@
struct unit_test_log_impl {
// Constructor
unit_test_log_impl()
- : m_stream( &std::cout )
- , m_stream_state_saver( new io_saver_type( std::cout ) )
+ : m_stream( runtime_config::log_sink() )
+ , m_stream_state_saver( new io_saver_type( *m_stream ) )
, m_threshold_level( log_all_errors )
, m_log_formatter( new output::compiler_log_formatter )
{
Modified: trunk/boost/test/impl/unit_test_parameters.ipp
==============================================================================
--- trunk/boost/test/impl/unit_test_parameters.ipp (original)
+++ trunk/boost/test/impl/unit_test_parameters.ipp 2009-11-23 00:57:27 EST (Mon, 23 Nov 2009)
@@ -52,6 +52,7 @@
#include <map>
#include <cstdlib>
#include <iostream>
+#include <fstream>
#include <boost/test/detail/suppress_warnings.hpp>
@@ -161,10 +162,12 @@
std::string DETECT_MEM_LEAKS = "detect_memory_leaks";
std::string LOG_FORMAT = "log_format";
std::string LOG_LEVEL = "log_level";
+std::string LOG_SINK = "log_sink";
std::string OUTPUT_FORMAT = "output_format";
std::string RANDOM_SEED = "random";
std::string REPORT_FORMAT = "report_format";
std::string REPORT_LEVEL = "report_level";
+std::string REPORT_SINK = "report_sink";
std::string RESULT_CODE = "result_code";
std::string TESTS_TO_RUN = "run_test";
std::string SAVE_TEST_PATTERN = "save_pattern";
@@ -180,10 +183,12 @@
DETECT_MEM_LEAKS , "BOOST_TEST_DETECT_MEMORY_LEAK",
LOG_FORMAT , "BOOST_TEST_LOG_FORMAT",
LOG_LEVEL , "BOOST_TEST_LOG_LEVEL",
+ LOG_SINK , "BOOST_TEST_LOG_SINK",
OUTPUT_FORMAT , "BOOST_TEST_OUTPUT_FORMAT",
RANDOM_SEED , "BOOST_TEST_RANDOM",
REPORT_FORMAT , "BOOST_TEST_REPORT_FORMAT",
REPORT_LEVEL , "BOOST_TEST_REPORT_LEVEL",
+ REPORT_SINK , "BOOST_TEST_REPORT_SINK",
RESULT_CODE , "BOOST_TEST_RESULT_CODE",
TESTS_TO_RUN , "BOOST_TESTS_TO_RUN",
SAVE_TEST_PATTERN , "BOOST_TEST_SAVE_PATTERN",
@@ -216,9 +221,9 @@
optional<T> val = s_cla_parser.get<optional<T> >( parameter_name );
if( val )
- return *val;
+ return *val;
else
- return optional_value;
+ return optional_value;
}
boost::optional<T> v;
@@ -268,6 +273,9 @@
<< cla::dual_name_parameter<unit_test::log_level>( LOG_LEVEL + "|l" )
- (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
cla::description = "Specifies log level")
+ << cla::dual_name_parameter<std::string>( LOG_SINK + "|k" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies log sink:stdout(default),stderr or file name")
<< cla::dual_name_parameter<unit_test::output_format>( OUTPUT_FORMAT + "|o" )
- (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
cla::description = "Specifies output format (both log and report)")
@@ -281,6 +289,9 @@
<< cla::dual_name_parameter<unit_test::report_level>(REPORT_LEVEL + "|r")
- (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
cla::description = "Specifies report level")
+ << cla::dual_name_parameter<std::string>( REPORT_SINK + "|e" )
+ - (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
+ cla::description = "Specifies report sink:stderr(default),stdout or file name")
<< cla::dual_name_parameter<bool>( RESULT_CODE + "|c" )
- (cla::prefix = "--|-",cla::separator = "=| ",cla::guess_name,cla::optional,
cla::description = "Allows to disable test modules's result code generation")
@@ -453,6 +464,40 @@
//____________________________________________________________________________//
+std::ostream*
+report_sink()
+{
+ std::string sink_name = retrieve_parameter( REPORT_SINK, s_cla_parser, s_empty );
+
+ if( sink_name.empty() || sink_name == "stderr" )
+ return &std::cerr;
+
+ if( sink_name == "stdout" )
+ return &std::cout;
+
+ static std::ofstream log_file( sink_name.c_str() );
+ return &log_file;
+}
+
+//____________________________________________________________________________//
+
+std::ostream*
+log_sink()
+{
+ std::string sink_name = retrieve_parameter( LOG_SINK, s_cla_parser, s_empty );
+
+ if( sink_name.empty() || sink_name == "stdout" )
+ return &std::cout;
+
+ if( sink_name == "stderr" )
+ return &std::cerr;
+
+ static std::ofstream report_file( sink_name.c_str() );
+ return &report_file;
+}
+
+//____________________________________________________________________________//
+
long
detect_memory_leaks()
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk