1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
|
# -*- python -*-
#
# Copyright (c) 2016 Stefan Seefeld
# All rights reserved.
#
# 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)
from faber import platform
from faber.feature import set
from faber.tools.compiler import runpath
from faber.tools.python import python, pythonpath
from faber.artefacts.object import object
from faber.artefacts.binary import binary
from faber.artefacts.python import extension
from faber.test import test, report, fail
src = module('..src')
python_libs=python.instance().libs
features |= runpath(src.bpl.path, base='')
def extension_test(name, ext=[], script=None, np=False,
features=features, condition=None):
"""Create a Python extension test `name`.
Arguments:
* name: the name of the test.
* ext: extensions to be compiled, <name> if none are given.
* script: the test script to execute, <name>.py if none is given.
* np: if true, add boost_numpy to sources
* features: pre-defined features
* condition: any condition under which to run the test
Return:
* the test artefact"""
features=features.copy()
extensions = []
libs = [src.bnl, src.bpl] if np else [src.bpl]
for e in ext or [name]:
if type(e) is str: # build from a single source file
n = e if e != name else e + '_ext'
s = [e + '.cpp']
else: # build from a list of source files
n = e[0] if e[0] != name else e[0] + '_ext'
s = [n + '.cpp' for n in e]
e = extension(n, s + libs, features=features)
features |= pythonpath(e.path, base='')
extensions.append(e)
if not script:
script = name+'.py'
return test(name, script, run=python.run, dependencies=extensions,
features=features, condition=condition)
tests = []
for t in [('injected',),
('properties',),
('return_arg',),
('staticmethod',),
('boost_shared_ptr',),
('enable_shared_from_this',),
('andreas_beyer',),
('polymorphism',),
('polymorphism2',),
('wrapper_held_type',),
('minimal',),
('args',),
('raw_ctor',),
('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',),
('builtin_converters', [], 'test_builtin_converters.py'),
('map_indexing_suite',
[['map_indexing_suite', 'int_map_indexing_suite', 'a_map_indexing_suite']])]:
tests.append(extension_test(*t))
tests.append(extension_test('shared_ptr',
condition=set.define.contains('HAS_CXX11')))
tests.append(extension_test('polymorphism2_auto_ptr',
condition=set.define.contains('HAS_CXX11').not_()))
tests.append(extension_test('auto_ptr',
condition=set.define.contains('HAS_CXX11')))
import_ = binary('import_', ['import_.cpp', src.bpl], features=features|python_libs)
if platform.os == 'Windows':
command = """set PATH=$(runpath);%PATH%
$(>[1]) $(>[2])"""
else:
command = 'LD_LIBRARY_PATH=$(runpath) $(>[1]) $(>[2])'
tests.append(test('import', [import_, 'import_.py'],
run=action('run', command),
features=features))
tests.append(extension_test('calling_conventions',
condition=platform.os == 'Windows'))
tests.append(extension_test('calling_conventions_mf',
condition=platform.os == 'Windows'))
for t in ['destroy_test',
'pointer_type_id_test',
'bases',
'pointee',
'if_else',
'pointee',
'result',
'upcast',
'select_from_python_test']:
tests.append(test(t, binary(t, [t + '.cpp', src.bpl], features=features), features=features, run=True))
for t in ['indirect_traits_test',
'string_literal',
'borrowed',
'object_manager',
'copy_ctor_mutates_rhs',
'select_holder',
'select_arg_to_python_test']:
tests.append(test(t, object(t, [t + '.cpp'], features=features)))
for t in ['raw_pyobject_fail1',
'raw_pyobject_fail2',
'as_to_python_function',
'object_fail1']:
tests.append(test(t, object(t, [t + '.cpp'], features=features), expected=fail))
for t in ['numpy/dtype',
'numpy/ufunc',
'numpy/templates',
'numpy/ndarray',
'numpy/indexing',
'numpy/shapes']:
tests.append(extension_test(t, np=True,
condition=set.define.contains('HAS_NUMPY')))
default = report('report', tests, fail_on_failures=True)
|