mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-01-14 01:47:54 +08:00
Stop checking status; raise instead
This commit is contained in:
parent
1ff6bb65a0
commit
411d88fae8
@ -62,6 +62,10 @@ def safeReadFile(path):
|
|||||||
except IOError as e:
|
except IOError as e:
|
||||||
return '<File "%s" is missing: %s>' % (path,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,
|
def runAllTests(jsontest_executable_path, input_dir = None,
|
||||||
use_valgrind=False, with_json_checker=False,
|
use_valgrind=False, with_json_checker=False,
|
||||||
writerClass='StyledWriter'):
|
writerClass='StyledWriter'):
|
||||||
@ -161,10 +165,9 @@ def runAllTests(jsontest_executable_path, input_dir = None,
|
|||||||
print()
|
print()
|
||||||
print('Test results: %d passed, %d failed.' % (len(tests)-len(failed_tests),
|
print('Test results: %d passed, %d failed.' % (len(tests)-len(failed_tests),
|
||||||
len(failed_tests)))
|
len(failed_tests)))
|
||||||
return 1
|
raise FailError(repr(failed_tests))
|
||||||
else:
|
else:
|
||||||
print('All %d tests passed.' % len(tests))
|
print('All %d tests passed.' % len(tests))
|
||||||
return 0
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
@ -187,24 +190,21 @@ def main():
|
|||||||
input_path = os.path.normpath(os.path.abspath(args[1]))
|
input_path = os.path.normpath(os.path.abspath(args[1]))
|
||||||
else:
|
else:
|
||||||
input_path = None
|
input_path = None
|
||||||
status = runAllTests(jsontest_executable_path, input_path,
|
runAllTests(jsontest_executable_path, input_path,
|
||||||
use_valgrind=options.valgrind,
|
use_valgrind=options.valgrind,
|
||||||
with_json_checker=options.with_json_checker,
|
with_json_checker=options.with_json_checker,
|
||||||
writerClass='StyledWriter')
|
writerClass='StyledWriter')
|
||||||
if status:
|
runAllTests(jsontest_executable_path, input_path,
|
||||||
sys.exit(status)
|
|
||||||
status = runAllTests(jsontest_executable_path, input_path,
|
|
||||||
use_valgrind=options.valgrind,
|
use_valgrind=options.valgrind,
|
||||||
with_json_checker=options.with_json_checker,
|
with_json_checker=options.with_json_checker,
|
||||||
writerClass='StyledStreamWriter')
|
writerClass='StyledStreamWriter')
|
||||||
if status:
|
runAllTests(jsontest_executable_path, input_path,
|
||||||
sys.exit(status)
|
|
||||||
status = runAllTests(jsontest_executable_path, input_path,
|
|
||||||
use_valgrind=options.valgrind,
|
use_valgrind=options.valgrind,
|
||||||
with_json_checker=options.with_json_checker,
|
with_json_checker=options.with_json_checker,
|
||||||
writerClass='BuiltStyledStreamWriter')
|
writerClass='BuiltStyledStreamWriter')
|
||||||
if status:
|
|
||||||
sys.exit(status)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
try:
|
||||||
|
main()
|
||||||
|
except FailError:
|
||||||
|
sys.exit(1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user