From b8cbfe03ae22b55aab57e78c8e29798e43d16985 Mon Sep 17 00:00:00 2001 From: Craig Date: Fri, 10 Jan 2025 15:00:32 -0800 Subject: [PATCH] Add sys.exit(1) on failures --- schema/check_generated_data.py | 8 ++++---- schema/check_schemas.py | 3 ++- schema/check_test_output.py | 12 +++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/schema/check_generated_data.py b/schema/check_generated_data.py index 2436cc83..f2e03ac7 100644 --- a/schema/check_generated_data.py +++ b/schema/check_generated_data.py @@ -79,7 +79,7 @@ def main(args): summary_data = json.dumps(summary_json) except BaseException as error: logging.error('json.dumps Summary data problem: %s at %s', error, error) - exit(1) + sys.exit(1) output_filename = os.path.join(test_data_path, 'test_data_validation_summary.json') try: @@ -89,17 +89,17 @@ def main(args): except BaseException as error: schema_errors.append(output_filename) logging.fatal('Error: %s. Cannot save validation summary in file %s', error, output_filename) - exit(1) + sys.exit(1) if schema_errors: logging.critical('Test data file files: %d fail out of %d:', len(schema_errors), schema_count) for failure in schema_errors: logging.critical(' %s', failure) - exit(1) + sys.exit(1) else: logging.info("All %d generated test data files match with schema", schema_count) - exit(0) + sys.exit(0) if __name__ == "__main__": diff --git a/schema/check_schemas.py b/schema/check_schemas.py index 60770223..c16865cc 100644 --- a/schema/check_schemas.py +++ b/schema/check_schemas.py @@ -126,7 +126,8 @@ def main(args): len(schema_errors), schema_count) for failure in schema_errors: logging.error(' %s', failure) - exit(1) + # We need to clobber the process + sys.exit(1) else: logging.info("All %d schema are valid in file %s", schema_count, output_filename) exit(0) diff --git a/schema/check_test_output.py b/schema/check_test_output.py index b76d768f..5d45d676 100644 --- a/schema/check_test_output.py +++ b/schema/check_test_output.py @@ -20,7 +20,7 @@ def main(args): if len(args) <= 1: logging.error('Please specify the path to the test output directory') - exit(1) + sys.exit(1) else: test_output_path = args[1] @@ -85,7 +85,7 @@ def main(args): if json_file not in test_paths: logging.fatal('JSON file %s was not verified against a schema', json_file) # Bail out right away! - exit(1) + sys.exit(1) failed_validations = [] passed_validations = [] @@ -109,14 +109,14 @@ def main(args): } except BaseException as error: logging.fatal('Cannot create summary_json %s', error) - exit(1) + sys.exit(1) # Create outputs from these results. try: summary_data = json.dumps(summary_json) except TypeError as err: logging.fatal('Error: %s\n Cannot dump JSON for %s', err, summary_json) - exit(1) + sys.exit(1) output_filename = os.path.join(test_output_path, 'test_output_validation_summary.json') try: @@ -126,7 +126,7 @@ def main(args): except BaseException as error: logging.fatal('Error: %s. Cannot save validation summary in file %s', error, output_filename) # Don't continue after this problem. - exit(1) + sys.exit(1) logging.info("All %d test output files match with schema", schema_count) return @@ -134,5 +134,3 @@ def main(args): if __name__ == "__main__": main(sys.argv) - -# TODO: Implement this!