From dd8f4ecd3640b6c0fc2fe3499f20c44b7744683d Mon Sep 17 00:00:00 2001 From: Kunal Bhargava Date: Mon, 3 Jun 2024 17:16:02 +0000 Subject: [PATCH] add folder for missed protobufs --- src/test_suite/test_suite.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/test_suite/test_suite.py b/src/test_suite/test_suite.py index e8837d8..96b05e5 100644 --- a/src/test_suite/test_suite.py +++ b/src/test_suite/test_suite.py @@ -302,6 +302,12 @@ def run_tests( "-f", help="Only log failed test cases", ), + save_failures: bool = typer.Option( + False, + "--save-failures", + "-sf", + help="Saves failed test cases to results directory", + ), ): # Add Solana library to shared libraries shared_libraries = [solana_shared_library] + shared_libraries @@ -357,6 +363,11 @@ def diff_effect_wrapper(a, b): log_dir = globals.output_dir / target.stem log_dir.mkdir(parents=True, exist_ok=True) + # Make failed protobuf directory + if save_failures: + failed_protobufs_dir = globals.output_dir / "failed_protobufs" + failed_protobufs_dir.mkdir(parents=True, exist_ok=True) + test_cases = list(input_dir.iterdir()) num_test_cases = len(test_cases) @@ -410,6 +421,10 @@ def diff_effect_wrapper(a, b): elif status == -1: failed += 1 failed_tests.append(file_stem) + if save_failures: + failed_protobufs = list(input_dir.glob(f"{file_stem}*")) + for failed_protobuf in failed_protobufs: + shutil.copy(failed_protobuf, failed_protobufs_dir) print("Cleaning up...") for target in shared_libraries: