Skip to content

Commit 07dd8ea

Browse files
committed
A few build system fixes.
1 parent 81b3263 commit 07dd8ea

4 files changed

Lines changed: 110 additions & 86 deletions

File tree

config/tools/tests.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,25 @@
1111
from SCons.Action import Action
1212
from subprocess import check_output, STDOUT, CalledProcessError
1313
import sys
14+
import os
1415

1516

1617
def BoostCompileTest(env, test, source = None, **kw):
18+
19+
def gen_result(target, source, env=env):
20+
target_file = target[0].abspath
21+
result_file = os.path.splitext(target_file)[0] + '.result'
22+
if sys.stdout.isatty():
23+
env['RESULT']='\033[92mPASS\033[0m'
24+
else:
25+
env['RESULT']='PASS'
26+
27+
with open(result_file, 'w+') as result:
28+
result.write('Result: {}\n'.format('pass'))
29+
1730
obj = env.Object(test, source if source is not None else test + '.cpp')
31+
env.AddPostAction(obj, Action(gen_result, cmdstr=None))
32+
env.AddPostAction(obj, Action('@echo $RESULT'))
1833
return obj
1934

2035
def BoostRun(env, prog, target, command = '$SOURCE'):
@@ -77,8 +92,11 @@ def print_summary(target, source, **kw):
7792
failures = [r for r in results
7893
if r.get_path().endswith('.result') and not 'Result: pass' in r.get_contents()]
7994
print('%s tests; %s pass; %s fails'%(len(results), len(results)-len(failures), len(failures)))
95+
if failures:
96+
print('For detailed failure reports, see:')
8097
for f in failures:
81-
print('%s\n%s'%(f.get_path(), f.get_contents()))
98+
print(f.get_path())
99+
82100
testsumcomstr = env.get('TESTSUMCOMSTR')
83101
if testsumcomstr:
84102
run = env.Command('summary', tests, Action(print_summary, cmdstr=testsumcomstr))

test/SConscript

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
# (See accompanying file LICENSE_1_0.txt or copy at
88
# http://www.boost.org/LICENSE_1_0.txt)
99

10+
import platform
11+
1012
Import('env')
1113

1214
# libs needed for embedding
1315
ELIBS=env['LIBS'] + env['PYTHONLIBS']
1416

15-
def BPLTest(env, name, sources = None, script = None):
17+
def BPLTest(env, name, sources = None, deps = None):
1618
run = env.BoostRunPythonScript(name + '.py')
1719
if sources:
1820
for source in sources:
@@ -21,6 +23,8 @@ def BPLTest(env, name, sources = None, script = None):
2123
)
2224
else:
2325
Depends(run, env.PythonExtension(name + '_ext', name + '.cpp'))
26+
if deps:
27+
Depends(run, deps)
2428
return run
2529

2630
env.AddMethod(BPLTest)
@@ -30,83 +34,81 @@ env.AppendENVPath('PYTHONPATH', Dir('.').path)
3034
tests=[]
3135
tests+=env.BPLTest('crossmod_exception', ['crossmod_exception_a', 'crossmod_exception_b'])
3236

