Added backward compability code for boost test 1.33 (tested using 1.33.1)
This commit is contained in:
parent
8b5b55b275
commit
65ca06b1c3
14 changed files with 328 additions and 13 deletions
|
@ -152,6 +152,9 @@ if(ENABLE_TOOLS)
|
|||
find_package( ZLIB REQUIRED )
|
||||
find_package( PNG REQUIRED )
|
||||
endif()
|
||||
if(ENABLE_TESTS)
|
||||
find_package( Boost 1.33 REQUIRED COMPONENTS unit_test_framework )
|
||||
endif()
|
||||
|
||||
# get languages
|
||||
file(READ po/LINGUAS LINGUAS)
|
||||
|
|
|
@ -224,7 +224,7 @@ if env["prereqs"]:
|
|||
|
||||
have_server_prereqs = conf.CheckSDL('SDL_net') or Warning("Server prerequisites are not met. wesnothd and campaignd cannot be built.")
|
||||
|
||||
have_test_prereqs = have_client_prereqs and have_server_prereqs and conf.CheckBoost('unit_test_framework', require_version = "1.34.0") or Warning("Unit tests are disabled because their prerequisites are not met.")
|
||||
have_test_prereqs = have_client_prereqs and have_server_prereqs and conf.CheckBoost('unit_test_framework', require_version = "1.33.0") or Warning("Unit tests are disabled because their prerequisites are not met.")
|
||||
|
||||
# have_boost_asio = \
|
||||
# conf.CheckBoost("system", require_version = "1.35.0") and \
|
||||
|
|
|
@ -886,7 +886,6 @@ BOOST_IOSTREAMS
|
|||
BOOST_REGEX
|
||||
|
||||
if test "x$tests" = "xyes"; then
|
||||
BOOST_REQUIRE([1.34])
|
||||
BOOST_TEST
|
||||
# workaround for broken 1.33.1 debian packet
|
||||
if test x"$BOOST_UNIT_TEST_FRAMEWORK_LIBS" = x; then
|
||||
|
|
|
@ -364,7 +364,7 @@ test_sources = Split("""
|
|||
tests/gui/test_save_dialog.cpp
|
||||
tests/utils/play_scenario.cpp
|
||||
""")
|
||||
test_sources.extend(env.Object("tests/test_config_cache.cpp", EXTRA_DEFINE = env['python'] and "HAVE_PYTHON" or None))
|
||||
test_sources.extend(test_env.Object("tests/test_config_cache.cpp", EXTRA_DEFINE = env['python'] and "HAVE_PYTHON" or None))
|
||||
|
||||
test = test_env.WesnothProgram("test", test_sources + [libwesnoth_extras, libwesnoth_core, libwesnoth_sdl, libwesnoth,libtest_utils], have_test_prereqs)
|
||||
#Export("test")
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
|
||||
#include "tests/utils/test_support.hpp"
|
||||
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
|
|
@ -12,8 +12,9 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "tests/utils/test_support.hpp"
|
||||
|
||||
#include <boost/test/unit_test_suite.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
#include "dialogs.hpp"
|
||||
|
|
|
@ -11,12 +11,19 @@
|
|||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#define BOOST_TEST_MODULE wesnoth unit tests master suite
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/test/unit_test_monitor.hpp>
|
||||
#include <boost/test/detail/unit_test_parameters.hpp>
|
||||
#include <boost/test/results_reporter.hpp>
|
||||
|
||||
#if BOOST_VERSION < 103400
|
||||
#include <boost/test/unit_test_log.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "filesystem.hpp"
|
||||
|
@ -48,7 +55,6 @@ static void exception_translator_game(const game::error& e)
|
|||
throw boost::execution_exception(boost::execution_exception::cpp_exception_error, "game::error: " + e.message);
|
||||
}
|
||||
|
||||
|
||||
struct wesnoth_global_fixture {
|
||||
wesnoth_global_fixture()
|
||||
{
|
||||
|
@ -78,8 +84,30 @@ struct wesnoth_global_fixture {
|
|||
}
|
||||
};
|
||||
|
||||
BOOST_GLOBAL_FIXTURE( wesnoth_global_fixture );
|
||||
#if BOOST_VERSION < 103400
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
|
||||
#define BOOST_GLOBAL_FIXTURE(name)\
|
||||
boost::scoped_ptr<name> global_fix;\
|
||||
boost::unit_test::test_suite*\
|
||||
init_unit_test_suite( int argc, char* argv[] ) { \
|
||||
boost::unit_test::auto_unit_test_suite_t* master_test_suite = boost::unit_test::auto_unit_test_suite();\
|
||||
\
|
||||
boost::unit_test::const_string new_name = boost::unit_test::const_string( BOOST_STRINGIZE(BOOST_TEST_MODULE) );\
|
||||
\
|
||||
if( !new_name.is_empty() )\
|
||||
boost::unit_test::assign_op( master_test_suite->p_name.value, new_name, 0 );\
|
||||
\
|
||||
master_test_suite->argc = argc;\
|
||||
master_test_suite->argv = argv;\
|
||||
\
|
||||
global_fix.reset(new name());\
|
||||
return master_test_suite;\
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
BOOST_GLOBAL_FIXTURE(wesnoth_global_fixture);
|
||||
|
||||
/*
|
||||
* This is a main compilation unit for the test program.
|
||||
|
|
|
@ -12,10 +12,11 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "utils/test_support.hpp"
|
||||
|
||||
#define GETTEXT_DOMAIN "wesnoth-test"
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
|
||||
#include "config_cache.hpp"
|
||||
#include "filesystem.hpp"
|
||||
|
|
|
@ -12,14 +12,15 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#include "utils/test_support.hpp"
|
||||
|
||||
|
||||
#include "map.hpp"
|
||||
|
||||
#include "tests/utils/play_scenario.hpp"
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( formula_ai );
|
||||
BOOST_AUTO_TEST_SUITE( formula_ai )
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_move )
|
||||
{
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#include "utils/test_support.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <SDL.h>
|
||||
#include <iostream>
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
|
||||
#include "utils/test_support.hpp"
|
||||
|
||||
#include "team.hpp"
|
||||
|
||||
BOOST_AUTO_TEST_SUITE( teams )
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
|
||||
#include "utils/test_support.hpp"
|
||||
|
||||
#include <string>
|
||||
#include "util.hpp"
|
||||
|
||||
|
|
245
src/tests/utils/boost_unit_test_suite_1_34_0.hpp
Normal file
245
src/tests/utils/boost_unit_test_suite_1_34_0.hpp
Normal file
|
@ -0,0 +1,245 @@
|
|||
// (C) Copyright Gennadiy Rozental 2001-2005.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// See http://www.boost.org/libs/test for the library home page.
|
||||
//
|
||||
// File : $RCSfile: unit_test_suite.hpp,v $
|
||||
//
|
||||
// Version : $Revision: 1.36.1 $
|
||||
//
|
||||
// Description : defines Unit Test Framework public API
|
||||
// ***************************************************************************
|
||||
|
||||
#ifndef BOOST_TEST_UNIT_TEST_SUITE_HPP_1_34_0
|
||||
#define BOOST_TEST_UNIT_TEST_SUITE_HPP_1_34_0
|
||||
|
||||
// Boost.Test
|
||||
#include <boost/test/unit_test_suite.hpp>
|
||||
|
||||
|
||||
// Undefine all previusly define auto macros
|
||||
#undef BOOST_TEST_CASE
|
||||
#undef BOOST_CLASS_TEST_CASE
|
||||
#undef BOOST_TEST_SUITE
|
||||
#undef BOOST_AUTO_TEST_SUITE
|
||||
#undef BOOST_FIXTURE_TEST_SUITE
|
||||
#undef BOOST_AUTO_TEST_SUITE_END
|
||||
#undef BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES
|
||||
#undef BOOST_FIXTURE_TEST_CASE
|
||||
#undef BOOST_AUTO_TEST_CASE
|
||||
#undef BOOST_AUTO_TEST_CASE_TEMPLATE
|
||||
#undef BOOST_GLOBAL_FIXTURE
|
||||
#undef BOOST_AUTO_TC_REGISTRAR
|
||||
#undef BOOST_AUTO_TC_INVOKER
|
||||
#undef BOOST_AUTO_TC_UNIQUE_ID
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** Non-auto (explicit) test case interface ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_CASE( function ) \
|
||||
boost::unit_test::make_test_case( boost::unit_test::callback0<>(function), BOOST_TEST_STRINGIZE( function ) )
|
||||
#define BOOST_CLASS_TEST_CASE( function, tc_instance ) \
|
||||
boost::unit_test::make_test_case((function), BOOST_TEST_STRINGIZE( function ), tc_instance )
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_TEST_SUITE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_TEST_SUITE( testsuite_name ) \
|
||||
( new boost::unit_test::test_suite( testsuite_name ) )
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_SUITE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_AUTO_TEST_SUITE( suite_name ) \
|
||||
namespace suite_name { \
|
||||
BOOST_AUTO_TC_REGISTRAR( suite_name )( BOOST_TEST_SUITE( \
|
||||
BOOST_STRINGIZE( suite_name ) ) ); \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_FIXTURE_TEST_SUITE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_FIXTURE_TEST_SUITE( suite_name, F ) \
|
||||
BOOST_AUTO_TEST_SUITE( suite_name ) \
|
||||
typedef F BOOST_AUTO_TEST_CASE_FIXTURE; \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_SUITE_END ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_AUTO_TEST_SUITE_END() \
|
||||
BOOST_AUTO_TC_REGISTRAR( BOOST_JOIN( end_suite, __LINE__ ) )( 1 ); \
|
||||
} \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES( test_name, n ) \
|
||||
struct BOOST_AUTO_TC_UNIQUE_ID( test_name ); \
|
||||
namespace boost { namespace unit_test { namespace ut_detail { \
|
||||
\
|
||||
template<> \
|
||||
struct auto_tc_exp_fail<BOOST_AUTO_TC_UNIQUE_ID( test_name ) > { \
|
||||
enum { value = n }; \
|
||||
}; \
|
||||
\
|
||||
}}} \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_FIXTURE_TEST_CASE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_FIXTURE_TEST_CASE( test_name, F ) \
|
||||
struct test_name : public F { void test_method(); }; \
|
||||
\
|
||||
static void BOOST_AUTO_TC_INVOKER( test_name )() \
|
||||
{ \
|
||||
test_name t; \
|
||||
t.test_method(); \
|
||||
} \
|
||||
\
|
||||
struct BOOST_AUTO_TC_UNIQUE_ID( test_name ) {}; \
|
||||
\
|
||||
BOOST_AUTO_TC_REGISTRAR( test_name )( \
|
||||
boost::unit_test::make_test_case( \
|
||||
&BOOST_AUTO_TC_INVOKER( test_name ), #test_name ), \
|
||||
boost::unit_test::ut_detail::auto_tc_exp_fail< \
|
||||
BOOST_AUTO_TC_UNIQUE_ID( test_name )>::value ); \
|
||||
\
|
||||
void test_name::test_method() \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_CASE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_AUTO_TEST_CASE( test_name ) \
|
||||
BOOST_FIXTURE_TEST_CASE( test_name, BOOST_AUTO_TEST_CASE_FIXTURE )
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_CASE_TEMPLATE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_AUTO_TEST_CASE_TEMPLATE( test_name, type_name, TL ) \
|
||||
template<typename type_name> \
|
||||
struct test_name : public BOOST_AUTO_TEST_CASE_FIXTURE \
|
||||
{ void test_method(); }; \
|
||||
\
|
||||
struct BOOST_AUTO_TC_INVOKER( test_name ) { \
|
||||
template<typename TestType> \
|
||||
static void run( boost::type<TestType>* = 0 ) \
|
||||
{ \
|
||||
test_name<TestType> t; \
|
||||
t.test_method(); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
BOOST_AUTO_TC_REGISTRAR( test_name )( \
|
||||
boost::unit_test::ut_detail::template_test_case_gen< \
|
||||
BOOST_AUTO_TC_INVOKER( test_name ),TL >( \
|
||||
BOOST_STRINGIZE( test_name ) ) ); \
|
||||
\
|
||||
template<typename type_name> \
|
||||
void test_name<type_name>::test_method() \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_GLOBAL_FIXURE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_GLOBAL_FIXTURE( F ) \
|
||||
static boost::unit_test::ut_detail::global_fixture_impl<F> BOOST_JOIN( gf_, F ) ; \
|
||||
/**/
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_AUTO_TEST_CASE_FIXTURE ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
namespace boost { namespace unit_test { namespace ut_detail {
|
||||
|
||||
struct nil_t {};
|
||||
|
||||
} // namespace ut_detail
|
||||
} // unit_test
|
||||
} // namespace boost
|
||||
|
||||
// Intentionally is in global namespace, so that FIXURE_TEST_SUITE could reset it in user code.
|
||||
typedef ::boost::unit_test::ut_detail::nil_t BOOST_AUTO_TEST_CASE_FIXTURE;
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** Auto registration facility helper macros ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#define BOOST_AUTO_TC_REGISTRAR( test_name ) \
|
||||
static boost::unit_test::ut_detail::auto_test_unit_registrar BOOST_JOIN( test_name, _registrar )
|
||||
#define BOOST_AUTO_TC_INVOKER( test_name ) BOOST_JOIN( test_name, _invoker )
|
||||
#define BOOST_AUTO_TC_UNIQUE_ID( test_name ) BOOST_JOIN( test_name, _id )
|
||||
|
||||
// ************************************************************************** //
|
||||
// ************** BOOST_TEST_MAIN ************** //
|
||||
// ************************************************************************** //
|
||||
|
||||
#if defined(BOOST_TEST_MAIN)
|
||||
|
||||
#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
|
||||
bool init_unit_test() {
|
||||
#else
|
||||
::boost::unit_test::test_suite*
|
||||
init_unit_test_suite( int, char* [] ) {
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_TEST_MODULE
|
||||
using namespace ::boost::unit_test;
|
||||
assign_op( framework::master_test_suite().p_name.value, BOOST_TEST_STRINGIZE( BOOST_TEST_MODULE ).trim( "\"" ), 0 );
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_TEST_ALTERNATIVE_INIT_API
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//____________________________________________________________________________//
|
||||
|
||||
// ***************************************************************************
|
||||
// Revision History :
|
||||
//
|
||||
// $Log: unit_test_suite.hpp,v $
|
||||
// Revision 1.36.1 2008/09/12 12:36:20 suokko
|
||||
// Added undefs for 1.33.1 defined macros
|
||||
//
|
||||
// Revision 1.36 2006/03/19 12:23:21 rogeeff
|
||||
// eliminate warning
|
||||
//
|
||||
// Revision 1.35 2006/02/06 10:04:55 rogeeff
|
||||
// BOOST_TEST_MODULE - master test suite name
|
||||
//
|
||||
// Revision 1.34 2006/01/28 07:02:57 rogeeff
|
||||
// allow multiple global fixtures
|
||||
//
|
||||
// Revision 1.33 2005/12/14 05:24:55 rogeeff
|
||||
// dll support introduced
|
||||
// split into 2 files
|
||||
//
|
||||
// ***************************************************************************
|
||||
|
||||
#endif // BOOST_TEST_UNIT_TEST_SUITE_HPP_071894GER
|
||||
|
30
src/tests/utils/test_support.hpp
Normal file
30
src/tests/utils/test_support.hpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* $Id$ */
|
||||
/*
|
||||
Copyright (C) 2008 by Pauli Nieminen <paniemin@cc.hut.fi>
|
||||
Part of thie Battle for Wesnoth Project http://www.wesnoth.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
or at your option any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY.
|
||||
|
||||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#ifndef TESTS_UTILS_TEST_SUPPORT_HPP_INCLUDED
|
||||
#define TESTS_UTILS_TEST_SUPPORT_HPP_INCLUDED
|
||||
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if BOOST_VERSION < 103400
|
||||
// 1.33 doesn't provide namespace for test suite so fix that
|
||||
#include <boost/test/auto_unit_test.hpp>
|
||||
#include "tests/utils/boost_unit_test_suite_1_34_0.hpp"
|
||||
#else // BOOST_VERSION >= 103400
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue