Skip to content

Commit b166b15

Browse files
committed
Issue 1102: Fixup test suite, fix broken tests
A recent PR broken the JsonChecker tests by adding support for trailing commas. This didn't end up breaking the build, because those tests aren't run, except locally and only using CMake. This patch fixes the tests by adding exclusions for trailing comma tests, as well as updates Meson to run these tests as part of `ninja test`. See issue open-source-parsers#1102.
1 parent 3beb37e commit b166b15

File tree

2 files changed

+27
-36
lines changed

2 files changed

+27
-36
lines changed

meson.build

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,13 @@ test(
105105
jsontestrunner,
106106
join_paths(meson.current_source_dir(), 'test/data')]
107107
)
108+
test(
109+
'unittest_jsontestrunner',
110+
python,
111+
args : [
112+
'-B',
113+
join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
114+
'--with-json-checker',
115+
jsontestrunner,
116+
join_paths(meson.current_source_dir(), 'test/data')]
117+
)

test/runjsontests.py

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -69,45 +69,26 @@ def runAllTests(jsontest_executable_path, input_dir = None,
6969
input_dir = os.path.join(os.getcwd(), 'data')
7070
tests = glob(os.path.join(input_dir, '*.json'))
7171
if with_json_checker:
72-
all_test_jsonchecker = glob(os.path.join(input_dir, '../jsonchecker', '*.json'))
73-
# These tests fail with strict json support, but pass with jsoncpp extra lieniency
74-
"""
75-
Failure details:
76-
* Test ../jsonchecker/fail25.json
77-
Parsing should have failed:
78-
[" tab character in string "]
79-
80-
* Test ../jsonchecker/fail13.json
81-
Parsing should have failed:
82-
{"Numbers cannot have leading zeroes": 013}
83-
84-
* Test ../jsonchecker/fail18.json
85-
Parsing should have failed:
86-
[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]
87-
88-
* Test ../jsonchecker/fail8.json
89-
Parsing should have failed:
90-
["Extra close"]]
91-
92-
* Test ../jsonchecker/fail7.json
93-
Parsing should have failed:
94-
["Comma after the close"],
95-
96-
* Test ../jsonchecker/fail10.json
97-
Parsing should have failed:
98-
{"Extra value after close": true} "misplaced quoted value"
99-
100-
* Test ../jsonchecker/fail27.json
101-
Parsing should have failed:
102-
["line
103-
break"]
104-
"""
105-
known_differences_withjsonchecker = [ "fail25.json", "fail13.json", "fail18.json", "fail8.json",
106-
"fail7.json", "fail10.json", "fail27.json" ]
107-
test_jsonchecker = [ test for test in all_test_jsonchecker if os.path.basename(test) not in known_differences_withjsonchecker ]
72+
all_tests = glob(os.path.join(input_dir, '../jsonchecker', '*.json'))
73+
# These tests fail with strict json support, but pass with JsonCPP's
74+
# extra leniency features. When adding a new exclusion to this list,
75+
# remember to add the test's number and reasoning here:
76+
known = ["fail{}.json".format(n) for n in [
77+
4, 9, # fail because we allow trailing commas
78+
7, # fails because we allow commas after close
79+
8, # fails because we allow extra close
80+
10, # fails because we allow extra values after close
81+
13, # fails because we allow leading zeroes in numbers
82+
18, # fails because we allow deeply nested values
83+
25, # fails because we allow tab characters in strings.
84+
27, # fails because we allow string line breaks
85+
]]
86+
test_jsonchecker = [ test for test in all_tests
87+
if os.path.basename(test) not in known]
10888

10989
else:
11090
test_jsonchecker = []
91+
11192
failed_tests = []
11293
valgrind_path = use_valgrind and VALGRIND_CMD or ''
11394
for input_path in tests + test_jsonchecker:

0 commit comments

Comments
 (0)