diff --git a/tests/workspaces/default/recursiveness/failing-validation.version b/tests/workspaces/default/recursiveness/failing-validation.version new file mode 100644 index 0000000..a864599 --- /dev/null +++ b/tests/workspaces/default/recursiveness/failing-validation.version @@ -0,0 +1,16 @@ +{ + "NAME": "KSP-AVC Version File Validator", + "URL": "https://github.com/DasSkelett/AVC-VersionFileValidator", + "DOWNLOAD": "https://github.com/DasSkelett/AVC-VersionFileValidator/releases", + "GITHUB": { + "USERNAME": "DasSkelett", + "REPOSITORY": "AVC-VersionFileValidator" + }, + "VERSION": { + "MAJOR": 0, + "MINOR": 0, + "PATCH": 0, + "BUILD": 1 + }, + "KSP_VERSION": "*" +} diff --git a/validator/main.py b/validator/main.py index a968231..ce3ea26 100755 --- a/validator/main.py +++ b/validator/main.py @@ -29,26 +29,39 @@ def main(): # How to lazy-get this only when version_files is not empty (which is a generator)? schema = get_schema() + failed = False + failed_files = [] + for f in version_files: - with f.open('r') as vf: - try: - print(f'Loading {f}') + print(f'\nLoading {f}') + try: + with f.open('r') as vf: json_file = json.load(vf) - except json.decoder.JSONDecodeError as e: - print('Failed loading JSON file. Check for syntax errors around the mentioned line:') - print(e.msg) - exit(1) + except json.decoder.JSONDecodeError as e: + print('Failed loading JSON file. Check for syntax errors around the mentioned line:') + print(e.msg) + failed = True + failed_files.append(f.name) + continue + print(f'Validating {f}') try: - print(f'Validating {f}') jsonschema.validate(json_file, schema) except jsonschema.ValidationError as e: - print('Validation failed, see message below:') + print('Validation failed:') print(e.message) - exit(1) + failed = True + failed_files.append(f.name) + continue + print('Validation successful') print('Done!') - exit(0) + if failed: + print('\nThe following files failed validation:') + print(failed_files) + exit(1) + else: + exit(0) def get_schema():