33-
for test in ['injected',
34-
'properties',
35-
'return_arg',
36-
'staticmethod',
37-
'shared_ptr',
38-
'enable_shared_from_this',
39-
'andreas_beyer',
40-
'polymorphism',
41-
'polymorphism2',
42-
'wrapper_held_type',
43-
'polymorphism2_auto_ptr',
44-
'auto_ptr',
45-
'minimal',
46-
'args',
47-
'raw_ctor',
48-
#'numpy',
49-
'exception_translator']:
50-
tests+=env.BPLTest(test)
51-
52-
tests+=env.BPLTest('test_enum', ['enum_ext'])
53-
tests+=env.BPLTest('test_cltree', ['cltree'])
54-
tests+=env.BPLTest('newtest', ['m1', 'm2'])
55-
tests+=env.BPLTest('const_argument')
56-
tests+=env.BPLTest('keywords_test', ['keywords'])
37+
for test in [('injected',),
38+
('properties',),
39+
('return_arg',),
40+
('staticmethod',),
41+
('shared_ptr',),
42+
('enable_shared_from_this',),
43+
('andreas_beyer',),
44+
('polymorphism',),
45+
('polymorphism2',),
46+
('wrapper_held_type',),
47+
('polymorphism2_auto_ptr',),
48+
('auto_ptr',),
49+
('minimal',),
50+
('args',),
51+
('raw_ctor',),
52+
('numpy',None, ['printer.py', 'numeric_tests.py', 'numarray_tests.py']),
53+
('exception_translator',),
54+
('test_enum', ['enum_ext']),
55+
('test_cltree', ['cltree']),
56+
('newtest', ['m1', 'm2']),
57+
('const_argument',),
58+
('keywords_test', ['keywords']),
59+
('test_pointer_adoption',),
60+
('operators',),
61+
('operators_wrapper',),
62+
('callbacks',),
63+
('defaults',),
64+
('object',),
65+
('list',),
66+
('long',),
67+
('dict',),
68+
('tuple',),
69+
('str',),
70+
('slice',),
71+
('virtual_functions',),
72+
('back_reference',),
73+
('implicit',),
74+
('data_members',),
75+
('ben_scott1',),
76+
('bienstman1',),
77+
('bienstman2',),
78+
('bienstman3',),
79+
('multi_arg_constructor',),
80+
('iterator', ['iterator', 'input_iterator']),
81+
('stl_iterator',),
82+
('extract',),
83+
('crossmod_opaque', ['crossmod_opaque_a', 'crossmod_opaque_b']),
84+
('opaque',),
85+
('voidptr',),
86+
('pickle1',),
87+
('pickle2',),
88+
('pickle3',),
89+
('pickle4',),
90+
('nested',),
91+
('docstring',),
92+
('pytype_function',),
93+
('vector_indexing_suite',),
94+
('pointer_vector',)]:
95+
tests+=env.BPLTest(*test)
96+
97+
test = env.BoostRunPythonScript('test_builtin_converters.py')
5798
Depends(
58-
env.BoostRunPythonScript('test_builtin_converters.py'),
59-
env.PythonExtension('builtin_converters_ext', 'test_builtin_converters.cpp')
99+
test,
100+
env.PythonExtension('builtin_converters_ext', ['test_builtin_converters.cpp'])
60101
)
61-
62-
for test in ['test_pointer_adoption',
63-
'operators',
64-
'operators_wrapper',
65-
'callbacks',
66-
'defaults',
67-
'object',
68-
'list',
69-
'long',
70-
'dict',
71-
'tuple',
72-
'str',
73-
'slice',
74-
'virtual_functions',
75-
'back_reference',
76-
'implicit',
77-
'data_members',
78-
'ben_scott1',
79-
'bienstman1',
80-
'bienstman2',
81-
'bienstman3',
82-
'multi_arg_constructor']:
83-
tests+=env.BPLTest(test)
84-
85-
tests+=env.BPLTest('iterator', ['iterator', 'input_iterator'])
86-
tests+=env.BPLTest('stl_iterator')
87-
tests+=env.BPLTest('extract')
88-
tests+=env.BPLTest('crossmod_opaque', ['crossmod_opaque_a', 'crossmod_opaque_b'])
89-
90-
for test in ['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-
102+
tests+=test
103+
test = env.BoostRunPythonScript('map_indexing_suite.py')
103104
Depends(
104-
env.BoostRunPythonScript('map_indexing_suite.py'),
105+
test,
105106
env.PythonExtension('map_indexing_suite_ext', [
106107
'map_indexing_suite.cpp',
107108
'int_map_indexing_suite.cpp',
108109
'a_map_indexing_suite.cpp'])
109110
)
111+
tests+=test
110112

111113
tests+=env.BoostRunTest('import_', 'import_.cpp', '${SOURCES[0]} ${SOURCES[1]}', 'import_.py', LIBS=ELIBS)
112114

@@ -128,5 +130,9 @@ tests+=env.BoostCompileTest('select_holder')
128130
tests+=env.BoostRunTest('select_from_python_test', LIBS=ELIBS)
129131
tests+=env.BoostCompileTest('select_arg_to_python_test')
130132

133+
if platform.system() == 'Windows':
134+
tests+=env.BPLTest('calling_conventions')
135+
tests+=env.BPLTest('calling_conventions_mf')
136+
131137
env.BoostTestSummary(tests)
132138
AlwaysBuild(tests)

test/numeric_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
1010
>>> try: take_array(3)
1111
... except TypeError: pass
12-
... else: print 'expected a TypeError'
12+
... else: print('expected a TypeError')
1313
1414
>>> take_array(x)
1515
16-
>>> print x
16+
>>> print(x)
1717
[[1 2 3]
1818
[4 0 6]
1919
[7 8 9]]

test/test_builtin_converters.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
>>> def should_pass(method, values):
1818
... result = map(method, values[0])
1919
... if result != values[0]:
20-
... print "Got %s but expected %s" % (result, values[0])
20+
... print("Got %s but expected %s" % (result, values[0]))
2121
>>> def test_overflow(method, values):
2222
... for v in values[1]:
2323
... try: method(v)
2424
... except OverflowError: pass
25-
... else: print "OverflowError expected"
25+
... else: print("OverflowError expected")
2626
2727
# Synthesize idendity functions in case long long not supported
2828
>>> if not 'rewrap_value_long_long' in dir():
@@ -114,7 +114,7 @@
114114
>>> for v in _unsigned_values(long_long_size())[1]:
115115
... try: rewrap_value_unsigned_long_long(v)
116116
... except (OverflowError, TypeError): pass
117-
... else: print "OverflowError or TypeError expected"
117+
... else: print("OverflowError or TypeError expected")
118118
119119
>>> assert abs(rewrap_value_float(4.2) - 4.2) < .000001
120120
>>> rewrap_value_double(4.2) - 4.2
@@ -131,12 +131,12 @@
131131
>>> rewrap_value_string('yo, wassup?')
132132
'yo, wassup?'
133133
134-
>>> print rewrap_value_wstring(u'yo, wassup?')
134+
>>> print(rewrap_value_wstring(u'yo, wassup?'))
135135
yo, wassup?
136136
137137
test that overloading on unicode works:
138138
139-
>>> print rewrap_value_string(u'yo, wassup?')
139+
>>> print(rewrap_value_string(u'yo, wassup?'))
140140
yo, wassup?
141141
142142
wrap strings with embedded nulls:
@@ -163,7 +163,7 @@
163163
164164
>>> try: rewrap_const_reference_bool('yes')
165165
... except TypeError: pass
166-
... else: print 'expected a TypeError exception'
166+
... else: print('expected a TypeError exception')
167167
168168
>>> rewrap_const_reference_char('x')
169169
'x'
@@ -226,7 +226,7 @@
226226
227227
>>> try: rewrap_const_reference_string(None)
228228
... except TypeError: pass
229-
... else: print 'expected a TypeError exception'
229+
... else: print('expected a TypeError exception')
230230
231231
Now check implicit conversions between floating/integer types
232232
@@ -238,14 +238,14 @@
238238
239239
>>> try: rewrap_const_reference_int(42.0)
240240
... except TypeError: pass
241-
... else: print 'expected a TypeError exception'
241+
... else: print('expected a TypeError exception')
242242
243243
>>> rewrap_value_float(42)
244244
42.0
245245
246246
>>> try: rewrap_value_int(42.0)
247247
... except TypeError: pass
248-
... else: print 'expected a TypeError exception'
248+
... else: print('expected a TypeError exception')
249249
250250
Check that classic classes also work
251251
@@ -261,19 +261,19 @@
261261
262262
>>> try: rewrap_const_reference_float(FortyTwo())
263263
... except TypeError: pass
264-
... else: print 'expected a TypeError exception'
264+
... else: print('expected a TypeError exception')
265265
266266
>>> try: rewrap_value_int(FortyTwo())
267267
... except TypeError: pass
268-
... else: print 'expected a TypeError exception'
268+
... else: print('expected a TypeError exception')
269269
270270
>>> try: rewrap_const_reference_string(FortyTwo())
271271
... except TypeError: pass
272-
... else: print 'expected a TypeError exception'
272+
... else: print('expected a TypeError exception')
273273
274274
>>> try: rewrap_value_complex_double(FortyTwo())
275275
... except TypeError: pass
276-
... else: print 'expected a TypeError exception'
276+
... else: print('expected a TypeError exception')
277277
278278
# show that arbitrary handle<T> instantiations can be returned
279279
>>> assert get_type(1) is type(1)

0 commit comments

Comments
 (0)