Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix how '--check-metaschema' builds validators (#230)
* Simplify: remove `make_validator` This was an intermediate method which doesn't appear to be necessary, and leverages caching behavior which is never used. Remove it and move the body into `get_validator` (its only caller). * Minor cleanup to acceptance test naming * Fix how '--check-metaschema' builds a validator Metaschema checking was not building the validator correctly. Primarily two fixes are applied here: - the metaschema's schema dialect is no longer copied from the schema being checked, but is taken from the metaschema document - metaschema checking now automatically includes format checking and applies the CLI parameters for format checking (including the ability to disable format checking) Add test for an invalid format under metaschema. This test requires one of the format checking libraries, and therefore drives the need for new features in the testsuite, including the addition of config for the example file tests. Example file config is schema-validated, which serves as another dogfooding self-check. The test file imitates the driving use-case in #220 The acceptance test definition is refactored to make managing the test data a little easier.
- Loading branch information
Showing
9 changed files
with
334 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"$comment": "An internal schema used to check the testsuite _config.yaml files.", | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$defs": { | ||
"spec": { | ||
"type": "object", | ||
"properties": { | ||
"requires_packages": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"add_args": { | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"type": "object", | ||
"properties": { | ||
"files": { | ||
"type": "object", | ||
"patternProperties": { | ||
"^.+\\.(json|yml|yaml|json5|toml)$": { | ||
"$ref": "#/$defs/spec" | ||
} | ||
}, | ||
"additionalProperties": false | ||
} | ||
}, | ||
"additionalProperties": false | ||
} |
93 changes: 93 additions & 0 deletions
93
tests/example-files/hooks/negative/metaschema/2020_invalid_format_value.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"title": "Meta-schema defining a ref with invalid URI reference", | ||
"$defs": { | ||
"prop<(str|list)>": { | ||
"oneOf": [ | ||
{ | ||
"type": "string" | ||
}, | ||
{ | ||
"type": "array", | ||
"items": true | ||
} | ||
] | ||
}, | ||
"anchorString": { | ||
"type": "string", | ||
"pattern": "^[A-Za-z_][-A-Za-z0-9._]*$" | ||
}, | ||
"uriString": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"uriReferenceString": { | ||
"type": "string", | ||
"format": "uri-reference" | ||
}, | ||
"original2020metaschema": { | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"$vocabulary": { | ||
"https://json-schema.org/draft/2020-12/vocab/core": true | ||
}, | ||
"$dynamicAnchor": "meta", | ||
"title": "Core vocabulary meta-schema", | ||
"type": [ | ||
"object", | ||
"boolean" | ||
], | ||
"properties": { | ||
"$id": { | ||
"$ref": "#/$defs/uriReferenceString", | ||
"$comment": "Non-empty fragments not allowed.", | ||
"pattern": "^[^#]*#?$" | ||
}, | ||
"$schema": { | ||
"$ref": "#/$defs/uriString" | ||
}, | ||
"$ref": { | ||
"$ref": "#/$defs/uriReferenceString" | ||
}, | ||
"$anchor": { | ||
"$ref": "#/$defs/anchorString" | ||
}, | ||
"$dynamicRef": { | ||
"$ref": "#/$defs/uriReferenceString" | ||
}, | ||
"$dynamicAnchor": { | ||
"$ref": "#/$defs/anchorString" | ||
}, | ||
"$vocabulary": { | ||
"type": "object", | ||
"propertyNames": { | ||
"$ref": "#/$defs/uriString" | ||
}, | ||
"additionalProperties": { | ||
"type": "boolean" | ||
} | ||
}, | ||
"$comment": { | ||
"type": "string" | ||
}, | ||
"$defs": { | ||
"type": "object", | ||
"additionalProperties": { | ||
"$dynamicRef": "#meta" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"allOf": [ | ||
{ | ||
"$ref": "#/$defs/original2020metaschema" | ||
}, | ||
{ | ||
"properties": { | ||
"title": { | ||
"$ref": "#/$defs/prop<(str|list)>" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files: | ||
2020_invalid_format_value.json: | ||
requires_packages: | ||
- rfc3987 |
Oops, something went wrong.