Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / python / test / SConscript
1 # -*- python -*-
2 #
3 # Copyright (c) 2016 Stefan Seefeld
4 # All rights reserved.
5 #
6 # Distributed under the Boost Software License, Version 1.0.
7 # (See accompanying file LICENSE_1_0.txt or copy at
8 # http://www.boost.org/LICENSE_1_0.txt)
9
10 import platform
11 import sys
12
13 Import('env')
14
15 if sys.platform == 'win32':
16     # HACK: This works around a bug in SCons.
17     #       subprocess.check_output will complain unless all environment
18     #       variables are strings.
19     system_root = env['ENV']['SystemRoot']
20     env['ENV']['SystemRoot'] = str(system_root)
21
22
23 # libs needed for embedding
24 ELIBS=env['LIBS'] + env['PYTHONLIBS']
25
26 def BPLTest(env, name, sources = None, deps = None):
27     run = env.BoostRunPythonScript(name + '.py')
28     if sources:
29         for source in sources:
30             Depends(run,
31                     env.PythonExtension(source != name and source or (source + '_ext'), source + '.cpp')
32             )
33     else:
34         Depends(run, env.PythonExtension(name + '_ext', name + '.cpp'))
35     if deps:
36         Depends(run, deps)
37     return run
38         
39 env.AddMethod(BPLTest)
40
41 env.AppendENVPath('PYTHONPATH', Dir('.').path)
42
43 tests=[]
44 tests+=env.BPLTest('crossmod_exception', ['crossmod_exception_a', 'crossmod_exception_b'])
45
46 for test in [('injected',),
47              ('properties',),
48              ('return_arg',),
49              ('staticmethod',),
50              ('boost_shared_ptr',),
51              ('enable_shared_from_this',),
52              ('andreas_beyer',),
53              ('polymorphism',),
54              ('polymorphism2',),
55              ('wrapper_held_type',),
56              ('minimal',),
57              ('args',),
58              ('raw_ctor',),
59              ('exception_translator',),
60              ('test_enum', ['enum_ext']),
61              ('test_cltree', ['cltree']),
62              ('newtest', ['m1', 'm2']),
63              ('const_argument',),
64              ('keywords_test', ['keywords']),
65              ('test_pointer_adoption',),
66              ('operators',),
67              ('operators_wrapper',),
68              ('callbacks',),
69              ('defaults',),
70              ('object',),
71              ('list',),
72              ('long',),
73              ('dict',),
74              ('tuple',),
75              ('str',),
76              ('slice',),
77              ('virtual_functions',),
78              ('back_reference',),
79              ('implicit',),
80              ('data_members',),
81              ('ben_scott1',),
82              ('bienstman1',),
83              ('bienstman2',),
84              ('bienstman3',),
85              ('multi_arg_constructor',),
86              ('iterator', ['iterator', 'input_iterator']),
87              ('stl_iterator',),
88              ('extract',),
89              ('crossmod_opaque', ['crossmod_opaque_a', 'crossmod_opaque_b']),
90              ('opaque',),
91 #             ('voidptr',),
92              ('pickle1',),
93              ('pickle2',),
94              ('pickle3',),
95              ('pickle4',),
96              ('nested',),
97              ('docstring',),
98              ('pytype_function',),
99              ('vector_indexing_suite',),
100              ('pointer_vector',)]:
101     tests+=env.BPLTest(*test)
102
103 if env['CXX11']:
104     for test in [
105         ('shared_ptr',),
106     ]:
107         tests+=env.BPLTest(*test)
108 else:
109     for test in [
110         ('polymorphism2_auto_ptr',),
111         ('auto_ptr',),
112     ]:
113         tests+=env.BPLTest(*test)
114
115
116 test = env.BoostRunPythonScript('test_builtin_converters.py')
117 Depends(
118     test,
119     env.PythonExtension('builtin_converters_ext', ['test_builtin_converters.cpp'])
120     )
121 tests+=test
122 test = env.BoostRunPythonScript('map_indexing_suite.py')
123 Depends(
124     test,
125     env.PythonExtension('map_indexing_suite_ext', [
126         'map_indexing_suite.cpp',
127         'int_map_indexing_suite.cpp',
128         'a_map_indexing_suite.cpp'])
129     )
130 tests+=test
131
132 tests+=env.BoostRunTest('import_', 'import_.cpp', '${SOURCES[0]} ${SOURCES[1]}', 'import_.py', LIBS=ELIBS)
133
134 tests+=env.BoostCompileTest('indirect_traits_test')
135 tests+=env.BoostRunTests(['destroy_test',
136                           'pointer_type_id_test',
137                           'bases',
138                           'if_else',
139                           'pointee',
140                           'result'], LIBS=ELIBS)
141
142 tests+=env.BoostCompileTests(['string_literal',
143                               'borrowed',
144                               'object_manager',
145                               'copy_ctor_mutates_rhs'])
146
147 tests+=env.BoostRunTest('upcast', LIBS=ELIBS)
148 tests+=env.BoostCompileTest('select_holder')
149 tests+=env.BoostRunTest('select_from_python_test', LIBS=ELIBS)
150 tests+=env.BoostCompileTest('select_arg_to_python_test')
151
152 if platform.system() == 'Windows':
153     tests+=env.BPLTest('calling_conventions')
154     tests+=env.BPLTest('calling_conventions_mf')
155
156 if env['NUMPY']:
157     numpy_env = env.Clone()
158     numpy_env.BoostUseLib('numpy')
159     for test in [('numpy/dtype',),
160                  ('numpy/ufunc',),
161                  ('numpy/templates',),
162                  ('numpy/ndarray',),
163                  ('numpy/indexing',),
164                  ('numpy/shapes',),]:
165         tests+=numpy_env.BPLTest(*test)
166
167
168 env.BoostTestSummary(tests)
169 AlwaysBuild(tests)