libcruft-util/test/json/compare.py.in

22 lines
586 B
Python
Raw Normal View History

#!/usr/bin/env python3
from glob import glob
from subprocess import call
from os.path import basename
tool="@CMAKE_CURRENT_BINARY_DIR@/json-compare"
src="@CMAKE_CURRENT_SOURCE_DIR@/test/json/compare"
suffix=".a.json"
for expected in [ "good", "bad" ]:
for path in glob(f"{src}/{expected}/*{suffix}"):
base = path[:-len(suffix)]
inputs = glob(f"{base}*.json")
code = call([tool, *inputs])
success = (expected == "good") == (code == 0)
prefix = "not " if not success else ""
print(prefix, "ok - ", expected, basename(base), code)