@@ -62,6 +62,10 @@ def safeReadFile(path):
62
62
except IOError as e :
63
63
return '<File "%s" is missing: %s>' % (path ,e )
64
64
65
+ class FailError (Exception ):
66
+ def __init__ (self , msg ):
67
+ super (Exception , self ).__init__ (msg )
68
+
65
69
def runAllTests (jsontest_executable_path , input_dir = None ,
66
70
use_valgrind = False , with_json_checker = False ,
67
71
writerClass = 'StyledWriter' ):
@@ -161,10 +165,9 @@ def runAllTests(jsontest_executable_path, input_dir = None,
161
165
print ()
162
166
print ('Test results: %d passed, %d failed.' % (len (tests )- len (failed_tests ),
163
167
len (failed_tests )))
164
- return 1
168
+ raise FailError ( repr ( failed_tests ))
165
169
else :
166
170
print ('All %d tests passed.' % len (tests ))
167
- return 0
168
171
169
172
def main ():
170
173
from optparse import OptionParser
@@ -187,24 +190,21 @@ def main():
187
190
input_path = os .path .normpath (os .path .abspath (args [1 ]))
188
191
else :
189
192
input_path = None
190
- status = runAllTests (jsontest_executable_path , input_path ,
193
+ runAllTests (jsontest_executable_path , input_path ,
191
194
use_valgrind = options .valgrind ,
192
195
with_json_checker = options .with_json_checker ,
193
196
writerClass = 'StyledWriter' )
194
- if status :
195
- sys .exit (status )
196
- status = runAllTests (jsontest_executable_path , input_path ,
197
+ runAllTests (jsontest_executable_path , input_path ,
197
198
use_valgrind = options .valgrind ,
198
199
with_json_checker = options .with_json_checker ,
199
200
writerClass = 'StyledStreamWriter' )
200
- if status :
201
- sys .exit (status )
202
- status = runAllTests (jsontest_executable_path , input_path ,
201
+ runAllTests (jsontest_executable_path , input_path ,
203
202
use_valgrind = options .valgrind ,
204
203
with_json_checker = options .with_json_checker ,
205
204
writerClass = 'BuiltStyledStreamWriter' )
206
- if status :
207
- sys .exit (status )
208
205
209
206
if __name__ == '__main__' :
210
- main ()
207
+ try :
208
+ main ()
209
+ except FailError :
210
+ sys .exit (1 )
0 commit comments