66# The complete license agreement can be obtained at:
77# http://arrayfire.com/licenses/BSD-3-Clause
88########################################################
9-
109import traceback
1110import logging
1211import arrayfire as af
13-
14- def display_func (verbose ):
15- if (verbose ):
16- return af .display
17- else :
18- def eval_func (foo ):
19- res = foo
20- return eval_func
21-
22- def print_func (verbose ):
23- def print_func_impl (* args ):
24- if (verbose ):
25- print (args )
26- else :
27- res = [args ]
28- return print_func_impl
12+ import sys
2913
3014class _simple_test_dict (dict ):
3115
3216 def __init__ (self ):
3317 self .print_str = "Simple %16s: %s"
18+ self .failed = False
3419 super (_simple_test_dict , self ).__init__ ()
3520
3621 def run (self , name_list = None , verbose = False ):
3722 test_list = name_list if name_list is not None else self .keys ()
3823 for key in test_list :
24+ self .print_log = ''
3925 try :
4026 test = self [key ]
4127 except :
@@ -47,8 +33,25 @@ def run(self, name_list=None, verbose=False):
4733 print (self .print_str % (key , "PASSED" ))
4834 except Exception as e :
4935 print (self .print_str % (key , "FAILED" ))
50- if (verbose ):
51- logging .error (traceback .format_exc ())
36+ self .failed = True
37+ if (not verbose ):
38+ print (tests .print_log )
39+ logging .error (traceback .format_exc ())
5240
41+ if (self .failed ):
42+ sys .exit (1 )
5343
5444tests = _simple_test_dict ()
45+
46+ def print_func (verbose ):
47+ def print_func_impl (* args ):
48+ _print_log = ''
49+ for arg in args :
50+ _print_log += str (arg ) + '\n '
51+ if (verbose ):
52+ print (_print_log )
53+ tests .print_log += _print_log
54+ return print_func_impl
55+
56+ def display_func (verbose ):
57+ return print_func (verbose )
0 commit comments