Skip to content

Commit

Permalink
Stop checking status; raise instead
Browse files Browse the repository at this point in the history
  • Loading branch information
cdunn2001 committed Apr 24, 2020
1 parent 1ff6bb6 commit 411d88f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/runjsontests.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def safeReadFile(path):
except IOError as e:
return '<File "%s" is missing: %s>' % (path,e)

class FailError(Exception):
def __init__(self, msg):
super(Exception, self).__init__(msg)

def runAllTests(jsontest_executable_path, input_dir = None,
use_valgrind=False, with_json_checker=False,
writerClass='StyledWriter'):
Expand Down Expand Up @@ -161,10 +165,9 @@ def runAllTests(jsontest_executable_path, input_dir = None,
print()
print('Test results: %d passed, %d failed.' % (len(tests)-len(failed_tests),
len(failed_tests)))
return 1
raise FailError(repr(failed_tests))
else:
print('All %d tests passed.' % len(tests))
return 0

def main():
from optparse import OptionParser
Expand All @@ -187,24 +190,21 @@ def main():
input_path = os.path.normpath(os.path.abspath(args[1]))
else:
input_path = None
status = runAllTests(jsontest_executable_path, input_path,
runAllTests(jsontest_executable_path, input_path,
use_valgrind=options.valgrind,
with_json_checker=options.with_json_checker,
writerClass='StyledWriter')
if status:
sys.exit(status)
status = runAllTests(jsontest_executable_path, input_path,
runAllTests(jsontest_executable_path, input_path,
use_valgrind=options.valgrind,
with_json_checker=options.with_json_checker,
writerClass='StyledStreamWriter')
if status:
sys.exit(status)
status = runAllTests(jsontest_executable_path, input_path,
runAllTests(jsontest_executable_path, input_path,
use_valgrind=options.valgrind,
with_json_checker=options.with_json_checker,
writerClass='BuiltStyledStreamWriter')
if status:
sys.exit(status)

if __name__ == '__main__':
main()
try:
main()
except FailError:
sys.exit(1)

0 comments on commit 411d88f

Please sign in to comment.