Skip to content

Commit 8ee4323

Browse files
committed
add some more detail in readme; add redundant keyword to some tests
1 parent c883552 commit 8ee4323

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

output-tests/README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,50 @@ Output was initially specified with draft 2019-09. It remained largely unchange
88

99
The tests are organized by specification release and then into two categories: content and structure.
1010

11-
Content tests verify that the keywords are producing the correct annotations and/or error messages. Since there are no requirements on the content of error messages, there's not much that can be verified for them, but it is possible to identify when a error message _could_ be present. Primarily, these tests need to extensively cover the annotation behaviors of each keyword. The only output format needed for these tests is `basic`.
11+
Content tests verify that the keywords are producing the correct annotations and/or error messages. Since there are no requirements on the content of error messages, there's not much that can be verified for them, but it is possible to identify when a error message _could_ be present. Primarily, these tests need to extensively cover the annotation behaviors of each keyword. The only output format needed for these tests is `basic` for 2019-09/2020/12 and `list` for later versions.
1212

13-
Structure tests verify that the structures of the various formats (i.e. `flag`, `basic`, `detailed`, `verbose`) are correct. These tests don't need to cover each keyword; rather they need to sufficiently cover the various aspects of building the output structures by using whatever keywords are necessary to do so.
13+
Structure tests verify that the structures of the various formats (i.e. `flag`, `basic`, `detailed`, `verbose` for 2019/2020 and `flag`, `list`, `hierarchical` for later versions) are correct. These tests don't need to cover each keyword; rather they need to sufficiently cover the various aspects of building the output structures by using whatever keywords are necessary to do so.
1414

1515
In each release folder, you'll also find an _output-schema.json_ file that contains the schema from the specification repo that describes output for that release. This schema will need to be loaded as the tests reference it.
1616

1717
## Test Files
1818

1919
The content of a test file is the same as the validation tests in `tests/`, however an `output` property has been added to each test case.
2020

21-
The `output` property itself has a property for each of the output formats where the value is a schema that will successfully validate for compliant output. For the content tests, only `basic` needs to be present.
21+
The `output` property itself has a property for each of the output formats where the value is a schema that will successfully validate for compliant output. For the content tests, only `basic`/`list` needs to be present.
22+
23+
## Other notes
24+
25+
### Ambiguity around 2020-09/2020-12 `basic`
26+
27+
The 2019-09/2020-12 specs don't define the structure of `basic` very thoroughly. Specifically there is a nuance where if the list contains a single output node, there are two possible structures, given the text:
28+
29+
- the output node for the root schema appears in the list with a containing node that just has a `valid` property
30+
```json
31+
{
32+
"valid": false,
33+
"errors": [
34+
{
35+
"valid": false,
36+
"keywordLocation": "",
37+
"absoluteKeywordLocation": "https://json-schema.org/tests/content/draft2019-09/general/0",
38+
"instanceLocation": ""
39+
}
40+
]
41+
}
42+
```
43+
- the entire structure is collapsed to just the root output node as `detailed` would do.
44+
```json
45+
{
46+
"valid": false,
47+
"keywordLocation": "",
48+
"absoluteKeywordLocation": "https://json-schema.org/tests/content/draft2019-09/general/0",
49+
"instanceLocation": ""
50+
}
51+
```
52+
As the Test Suite should not prefer one interpretation over another, these cases need to be tested another way.
53+
54+
A simple solution (though there are likely others) is to force a second output unit by adding an `"anyOf": [ true ]`. This has no impact on the validation result while adding superfluous structure to the output that avoids the above ambiguous scenario. The test schema should still be targeted on what's being tested and ignore any output units generated by this extra keyword.
2255

2356
## Contributing
2457

output-tests/draft2019-09/content/type.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"schema": {
55
"$schema": "https://json-schema.org/draft/2019-09/schema",
66
"$id": "https://json-schema.org/tests/content/draft2019-09/type/0",
7-
"type": "string"
7+
"type": "string",
8+
"anyOf": [ true ]
89
},
910
"tests": [
1011
{

output-tests/draft2020-12/content/type.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"schema": {
55
"$schema": "https://json-schema.org/draft/2020-12/schema",
66
"$id": "https://json-schema.org/tests/content/draft2020-12/type/0",
7-
"type": "string"
7+
"type": "string",
8+
"anyOf": [ true ]
89
},
910
"tests": [
1011
{

0 commit comments

Comments
 (0)