6
6
# The complete license agreement can be obtained at:
7
7
# http://arrayfire.com/licenses/BSD-3-Clause
8
8
########################################################
9
-
10
9
import traceback
11
10
import logging
12
11
import 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
29
13
30
14
class _simple_test_dict (dict ):
31
15
32
16
def __init__ (self ):
33
17
self .print_str = "Simple %16s: %s"
18
+ self .failed = False
34
19
super (_simple_test_dict , self ).__init__ ()
35
20
36
21
def run (self , name_list = None , verbose = False ):
37
22
test_list = name_list if name_list is not None else self .keys ()
38
23
for key in test_list :
24
+ self .print_log = ''
39
25
try :
40
26
test = self [key ]
41
27
except :
@@ -47,8 +33,25 @@ def run(self, name_list=None, verbose=False):
47
33
print (self .print_str % (key , "PASSED" ))
48
34
except Exception as e :
49
35
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 ())
52
40
41
+ if (self .failed ):
42
+ sys .exit (1 )
53
43
54
44
tests = _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