Index: libs/test/test/test_tools_test.cpp =================================================================== --- libs/test/test/test_tools_test.cpp (revision 80612) +++ libs/test/test/test_tools_test.cpp (working copy) @@ -100,7 +100,10 @@ \ BOOST_AUTO_TEST_CASE( name ) \ { \ - test_case* impl = make_test_case( &name ## _impl, #name ); \ + test_case* impl = make_test_case( &name ## _impl, \ + #name, \ + __FILE__, \ + __LINE__ ); \ \ unit_test_log.set_stream( ots() ); \ unit_test_log.set_threshold_level( log_nothing ); \ Index: libs/test/test/test_tree_management_test.cpp =================================================================== --- libs/test/test/test_tree_management_test.cpp (revision 80612) +++ libs/test/test/test_tree_management_test.cpp (working copy) @@ -108,8 +108,10 @@ BOOST_CHECK_THROW( &framework::get( tc1->p_id, tut_suite ), framework::internal_error ); - test_case* tc2 = make_test_case( &empty, "my test case" ); + test_case* tc2 = make_test_case( &empty, "my test case", "test_file_name", 1 ); BOOST_CHECK_EQUAL( tc2->p_name, const_string( "my test case" ) ); + BOOST_CHECK_EQUAL( tc2->p_file_name, const_string( "test_file_name" ) ); + BOOST_CHECK_EQUAL( tc2->p_line_num, 1 ); } //____________________________________________________________________________// @@ -139,8 +141,10 @@ { test_suite* ts1 = BOOST_TEST_SUITE( "TestSuite" ); - test_case* tc1 = make_test_case( &empty, "empty1" ); + std::size_t line_num = 1; + test_case* tc1 = make_test_case( &empty, "empty1", "file_name", line_num ); + ts1->add( tc1, 1, 10U ); BOOST_CHECK_EQUAL( ts1->size(), 1U ); @@ -148,7 +152,7 @@ BOOST_CHECK_EQUAL( tc1->p_timeout, 10U ); BOOST_CHECK_EQUAL( ts1->p_expected_failures, 1U ); - test_case* tc2 = make_test_case( &empty, "empty2" ); + test_case* tc2 = make_test_case( &empty, "empty2", "file_name", line_num ); ts1->add( tc2, 2U ); BOOST_CHECK_EQUAL( ts1->size(), 2U ); Index: boost/test/tree/auto_registration.hpp =================================================================== --- boost/test/tree/auto_registration.hpp (revision 80612) +++ boost/test/tree/auto_registration.hpp (working copy) @@ -38,7 +38,7 @@ struct BOOST_TEST_DECL auto_test_unit_registrar { // Constructors auto_test_unit_registrar( test_case* tc, decorator::collector* decorators, counter_t exp_fail = 0 ); - explicit auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators ); + explicit auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector* decorators ); explicit auto_test_unit_registrar( test_unit_generator const& tc_gen, decorator::collector* decorators ); explicit auto_test_unit_registrar( int ); Index: boost/test/tree/test_case_template.hpp =================================================================== --- boost/test/tree/test_case_template.hpp (revision 80612) +++ boost/test/tree/test_case_template.hpp (working copy) @@ -64,8 +64,10 @@ template struct generate_test_case_4_type { - explicit generate_test_case_4_type( const_string tc_name, Generator& G ) + explicit generate_test_case_4_type( const_string tc_name, const_string tc_file, std::size_t tc_line, Generator& G ) : m_test_case_name( tc_name ) + , m_test_case_file( tc_file ) + , m_test_case_line( tc_line ) , m_holder( G ) {} @@ -80,12 +82,17 @@ full_name += " const"; full_name += '>'; - m_holder.m_test_cases.push_back( new test_case( full_name, test_case_template_invoker() ) ); + m_holder.m_test_cases.push_back( new test_case( full_name, + m_test_case_file, + m_test_case_line, + test_case_template_invoker() ) ); } private: // Data members const_string m_test_case_name; + const_string m_test_case_file; + std::size_t m_test_case_line; Generator& m_holder; }; @@ -97,11 +104,11 @@ class template_test_case_gen : public test_unit_generator { public: // Constructor - template_test_case_gen( const_string tc_name ) + template_test_case_gen( const_string tc_name, const_string tc_file, std::size_t tc_line ) { typedef generate_test_case_4_type,TestCaseTemplate> single_test_gen; - mpl::for_each >( single_test_gen( tc_name, *this ) ); + mpl::for_each >( single_test_gen( tc_name, tc_file, tc_line, *this ) ); } virtual test_unit* next() const Index: boost/test/tree/test_unit.hpp =================================================================== --- boost/test/tree/test_unit.hpp (revision 80612) +++ boost/test/tree/test_unit.hpp (working copy) @@ -49,7 +49,7 @@ typedef std::list fixture_list; // Constructor - test_unit( const_string tu_name, test_unit_type t ); + test_unit( const_string tu_name, const_string tc_file, std::size_t tc_line, test_unit_type t ); // dependencies management void depends_on( test_unit* tu ); @@ -70,6 +70,8 @@ readonly_property p_type; // type for this test unit readonly_property p_type_name; // "case"/"suite" + readonly_property p_file_name; + readonly_property p_line_num; id_t p_id; // unique id for this test unit parent_id_t p_parent_id; // parent test suite id id_list_t p_dependencies; // list of test units this one depends on @@ -112,7 +114,7 @@ enum { type = tut_case }; // Constructor - test_case( const_string tc_name, boost::function const& test_func ); + test_case( const_string tc_name, const_string tc_file, std::size_t tc_line, boost::function const& test_func ); // Public property typedef BOOST_READONLY_PROPERTY(boost::function,(test_case)) test_func; @@ -133,7 +135,7 @@ enum { type = tut_suite }; // Constructor - explicit test_suite( const_string ts_name ); + explicit test_suite( const_string ts_name, const_string ts_file, std::size_t ts_line ); // test unit list management void add( test_unit* tu, counter_t expected_failures = 0, unsigned timeout = 0 ); @@ -160,7 +162,7 @@ class BOOST_TEST_DECL master_test_suite_t : public test_suite { public: - master_test_suite_t() : test_suite( "Master Test Suite" ) + master_test_suite_t() : test_suite( "Master Test Suite", "", 0 ) , argc( 0 ) , argv( 0 ) {} @@ -200,9 +202,9 @@ // ************************************************************************** // inline test_case* -make_test_case( boost::function const& test_func, const_string tc_name ) +make_test_case( boost::function const& test_func, const_string tc_name, const_string tc_file, std::size_t tc_line ) { - return new test_case( ut_detail::normalize_test_case_name( tc_name ), test_func ); + return new test_case( ut_detail::normalize_test_case_name( tc_name ), tc_name, tc_line, test_func ); } //____________________________________________________________________________// @@ -211,9 +213,13 @@ inline test_case* make_test_case( void (UserTestCase::* test_method )(), const_string tc_name, + const_string tc_file, + std::size_t tc_line, boost::shared_ptr user_test_case ) { return new test_case( ut_detail::normalize_test_case_name( tc_name ), + tc_file, + tc_line, ut_detail::user_tc_method_invoker( user_test_case, test_method ) ); } Index: boost/test/impl/xml_log_formatter.ipp =================================================================== --- boost/test/impl/xml_log_formatter.ipp (revision 80612) +++ boost/test/impl/xml_log_formatter.ipp (working copy) @@ -80,7 +80,14 @@ void xml_log_formatter::test_unit_start( std::ostream& ostr, test_unit const& tu ) { - ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get() << ">"; + ostr << "<" << tu_type_name( tu ) << " name" << attr_value() << tu.p_name.get(); + + if( !tu.p_file_name.get().empty() ) + { + ostr << BOOST_TEST_L( " file" ) << attr_value() << tu.p_file_name + << BOOST_TEST_L( " line" ) << attr_value() << tu.p_line_num; + } + ostr << ">"; } //____________________________________________________________________________// Index: boost/test/impl/test_tree.ipp =================================================================== --- boost/test/impl/test_tree.ipp (revision 80612) +++ boost/test/impl/test_tree.ipp (working copy) @@ -54,9 +54,11 @@ // ************** test_unit ************** // // ************************************************************************** // -test_unit::test_unit( const_string name, test_unit_type t ) +test_unit::test_unit( const_string name, const_string file_name, std::size_t line_num, test_unit_type t ) : p_type( t ) , p_type_name( t == tut_case ? "case" : "suite" ) +, p_file_name( file_name ) +, p_line_num( line_num ) , p_id( INV_TEST_UNIT_ID ) , p_name( std::string( name.begin(), name.size() ) ) , p_enabled( true ) @@ -126,8 +128,8 @@ // ************** test_case ************** // // ************************************************************************** // -test_case::test_case( const_string name, boost::function const& test_func ) -: test_unit( name, static_cast(type) ) +test_case::test_case( const_string name, const_string file_name, std::size_t line_num, boost::function const& test_func ) +: test_unit( name, file_name, line_num, static_cast(type) ) , p_test_func( test_func ) { framework::register_test_unit( this ); @@ -141,8 +143,8 @@ //____________________________________________________________________________// -test_suite::test_suite( const_string name ) -: test_unit( name, static_cast(type) ) +test_suite::test_suite( const_string name, const_string file_name, std::size_t line_num ) +: test_unit( name, file_name, line_num, static_cast(type) ) { framework::register_test_unit( this ); } @@ -292,7 +294,7 @@ //____________________________________________________________________________// -auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, decorator::collector* decorators ) +auto_test_unit_registrar::auto_test_unit_registrar( const_string ts_name, const_string ts_file, std::size_t ts_line, decorator::collector* decorators ) { test_unit_id id = curr_ts_store().back()->get( ts_name ); @@ -303,7 +305,7 @@ BOOST_ASSERT( ts->p_parent_id == curr_ts_store().back()->p_id ); } else { - ts = new test_suite( ts_name ); + ts = new test_suite( ts_name, ts_file, ts_line ); curr_ts_store().back()->add( ts ); } Index: boost/test/impl/compiler_log_formatter.ipp =================================================================== --- boost/test/impl/compiler_log_formatter.ipp (revision 80612) +++ boost/test/impl/compiler_log_formatter.ipp (working copy) @@ -93,6 +93,7 @@ { BOOST_TEST_SCOPE_SETCOLOR( output, term_attr::BRIGHT, term_color::BLUE ); + print_prefix( output, tu.p_file_name, tu.p_line_num ); output << "Entering test " << tu.p_type_name << " \"" << tu.p_name << "\"" << std::endl; } @@ -230,15 +231,18 @@ //____________________________________________________________________________// void -compiler_log_formatter::print_prefix( std::ostream& output, const_string file, std::size_t line ) +compiler_log_formatter::print_prefix( std::ostream& output, const_string file_name, std::size_t line_num ) { + if( !file_name.empty() ) + { #ifdef __APPLE_CC__ - // Xcode-compatible logging format, idea by Richard Dingwall at - // . - output << file << ':' << line << ": "; + // Xcode-compatible logging format, idea by Richard Dingwall at + // . + output << file_name << ':' << line_num << ": "; #else - output << file << '(' << line << "): "; + output << file_name << '(' << line_num << "): "; #endif + } } //____________________________________________________________________________// Index: boost/test/unit_test_suite.hpp =================================================================== --- boost/test/unit_test_suite.hpp (revision 80612) +++ boost/test/unit_test_suite.hpp (working copy) @@ -27,17 +27,21 @@ // ************** Non-auto (explicit) test case interface ************** // // ************************************************************************** // -#define BOOST_TEST_CASE( test_function ) \ -boost::unit_test::make_test_case( boost::function(test_function), BOOST_TEST_STRINGIZE( test_function ) ) -#define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \ -boost::unit_test::make_test_case((test_function), BOOST_TEST_STRINGIZE( test_function ), tc_instance ) +#define BOOST_TEST_CASE( test_function ) \ +boost::unit_test::make_test_case( boost::function(test_function), \ + BOOST_TEST_STRINGIZE( test_function ), \ + __FILE__, __LINE__ ) +#define BOOST_CLASS_TEST_CASE( test_function, tc_instance ) \ +boost::unit_test::make_test_case( (test_function), \ + BOOST_TEST_STRINGIZE( test_function ), \ + __FILE__, __LINE__, tc_instance ) // ************************************************************************** // // ************** BOOST_TEST_SUITE ************** // // ************************************************************************** // #define BOOST_TEST_SUITE( testsuite_name ) \ -( new boost::unit_test::test_suite( testsuite_name ) ) +( new boost::unit_test::test_suite( testsuite_name, __FILE__, __LINE__ ) ) // ************************************************************************** // // ************** BOOST_AUTO_TEST_SUITE ************** // @@ -47,6 +51,7 @@ namespace suite_name { \ BOOST_AUTO_TU_REGISTRAR( suite_name )( \ BOOST_STRINGIZE( suite_name ), \ + __FILE__, __LINE__, \ boost::unit_test::decorator::collector::instance() ); \ /**/ @@ -97,7 +102,8 @@ \ BOOST_AUTO_TU_REGISTRAR( test_name )( \ boost::unit_test::make_test_case( \ - &BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \ + &BOOST_AUTO_TC_INVOKER( test_name ), \ + #test_name, __FILE__, __LINE__ ), \ boost::unit_test::decorator::collector::instance() ); \ \ void test_name::test_method() \ @@ -135,7 +141,7 @@ BOOST_AUTO_TU_REGISTRAR( test_name )( \ boost::unit_test::ut_detail::template_test_case_gen< \ BOOST_AUTO_TC_INVOKER( test_name ),TL >( \ - BOOST_STRINGIZE( test_name ) ), \ + BOOST_STRINGIZE( test_name ), __FILE__, __LINE__ ), \ boost::unit_test::decorator::collector::instance() ); \ \ template \ @@ -155,7 +161,7 @@ #define BOOST_TEST_CASE_TEMPLATE( name, typelist ) \ boost::unit_test::ut_detail::template_test_case_gen(\ - BOOST_TEST_STRINGIZE( name ) ) \ + BOOST_TEST_STRINGIZE( name ), __FILE__, __LINE__ ) \ /**/ // ************************************************************************** // Index: boost/test/parameterized_test.hpp =================================================================== --- boost/test/parameterized_test.hpp (revision 80612) +++ boost/test/parameterized_test.hpp (working copy) @@ -32,12 +32,14 @@ #define BOOST_PARAM_TEST_CASE( function, begin, end ) \ boost::unit_test::make_test_case( function, \ BOOST_TEST_STRINGIZE( function ), \ + __FILE__, __LINE__, \ (begin), (end) ) \ /**/ #define BOOST_PARAM_CLASS_TEST_CASE( function, tc_instance, begin, end ) \ boost::unit_test::make_test_case( function, \ BOOST_TEST_STRINGIZE( function ), \ + __FILE__, __LINE__, \ (tc_instance), \ (begin), (end) ) \ /**/ @@ -56,10 +58,14 @@ public: param_test_case_generator( boost::function const& test_func, const_string tc_name, + const_string tc_file, + std::size_t tc_line, ParamIter par_begin, ParamIter par_end ) : m_test_func( test_func ) , m_tc_name( ut_detail::normalize_test_case_name( tc_name ) ) + , m_tc_file( tc_file ) + , m_tc_line( tc_line ) , m_par_begin( par_begin ) , m_par_end( par_end ) {} @@ -69,7 +75,7 @@ if( m_par_begin == m_par_end ) return (test_unit*)0; - test_unit* res = new test_case( m_tc_name, boost::bind( m_test_func, *m_par_begin ) ); + test_unit* res = new test_case( m_tc_name, m_tc_file, m_tc_line, boost::bind( m_test_func, *m_par_begin ) ); ++m_par_begin; @@ -80,6 +86,8 @@ // Data members boost::function m_test_func; std::string m_tc_name; + const_string m_tc_file; + std::size_t m_tc_line; mutable ParamIter m_par_begin; ParamIter m_par_end; }; @@ -109,10 +117,12 @@ inline ut_detail::param_test_case_generator make_test_case( boost::function const& test_func, const_string tc_name, + const_string tc_file, + std::size_t tc_line, ParamIter par_begin, ParamIter par_end ) { - return ut_detail::param_test_case_generator( test_func, tc_name, par_begin, par_end ); + return ut_detail::param_test_case_generator( test_func, tc_name, tc_file, tc_line, par_begin, par_end ); } //____________________________________________________________________________// @@ -122,11 +132,13 @@ BOOST_DEDUCED_TYPENAME remove_const::type>::type,ParamIter> make_test_case( void (*test_func)( ParamType ), const_string tc_name, + const_string tc_file, + std::size_t tc_line, ParamIter par_begin, ParamIter par_end ) { typedef BOOST_DEDUCED_TYPENAME remove_const::type>::type param_value_type; - return ut_detail::param_test_case_generator( test_func, tc_name, par_begin, par_end ); + return ut_detail::param_test_case_generator( test_func, tc_name, tc_file, tc_line, par_begin, par_end ); } //____________________________________________________________________________// @@ -136,6 +148,8 @@ BOOST_DEDUCED_TYPENAME remove_const::type>::type,ParamIter> make_test_case( void (UserTestCase::*test_method )( ParamType ), const_string tc_name, + const_string tc_file, + std::size_t tc_line, boost::shared_ptr const& user_test_case, ParamIter par_begin, ParamIter par_end ) @@ -144,6 +158,8 @@ return ut_detail::param_test_case_generator( ut_detail::user_param_tc_method_invoker( user_test_case, test_method ), tc_name, + tc_file, + tc_line, par_begin, par_end ); }