@@ -66,38 +66,51 @@ class FailError(Exception):
6666 def __init__ (self , msg ):
6767 super (Exception , self ).__init__ (msg )
6868
69- def runAllTests (jsontest_executable_path , input_dir = None ,
69+ def runAllTests (jsontest_executable_path , input_path = None ,
7070 use_valgrind = False , with_json_checker = False ,
7171 writerClass = 'StyledWriter' ):
72- if not input_dir :
73- input_dir = os .path .join (os .getcwd (), 'data' )
74- tests = glob (os .path .join (input_dir , '*.json' ))
75- if with_json_checker :
76- all_tests = glob (os .path .join (input_dir , '../jsonchecker' , '*.json' ))
77- # These tests fail with strict json support, but pass with JsonCPP's
78- # extra leniency features. When adding a new exclusion to this list,
79- # remember to add the test's number and reasoning here:
80- known = ["fail{}.json" .format (n ) for n in [
81- 4 , 9 , # fail because we allow trailing commas
82- 7 , # fails because we allow commas after close
83- 8 , # fails because we allow extra close
84- 10 , # fails because we allow extra values after close
85- 13 , # fails because we allow leading zeroes in numbers
86- 18 , # fails because we allow deeply nested values
87- 25 , # fails because we allow tab characters in strings
88- 27 , # fails because we allow string line breaks
89- ]]
90- test_jsonchecker = [ test for test in all_tests
91- if os .path .basename (test ) not in known ]
72+ if not input_path :
73+ input_path = os .path .join (os .getcwd (), 'data' )
9274
75+ if os .path .isdir (input_path ):
76+ tests = [
77+ os .path .normpath (os .path .abspath (test ))
78+ for test in glob (os .path .join (input_path , '*.json' ))
79+ ]
80+
81+ if with_json_checker :
82+ tests += [
83+ os .path .normpath (os .path .abspath (test ))
84+ for test in glob (os .path .join (input_path , '../jsonchecker' , '*.json' ))
85+ ]
9386 else :
94- test_jsonchecker = []
87+ tests = [input_path ]
88+
89+ # These tests fail with strict json support, but pass with JsonCPP's
90+ # extra leniency features. When adding a new exclusion to this list,
91+ # remember to add the test's number and reasoning here:
92+ known = ["fail{}.json" .format (n ) for n in [
93+ 4 , 9 , # fail because we allow trailing commas
94+ 7 , # fails because we allow commas after close
95+ 8 , # fails because we allow extra close
96+ 10 , # fails because we allow extra values after close
97+ 13 , # fails because we allow leading zeroes in numbers
98+ 18 , # fails because we allow deeply nested values
99+ 25 , # fails because we allow tab characters in strings
100+ 27 , # fails because we allow string line breaks
101+ ]]
102+
103+ tests = [
104+ test for test in tests
105+ if os .path .basename (test ) not in known and
106+ os .path .basename (os .path .dirname (test )) == "jsonchecker"
107+ ]
95108
96109 failed_tests = []
97110 valgrind_path = use_valgrind and VALGRIND_CMD or ''
98- for input_path in tests + test_jsonchecker :
111+ for input_path in tests :
99112 expect_failure = os .path .basename (input_path ).startswith ('fail' )
100- is_json_checker_test = input_path in test_jsonchecker
113+ is_json_checker_test = os . path . basename ( os . path . dirname ( input_path )) == "jsonchecker"
101114 is_parse_only = is_json_checker_test or expect_failure
102115 is_strict_test = ('_strict_' in os .path .basename (input_path )) or is_json_checker_test
103116 print ('TESTING:' , input_path , end = ' ' )
0 commit comments