Update run_tests.py
This commit is contained in:
parent
eece52600b
commit
896a9ff085
19
run_tests.py
19
run_tests.py
@ -12,6 +12,12 @@ class TermFormat:
|
|||||||
BOLD = "\033[1m"
|
BOLD = "\033[1m"
|
||||||
|
|
||||||
|
|
||||||
|
def print_header(header, width, padding):
|
||||||
|
print(
|
||||||
|
f"{TermFormat.BOLD}{'=' * (int(width / 3) + padding)}{header}{'=' * (int(width / 3) + padding)}{TermFormat.ENDC}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
test_dir = Path(__file__).parent / "test_files"
|
test_dir = Path(__file__).parent / "test_files"
|
||||||
hj_exec = Path(__file__).parent / "main"
|
hj_exec = Path(__file__).parent / "main"
|
||||||
|
|
||||||
@ -29,9 +35,20 @@ for vf in valid_files:
|
|||||||
if len(str(vf)) > name_width:
|
if len(str(vf)) > name_width:
|
||||||
name_width = len(str(vf))
|
name_width = len(str(vf))
|
||||||
|
|
||||||
|
|
||||||
|
print_header("helloJSON TEST SUITE", name_width, 9)
|
||||||
|
print()
|
||||||
|
print_header("VALID FILES", name_width, 13)
|
||||||
|
|
||||||
for vf in valid_files:
|
for vf in valid_files:
|
||||||
with open(vf, "r") as infile:
|
with open(vf, "r") as infile:
|
||||||
|
try:
|
||||||
original = json.load(infile)
|
original = json.load(infile)
|
||||||
|
except json.JSONDecodeError as e:
|
||||||
|
print(
|
||||||
|
f"\n{TermFormat.BOLD}{TermFormat.FAIL}ERROR:{TermFormat.ENDC} Failed to decode {str(vf)}\n{e.msg}"
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
cmd = [hj_exec, vf]
|
cmd = [hj_exec, vf]
|
||||||
|
|
||||||
@ -50,5 +67,5 @@ for vf in valid_files:
|
|||||||
match = original == parsed
|
match = original == parsed
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"{str(vf):{name_width + 3}} {TermFormat.BOLD}{TermFormat.OKGREEN if match else TermFormat.FAIL}{'PASSED' if match else 'FAILED'}{TermFormat.ENDC}"
|
f"\n{str(vf):{name_width + 3}} {TermFormat.BOLD}{TermFormat.OKGREEN if match else TermFormat.FAIL}{'PASSED' if match else 'FAILED'}{TermFormat.ENDC}"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user