@@ -62,6 +62,10 @@ def safeReadFile(path):
6262 except IOError as e :
6363 return '<File "%s" is missing: %s>' % (path ,e )
6464
65+ class FailError (Exception ):
66+ def __init__ (self , msg ):
67+ super (Exception , self ).__init__ (msg )
68+
6569def runAllTests (jsontest_executable_path , input_dir = None ,
6670 use_valgrind = False , with_json_checker = False ,
6771 writerClass = 'StyledWriter' ):
@@ -161,10 +165,9 @@ def runAllTests(jsontest_executable_path, input_dir = None,
161165 print ()
162166 print ('Test results: %d passed, %d failed.' % (len (tests )- len (failed_tests ),
163167 len (failed_tests )))
164- return 1
168+ raise FailError ( repr ( failed_tests ))
165169 else :
166170 print ('All %d tests passed.' % len (tests ))
167- return 0
168171
169172def main ():
170173 from optparse import OptionParser
@@ -187,24 +190,21 @@ def main():
187190 input_path = os .path .normpath (os .path .abspath (args [1 ]))
188191 else :
189192 input_path = None
190- status = runAllTests (jsontest_executable_path , input_path ,
193+ runAllTests (jsontest_executable_path , input_path ,
191194 use_valgrind = options .valgrind ,
192195 with_json_checker = options .with_json_checker ,
193196 writerClass = 'StyledWriter' )
194- if status :
195- sys .exit (status )
196- status = runAllTests (jsontest_executable_path , input_path ,
197+ runAllTests (jsontest_executable_path , input_path ,
197198 use_valgrind = options .valgrind ,
198199 with_json_checker = options .with_json_checker ,
199200 writerClass = 'StyledStreamWriter' )
200- if status :
201- sys .exit (status )
202- status = runAllTests (jsontest_executable_path , input_path ,
201+ runAllTests (jsontest_executable_path , input_path ,
203202 use_valgrind = options .valgrind ,
204203 with_json_checker = options .with_json_checker ,
205204 writerClass = 'BuiltStyledStreamWriter' )
206- if status :
207- sys .exit (status )
208205
209206if __name__ == '__main__' :
210- main ()
207+ try :
208+ main ()
209+ except FailError :
210+ sys .exit (1 )
0 commit comments