From a0d56acabee57a845c004483baf944a578c18fbc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 16 Jun 2020 15:37:19 +0200 Subject: [PATCH] CI: verbose schema-failure diagnostics --- ci/configvalidator.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ci/configvalidator.py b/ci/configvalidator.py index e3b8ac24e..858c53224 100644 --- a/ci/configvalidator.py +++ b/ci/configvalidator.py @@ -79,8 +79,9 @@ with open(schema_file_name, "r") as data: try: validate(instance={}, schema=schema) +# While developing the schemata, get full exceptions from schema failure except SchemaError as e: - print(e.message) + print(e) print("\nSchema file '{}' is invalid JSON-Schema.".format(schema_file_name)) exit(ERR_INVALID) except ValidationError: @@ -101,10 +102,15 @@ for f in config_file_names: print("YAML file '{}' is empty.".format(f)) configs.append(config) +assert len(configs) == len(config_file_names), "Not all configurations loaded." + ### SCHEMA VALIDATION # # -# Here a ValidationError from jsonschema carries a lot of useful information, -# so just let it go. -for c in configs: - validate(instance=c, schema=schema) +for c, f in zip(configs, config_file_names): + try: + validate(instance=c, schema=schema) + except ValidationError as e: + print(e) + print("\nConfig file '{}' does not validate in schema.".format(f)) + exit(ERR_INVALID)