diff --git a/.travis.yml b/.travis.yml index f0bdcfe0..0f528684 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,17 +10,32 @@ language: cpp env: -- PYTHON=python -- PYTHON=python3 +- PYTHON=python CCFLAGS=-std=c++98 +- PYTHON=python CCFLAGS=-std=c++11 +- PYTHON=python3 CCFLAGS=-std=c++98 +- PYTHON=python3 CCFLAGS=-std=c++11 compiler: - - gcc +- gcc + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.8 + - g++-4.8 + - clang + - python-dev python-pip + - python3-dev + - libboost-all-dev + before_install: - - sudo apt-get install -y python-dev python-pip - sudo pip install future - - sudo apt-get install -y python3-dev - - sudo apt-get install -y libboost-all-dev + +install: +- if [ "$CXX" = "g++" ]; then export CXX="g++-4.8" CC="gcc-4.8"; fi script: scons config --python=$PYTHON && scons && scons test diff --git a/config/__init__.py b/config/__init__.py index b03127ec..192e33f6 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -92,7 +92,7 @@ def prepare_build_dir(env): def variants(env): - env.Append(CPPPATH = "#/include", CPPDEFINES = ["BOOST_ALL_NO_LIB=1"]) + env.Prepend(CPPPATH = "#/include", CPPDEFINES = ["BOOST_ALL_NO_LIB=1"]) set_property(env, architecture = env['TARGET_ARCH']) for variant in env["variant"]: e = env.Clone() diff --git a/config/tools/tests.py b/config/tools/tests.py index 9a872f8f..fb224d01 100644 --- a/config/tools/tests.py +++ b/config/tools/tests.py @@ -11,10 +11,25 @@ from SCons.Script import Builder from SCons.Action import Action from subprocess import check_output, STDOUT, CalledProcessError import sys +import os def BoostCompileTest(env, test, source = None, **kw): + + def gen_result(target, source, env=env): + target_file = target[0].abspath + result_file = os.path.splitext(target_file)[0] + '.result' + if sys.stdout.isatty(): + env['RESULT']='\033[92mPASS\033[0m' + else: + env['RESULT']='PASS' + + with open(result_file, 'w+') as result: + result.write('Result: {}\n'.format('pass')) + obj = env.Object(test, source if source is not None else test + '.cpp') + env.AddPostAction(obj, Action(gen_result, cmdstr=None)) + env.AddPostAction(obj, Action('@echo $RESULT')) return obj def BoostRun(env, prog, target, command = '$SOURCE'): @@ -77,8 +92,11 @@ def BoostTestSummary(env, tests, **kw): failures = [r for r in results if r.get_path().endswith('.result') and not 'Result: pass' in r.get_contents()] print('%s tests; %s pass; %s fails'%(len(results), len(results)-len(failures), len(failures))) + if failures: + print('For detailed failure reports, see:') for f in failures: - print('%s\n%s'%(f.get_path(), f.get_contents())) + print(f.get_path()) + testsumcomstr = env.get('TESTSUMCOMSTR') if testsumcomstr: run = env.Command('summary', tests, Action(print_summary, cmdstr=testsumcomstr)) diff --git a/include/boost/python/cast.hpp b/include/boost/python/cast.hpp index 31c61dbf..bad7e282 100755 --- a/include/boost/python/cast.hpp +++ b/include/boost/python/cast.hpp @@ -70,7 +70,7 @@ namespace detail template inline void assert_castable(boost::type* = 0) { - typedef char must_be_a_complete_type[sizeof(T)]; + typedef char must_be_a_complete_type[sizeof(T)] BOOST_ATTRIBUTE_UNUSED; } template diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index f43b615a..70ca6d01 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -140,9 +140,9 @@ namespace detail // https://svn.boost.org/trac/boost/ticket/5803 //typedef typename assertion > >::failed test0; # if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - typedef typename assertion >::failed test1; + typedef typename assertion >::failed test1 BOOST_ATTRIBUTE_UNUSED; # endif - typedef typename assertion >::failed test2; + typedef typename assertion >::failed test2 BOOST_ATTRIBUTE_UNUSED; not_a_derived_class_member(Fn()); } }; diff --git a/include/boost/python/def.hpp b/include/boost/python/def.hpp index 76829b08..fe2c65f9 100644 --- a/include/boost/python/def.hpp +++ b/include/boost/python/def.hpp @@ -37,7 +37,7 @@ namespace detail // Must not try to use default implementations except with method definitions. typedef typename error::multiple_functions_passed_to_def< Helper::has_default_implementation - >::type assertion; + >::type assertion BOOST_ATTRIBUTE_UNUSED; detail::scope_setattr_doc( name, boost::python::make_function( diff --git a/include/boost/python/detail/config.hpp b/include/boost/python/detail/config.hpp index 1857d39a..11c16308 100644 --- a/include/boost/python/detail/config.hpp +++ b/include/boost/python/detail/config.hpp @@ -135,4 +135,8 @@ #define BOOST_PYTHON_SUPPORTS_PY_SIGNATURES // enables smooth transition #endif +#if !defined(BOOST_ATTRIBUTE_UNUSED) && defined(__GNUC__) && (__GNUC__ >= 4) +# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused)) +#endif + #endif // CONFIG_DWA052200_H_ diff --git a/include/boost/python/detail/defaults_gen.hpp b/include/boost/python/detail/defaults_gen.hpp index 0b3e0e26..88beeedb 100644 --- a/include/boost/python/detail/defaults_gen.hpp +++ b/include/boost/python/detail/defaults_gen.hpp @@ -213,7 +213,7 @@ namespace detail { \ typedef typename ::boost::python::detail:: \ error::more_keywords_than_function_arguments< \ - N,n_args>::too_many_keywords assertion; \ + N,n_args>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; \ } \ template \ fstubs_name(::boost::python::detail::keywords const& keywords, char const* doc = 0) \ @@ -222,7 +222,7 @@ namespace detail { \ typedef typename ::boost::python::detail:: \ error::more_keywords_than_function_arguments< \ - N,n_args>::too_many_keywords assertion; \ + N,n_args>::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; \ } # if defined(BOOST_NO_VOID_RETURNS) diff --git a/include/boost/python/init.hpp b/include/boost/python/init.hpp index b82ab01e..792de58e 100644 --- a/include/boost/python/init.hpp +++ b/include/boost/python/init.hpp @@ -68,7 +68,7 @@ namespace detail template struct more_keywords_than_init_arguments { - typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1]; + typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1] BOOST_ATTRIBUTE_UNUSED; }; } @@ -224,7 +224,7 @@ class init : public init_base > { typedef typename detail::error::more_keywords_than_init_arguments< N, n_arguments::value + 1 - >::too_many_keywords assertion; + >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; } template @@ -233,7 +233,7 @@ class init : public init_base > { typedef typename detail::error::more_keywords_than_init_arguments< N, n_arguments::value + 1 - >::too_many_keywords assertion; + >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; } template diff --git a/include/boost/python/make_constructor.hpp b/include/boost/python/make_constructor.hpp index 47cdf469..093703bb 100644 --- a/include/boost/python/make_constructor.hpp +++ b/include/boost/python/make_constructor.hpp @@ -174,7 +174,7 @@ namespace detail typedef typename detail::error::more_keywords_than_function_arguments< NumKeywords::value, arity - >::too_many_keywords assertion; + >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; typedef typename outer_constructor_signature::type outer_signature; diff --git a/include/boost/python/make_function.hpp b/include/boost/python/make_function.hpp index f2f2a9e5..7dd7c316 100644 --- a/include/boost/python/make_function.hpp +++ b/include/boost/python/make_function.hpp @@ -55,7 +55,7 @@ namespace detail typedef typename detail::error::more_keywords_than_function_arguments< NumKeywords::value, arity - >::too_many_keywords assertion; + >::too_many_keywords assertion BOOST_ATTRIBUTE_UNUSED; return objects::function_object( detail::caller(f, p) diff --git a/include/boost/python/object/pickle_support.hpp b/include/boost/python/object/pickle_support.hpp index cbdbcbb9..aa96d655 100644 --- a/include/boost/python/object/pickle_support.hpp +++ b/include/boost/python/object/pickle_support.hpp @@ -107,7 +107,7 @@ namespace detail { { typedef typename error_messages::missing_pickle_suite_function_or_incorrect_signature< - Class_>::error_type error_type; + Class_>::error_type error_type BOOST_ATTRIBUTE_UNUSED; } }; diff --git a/test/SConscript b/test/SConscript index 329f9bf5..896783c8 100644 --- a/test/SConscript +++ b/test/SConscript @@ -7,12 +7,14 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +import platform + Import('env') # libs needed for embedding ELIBS=env['LIBS'] + env['PYTHONLIBS'] -def BPLTest(env, name, sources = None, script = None): +def BPLTest(env, name, sources = None, deps = None): run = env.BoostRunPythonScript(name + '.py') if sources: for source in sources: @@ -21,6 +23,8 @@ def BPLTest(env, name, sources = None, script = None): ) else: Depends(run, env.PythonExtension(name + '_ext', name + '.cpp')) + if deps: + Depends(run, deps) return run env.AddMethod(BPLTest) @@ -30,83 +34,81 @@ env.AppendENVPath('PYTHONPATH', Dir('.').path) tests=[] tests+=env.BPLTest('crossmod_exception', ['crossmod_exception_a', 'crossmod_exception_b']) -for test in ['injected', - 'properties', - 'return_arg', - 'staticmethod', - 'shared_ptr', - 'enable_shared_from_this', - 'andreas_beyer', - 'polymorphism', - 'polymorphism2', - 'wrapper_held_type', - 'polymorphism2_auto_ptr', - 'auto_ptr', - 'minimal', - 'args', - 'raw_ctor', - #'numpy', - 'exception_translator']: - tests+=env.BPLTest(test) +for test in [('injected',), + ('properties',), + ('return_arg',), + ('staticmethod',), + ('shared_ptr',), + ('enable_shared_from_this',), + ('andreas_beyer',), + ('polymorphism',), + ('polymorphism2',), + ('wrapper_held_type',), + ('polymorphism2_auto_ptr',), + ('auto_ptr',), + ('minimal',), + ('args',), + ('raw_ctor',), + ('numpy',None, ['printer.py', 'numeric_tests.py', 'numarray_tests.py']), + ('exception_translator',), + ('test_enum', ['enum_ext']), + ('test_cltree', ['cltree']), + ('newtest', ['m1', 'm2']), + ('const_argument',), + ('keywords_test', ['keywords']), + ('test_pointer_adoption',), + ('operators',), + ('operators_wrapper',), + ('callbacks',), + ('defaults',), + ('object',), + ('list',), + ('long',), + ('dict',), + ('tuple',), + ('str',), + ('slice',), + ('virtual_functions',), + ('back_reference',), + ('implicit',), + ('data_members',), + ('ben_scott1',), + ('bienstman1',), + ('bienstman2',), + ('bienstman3',), + ('multi_arg_constructor',), + ('iterator', ['iterator', 'input_iterator']), + ('stl_iterator',), + ('extract',), + ('crossmod_opaque', ['crossmod_opaque_a', 'crossmod_opaque_b']), + ('opaque',), + ('voidptr',), + ('pickle1',), + ('pickle2',), + ('pickle3',), + ('pickle4',), + ('nested',), + ('docstring',), + ('pytype_function',), + ('vector_indexing_suite',), + ('pointer_vector',)]: + tests+=env.BPLTest(*test) -tests+=env.BPLTest('test_enum', ['enum_ext']) -tests+=env.BPLTest('test_cltree', ['cltree']) -tests+=env.BPLTest('newtest', ['m1', 'm2']) -tests+=env.BPLTest('const_argument') -tests+=env.BPLTest('keywords_test', ['keywords']) +test = env.BoostRunPythonScript('test_builtin_converters.py') Depends( - env.BoostRunPythonScript('test_builtin_converters.py'), - env.PythonExtension('builtin_converters_ext', 'test_builtin_converters.cpp') + test, + env.PythonExtension('builtin_converters_ext', ['test_builtin_converters.cpp']) ) - -for test in ['test_pointer_adoption', - 'operators', - 'operators_wrapper', - 'callbacks', - 'defaults', - 'object', - 'list', - 'long', - 'dict', - 'tuple', - 'str', - 'slice', - 'virtual_functions', - 'back_reference', - 'implicit', - 'data_members', - 'ben_scott1', - 'bienstman1', - 'bienstman2', - 'bienstman3', - 'multi_arg_constructor']: - tests+=env.BPLTest(test) - -tests+=env.BPLTest('iterator', ['iterator', 'input_iterator']) -tests+=env.BPLTest('stl_iterator') -tests+=env.BPLTest('extract') -tests+=env.BPLTest('crossmod_opaque', ['crossmod_opaque_a', 'crossmod_opaque_b']) - -for test in ['opaque', - 'voidptr', - 'pickle1', - 'pickle2', - 'pickle3', - 'pickle4', - 'nested', - 'docstring', - 'pytype_function', - 'vector_indexing_suite', - 'pointer_vector']: - tests+=env.BPLTest(test) - +tests+=test +test = env.BoostRunPythonScript('map_indexing_suite.py') Depends( - env.BoostRunPythonScript('map_indexing_suite.py'), + test, env.PythonExtension('map_indexing_suite_ext', [ 'map_indexing_suite.cpp', 'int_map_indexing_suite.cpp', 'a_map_indexing_suite.cpp']) ) +tests+=test tests+=env.BoostRunTest('import_', 'import_.cpp', '${SOURCES[0]} ${SOURCES[1]}', 'import_.py', LIBS=ELIBS) @@ -128,5 +130,9 @@ tests+=env.BoostCompileTest('select_holder') tests+=env.BoostRunTest('select_from_python_test', LIBS=ELIBS) tests+=env.BoostCompileTest('select_arg_to_python_test') +if platform.system() == 'Windows': + tests+=env.BPLTest('calling_conventions') + tests+=env.BPLTest('calling_conventions_mf') + env.BoostTestSummary(tests) AlwaysBuild(tests) diff --git a/test/destroy_test.cpp b/test/destroy_test.cpp index cae95ae9..57501604 100644 --- a/test/destroy_test.cpp +++ b/test/destroy_test.cpp @@ -38,7 +38,6 @@ void assert_destructions(int n) int main() { assert_destructions(0); - typedef int a[2]; foo* f1 = new foo; boost::python::detail::destroy_referent(f1); diff --git a/test/numeric_tests.py b/test/numeric_tests.py index 569ec19e..f5019212 100644 --- a/test/numeric_tests.py +++ b/test/numeric_tests.py @@ -9,11 +9,11 @@ import printer >>> try: take_array(3) ... except TypeError: pass -... else: print 'expected a TypeError' +... else: print('expected a TypeError') >>> take_array(x) ->>> print x +>>> print(x) [[1 2 3] [4 0 6] [7 8 9]] diff --git a/test/test_builtin_converters.py b/test/test_builtin_converters.py index 53c1e4b3..c3191d9b 100644 --- a/test/test_builtin_converters.py +++ b/test/test_builtin_converters.py @@ -19,12 +19,12 @@ r""" >>> def should_pass(method, values): ... result = map(method, values[0]) ... if result != values[0]: -... print "Got %s but expected %s" % (result, values[0]) +... print("Got %s but expected %s" % (result, values[0])) >>> def test_overflow(method, values): ... for v in values[1]: ... try: method(v) ... except OverflowError: pass -... else: print "OverflowError expected" +... else: print("OverflowError expected") # Synthesize idendity functions in case long long not supported >>> if not 'rewrap_value_long_long' in dir(): @@ -116,7 +116,7 @@ True >>> for v in _unsigned_values(long_long_size())[1]: ... try: rewrap_value_unsigned_long_long(v) ... except (OverflowError, TypeError): pass -... else: print "OverflowError or TypeError expected" +... else: print("OverflowError or TypeError expected") >>> assert abs(rewrap_value_float(4.2) - 4.2) < .000001 >>> rewrap_value_double(4.2) - 4.2 @@ -133,12 +133,12 @@ True >>> rewrap_value_string('yo, wassup?') 'yo, wassup?' ->>> print rewrap_value_wstring(u'yo, wassup?') +>>> print(rewrap_value_wstring(u'yo, wassup?')) yo, wassup? test that overloading on unicode works: ->>> print rewrap_value_string(u'yo, wassup?') +>>> print(rewrap_value_string(u'yo, wassup?')) yo, wassup? wrap strings with embedded nulls: @@ -165,7 +165,7 @@ yo, wassup? >>> try: rewrap_const_reference_bool('yes') ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') >>> rewrap_const_reference_char('x') 'x' @@ -228,7 +228,7 @@ But None cannot be converted to a string object: >>> try: rewrap_const_reference_string(None) ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') Now check implicit conversions between floating/integer types @@ -240,14 +240,14 @@ Now check implicit conversions between floating/integer types >>> try: rewrap_const_reference_int(42.0) ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') >>> rewrap_value_float(42) 42.0 >>> try: rewrap_value_int(42.0) ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') Check that classic classes also work @@ -263,19 +263,19 @@ Check that classic classes also work >>> try: rewrap_const_reference_float(FortyTwo()) ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') >>> try: rewrap_value_int(FortyTwo()) ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') >>> try: rewrap_const_reference_string(FortyTwo()) ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') >>> try: rewrap_value_complex_double(FortyTwo()) ... except TypeError: pass -... else: print 'expected a TypeError exception' +... else: print('expected a TypeError exception') # show that arbitrary handle instantiations can be returned >>> assert get_type(1) is type(1)