Skip to content

Commit 9e23f66

Browse files
baylesjcdunn2001
authored andcommitted
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 411d88f commit 9e23f66

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+
'jsonchecker_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
@@ -73,45 +73,26 @@ def runAllTests(jsontest_executable_path, input_dir = None,
7373
input_dir = os.path.join(os.getcwd(), 'data')
7474
tests = glob(os.path.join(input_dir, '*.json'))
7575
if with_json_checker:
76-
all_test_jsonchecker = glob(os.path.join(input_dir, '../jsonchecker', '*.json'))
77-
# These tests fail with strict json support, but pass with jsoncpp extra lieniency
78-
"""
79-
Failure details:
80-
* Test ../jsonchecker/fail25.json
81-
Parsing should have failed:
82-
[" tab character in string "]
83-
84-
* Test ../jsonchecker/fail13.json
85-
Parsing should have failed:
86-
{"Numbers cannot have leading zeroes": 013}
87-
88-
* Test ../jsonchecker/fail18.json
89-
Parsing should have failed:
90-
[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]
91-
92-
* Test ../jsonchecker/fail8.json
93-
Parsing should have failed:
94-
["Extra close"]]
95-
96-
* Test ../jsonchecker/fail7.json
97-
Parsing should have failed:
98-
["Comma after the close"],
99-
100-
* Test ../jsonchecker/fail10.json
101-
Parsing should have failed:
102-
{"Extra value after close": true} "misplaced quoted value"
103-
104-
* Test ../jsonchecker/fail27.json
105-
Parsing should have failed:
106-
["line
107-
break"]
108-
"""
109-
known_differences_withjsonchecker = [ "fail25.json", "fail13.json", "fail18.json", "fail8.json",
110-
"fail7.json", "fail10.json", "fail27.json" ]
111-
test_jsonchecker = [ test for test in all_test_jsonchecker if os.path.basename(test) not in known_differences_withjsonchecker ]
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]
11292

11393
else:
11494
test_jsonchecker = []
95+
11596
failed_tests = []
11697
valgrind_path = use_valgrind and VALGRIND_CMD or ''
11798
for input_path in tests + test_jsonchecker:

0 commit comments

Comments
 (0)