From ce2fb0b133f50524925084b2106a723405d576e5 Mon Sep 17 00:00:00 2001 From: Kern Handa Date: Thu, 14 Apr 2022 22:01:15 -0700 Subject: [PATCH] Makes output from `hatlib.verify_hat` easier to read (#45) --- hatlib/verify_hat_package.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/hatlib/verify_hat_package.py b/hatlib/verify_hat_package.py index 8890312..4fe1360 100644 --- a/hatlib/verify_hat_package.py +++ b/hatlib/verify_hat_package.py @@ -9,21 +9,34 @@ def verify_hat_package(hat_path): _, funcs = hat.load(hat_path) inputs = hat.generate_input_sets_for_hat_file(hat_path) for name, fn in funcs.items(): - print(f"Verifying function {name} --") + print(f"\n{'*' * 10}\n") + + print(f"[*] Verifying function {name} --") func_inputs = inputs[name] - print("Inputs before function call:") + print("[*] Inputs before function call:") for i, func_input in enumerate(func_inputs): - print(f"\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}") + print(f"[*]\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}") - time = fn(*inputs[name]) + try: + + time = fn(*inputs[name]) + except RuntimeError as e: + print(f"[!] Error while running {name}: {e}") + continue + print("Inputs after function call:") for i, func_input in enumerate(func_inputs): - print(f"\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}") + print(f"[*]\tInput {i}: {','.join(map(str, func_input.ravel()[:32]))}") if time: - print(f"Function execution time: {time:4f}ms") + print(f"[*] Function execution time: {time:4f}ms") + + del inputs[name] + + else: + print(f"\n{'*' * 10}\n") def main():