json/schema: move validation test cases to own directory

This commit is contained in:
Danny Robson 2018-07-06 13:17:29 +10:00
parent 195616f563
commit 19fdbaefb7
57 changed files with 27 additions and 10 deletions

View File

@ -13,7 +13,7 @@ src="@CMAKE_CURRENT_SOURCE_DIR@/test/json/schema"
devnull=open(os.devnull, 'w')
def test_bad(schema, dir):
def test_bad(schema:str, dir:str) -> int:
failures = 0
for input in glob(os.path.join(dir, "*.json")):
@ -30,7 +30,7 @@ def test_bad(schema, dir):
return failures
def test_good(schema, dir):
def test_good(schema:str, dir:str) -> int:
inputs = glob(os.path.join(dir, "*.input.json"))
results = glob(os.path.join(dir, "*.result.json"))
@ -56,7 +56,7 @@ def test_good(schema, dir):
return failures
def test_pool(dir):
def validation_group(dir:str) -> int:
schema = os.path.join(dir, "schema.json")
if not os.path.isfile(schema):
raise Exception("schema is not present")
@ -67,15 +67,24 @@ def test_pool(dir):
return failures
def test_validation(dir:str) -> int:
failures = 0
groups = (x for x in os.listdir(dir))
groups = (os.path.join(dir, x) for x in groups)
groups = (x for x in groups if os.path.isdir(x))
for name in sorted(groups):
path = os.path.join(src, name)
if not os.path.isdir(path):
continue
failures += validation_group(path)
return failures
if __name__ == "__main__":
failures = 0
for name in os.listdir(src):
path = os.path.join(src, name)
if not os.path.isdir(path):
continue
failures += test_pool(path)
failures += test_validation(os.path.join(src, "validation"))
exit(1 if failures else 0)

View File

@ -0,0 +1 @@
[true]

View File

@ -0,0 +1 @@
{"val": true}

View File

@ -0,0 +1 @@
false

View File

@ -0,0 +1 @@
{ "type": "boolean" }

View File

@ -0,0 +1 @@
true

View File

@ -0,0 +1 @@
null

View File

@ -0,0 +1 @@
"foo"