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 #1102.
This commit is contained in:
Jordan Bayles 2019-11-14 10:41:25 -08:00 committed by Christopher Dunn
parent 411d88fae8
commit 9e23f66f61
2 changed files with 27 additions and 36 deletions

View File

@ -105,3 +105,13 @@ test(
jsontestrunner, jsontestrunner,
join_paths(meson.current_source_dir(), 'test/data')] join_paths(meson.current_source_dir(), 'test/data')]
) )
test(
'jsonchecker_jsontestrunner',
python,
args : [
'-B',
join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
'--with-json-checker',
jsontestrunner,
join_paths(meson.current_source_dir(), 'test/data')]
)

View File

@ -73,45 +73,26 @@ def runAllTests(jsontest_executable_path, input_dir = None,
input_dir = os.path.join(os.getcwd(), 'data') input_dir = os.path.join(os.getcwd(), 'data')
tests = glob(os.path.join(input_dir, '*.json')) tests = glob(os.path.join(input_dir, '*.json'))
if with_json_checker: if with_json_checker:
all_test_jsonchecker = glob(os.path.join(input_dir, '../jsonchecker', '*.json')) all_tests = glob(os.path.join(input_dir, '../jsonchecker', '*.json'))
# These tests fail with strict json support, but pass with jsoncpp extra lieniency # These tests fail with strict json support, but pass with JsonCPP's
""" # extra leniency features. When adding a new exclusion to this list,
Failure details: # remember to add the test's number and reasoning here:
* Test ../jsonchecker/fail25.json known = ["fail{}.json".format(n) for n in [
Parsing should have failed: 4, 9, # fail because we allow trailing commas
[" tab character in string "] 7, # fails because we allow commas after close
8, # fails because we allow extra close
* Test ../jsonchecker/fail13.json 10, # fails because we allow extra values after close
Parsing should have failed: 13, # fails because we allow leading zeroes in numbers
{"Numbers cannot have leading zeroes": 013} 18, # fails because we allow deeply nested values
25, # fails because we allow tab characters in strings.
* Test ../jsonchecker/fail18.json 27, # fails because we allow string line breaks
Parsing should have failed: ]]
[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]] test_jsonchecker = [ test for test in all_tests
if os.path.basename(test) not in known]
* Test ../jsonchecker/fail8.json
Parsing should have failed:
["Extra close"]]
* Test ../jsonchecker/fail7.json
Parsing should have failed:
["Comma after the close"],
* Test ../jsonchecker/fail10.json
Parsing should have failed:
{"Extra value after close": true} "misplaced quoted value"
* Test ../jsonchecker/fail27.json
Parsing should have failed:
["line
break"]
"""
known_differences_withjsonchecker = [ "fail25.json", "fail13.json", "fail18.json", "fail8.json",
"fail7.json", "fail10.json", "fail27.json" ]
test_jsonchecker = [ test for test in all_test_jsonchecker if os.path.basename(test) not in known_differences_withjsonchecker ]
else: else:
test_jsonchecker = [] test_jsonchecker = []
failed_tests = [] failed_tests = []
valgrind_path = use_valgrind and VALGRIND_CMD or '' valgrind_path = use_valgrind and VALGRIND_CMD or ''
for input_path in tests + test_jsonchecker: for input_path in tests + test_jsonchecker: