Skip to content

Commit 7c66ac2

Browse files
committed
- added command-line option --with-json-checker to run test from jsonchecker test suite of json.org.
1 parent 8c2f18c commit 7c66ac2

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

test/runjsontests.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from glob import glob
55
import optparse
66

7-
RUN_JSONCHECKER = False
87
VALGRIND_CMD = 'valgrind --tool=memcheck --leak-check=yes --undef-value-errors=yes '
98

109
def compareOutputs( expected, actual, message ):
@@ -39,12 +38,12 @@ def safeReadFile( path ):
3938
return '<File "%s" is missing: %s>' % (path,e)
4039

4140
def runAllTests( jsontest_executable_path, input_dir = None,
42-
use_valgrind=False ):
41+
use_valgrind=False, with_json_checker=False ):
4342
if not input_dir:
4443
input_dir = os.path.join( os.getcwd(), 'data' )
4544
tests = glob( os.path.join( input_dir, '*.json' ) )
46-
if RUN_JSONCHECKER:
47-
test_jsonchecker = glob( os.path.join( input_dir, 'jsonchecker', '*.json' ) )
45+
if with_json_checker:
46+
test_jsonchecker = glob( os.path.join( input_dir, '../jsonchecker', '*.json' ) )
4847
else:
4948
test_jsonchecker = []
5049
failed_tests = []
@@ -112,6 +111,9 @@ def main():
112111
parser.add_option("--valgrind",
113112
action="store_true", dest="valgrind", default=False,
114113
help="run all the tests using valgrind to detect memory leaks")
114+
parser.add_option("-c", "--with-json-checker",
115+
action="store_true", dest="with_json_checker", default=False,
116+
help="run all the tests from the official JSONChecker test suite of json.org")
115117
parser.enable_interspersed_args()
116118
options, args = parser.parse_args()
117119

@@ -125,7 +127,7 @@ def main():
125127
else:
126128
input_path = None
127129
status = runAllTests( jsontest_executable_path, input_path,
128-
use_valgrind=options.valgrind )
130+
use_valgrind=options.valgrind, with_json_checker=options.with_json_checker )
129131
sys.exit( status )
130132

131133
if __name__ == '__main__':

0 commit comments

Comments
 (0)