-
Notifications
You must be signed in to change notification settings - Fork 37
Fix crashes on boolean schemas in various commands #792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| vendorpull https://github.com/sourcemeta/vendorpull 1dcbac42809cf87cb5b045106b863e17ad84ba02 | ||
| core https://github.com/sourcemeta/core 367f6ef45c8e8f05269d65d98dab155505f39ccb | ||
| jsonbinpack https://github.com/sourcemeta/jsonbinpack 183f333e0e032ebf0a397b5d66ed504c44a0a59f | ||
| blaze https://github.com/sourcemeta/blaze a2870f3a3de5fe8cd0008eed5cd679c48ebe126a | ||
| blaze https://github.com/sourcemeta/blaze 18618eccba9609f8beb5563ce57b32ec551f39bf | ||
| ctrf https://github.com/ctrf-io/ctrf 93ea827d951390190171d37443bff169cf47c808 |
This file contains hidden or 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 hidden or 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,24 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << 'EOF' > "$TMP/schema.json" | ||
| true | ||
| EOF | ||
|
|
||
| "$1" bundle "$TMP/schema.json" \ | ||
| --default-dialect "https://json-schema.org/draft/2020-12/schema" > "$TMP/result.json" | ||
|
|
||
| cat << 'EOF' > "$TMP/expected.json" | ||
| true | ||
| EOF | ||
|
|
||
| diff "$TMP/result.json" "$TMP/expected.json" | ||
|
|
||
| # Must come out formatted | ||
| "$1" fmt "$TMP/result.json" --check --default-dialect "https://json-schema.org/draft/2020-12/schema" |
This file contains hidden or 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,32 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << 'EOF' > "$TMP/schema.json" | ||
| true | ||
| EOF | ||
|
|
||
| "$1" inspect "$TMP/schema.json" \ | ||
| --default-dialect "https://json-schema.org/draft/2020-12/schema" > "$TMP/output.txt" | ||
|
|
||
| cat << EOF > "$TMP/expected.txt" | ||
| (RESOURCE) URI: file://$(realpath "$TMP")/schema.json | ||
| Type : Static | ||
| Root : file://$(realpath "$TMP")/schema.json | ||
| Pointer : | ||
| File Position : 1:1 | ||
| Base : file://$(realpath "$TMP")/schema.json | ||
| Relative Pointer : | ||
| Dialect : https://json-schema.org/draft/2020-12/schema | ||
| Base Dialect : https://json-schema.org/draft/2020-12/schema | ||
| Parent : <NONE> | ||
| Property Name : no | ||
| Orphan : no | ||
| EOF | ||
|
|
||
| diff "$TMP/output.txt" "$TMP/expected.txt" |
This file contains hidden or 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,26 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << 'EOF' > "$TMP/schema.json" | ||
| true | ||
| EOF | ||
|
|
||
| cat << 'EOF' > "$TMP/instance.json" | ||
| {} | ||
| EOF | ||
|
|
||
| "$1" rdf "$TMP/schema.json" "$TMP/instance.json" \ | ||
| --default-dialect "https://json-schema.org/draft/2020-12/schema" \ | ||
| > "$TMP/output.json" | ||
|
|
||
| cat << 'EOF' > "$TMP/expected.json" | ||
| [] | ||
| EOF | ||
|
|
||
| diff "$TMP/output.json" "$TMP/expected.json" |
29 changes: 29 additions & 0 deletions
29
test/validate/fail_boolean_schema_false_default_dialect.sh
This file contains hidden or 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,29 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << 'EOF' > "$TMP/schema.json" | ||
| false | ||
| EOF | ||
|
|
||
| cat << 'EOF' > "$TMP/instance.json" | ||
| {} | ||
| EOF | ||
|
|
||
| "$1" validate --default-dialect "https://json-schema.org/draft/2020-12/schema" \ | ||
| "$TMP/schema.json" "$TMP/instance.json" 2> "$TMP/stderr.txt" \ | ||
| && EXIT_CODE="$?" || EXIT_CODE="$?" | ||
| # Validation failure | ||
| test "$EXIT_CODE" = "2" | ||
|
|
||
| cat << EOF > "$TMP/expected.txt" | ||
| fail: $(realpath "$TMP")/instance.json | ||
| error: Schema validation failure | ||
| EOF | ||
|
|
||
| diff "$TMP/stderr.txt" "$TMP/expected.txt" | ||
This file contains hidden or 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,24 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -o errexit | ||
| set -o nounset | ||
|
|
||
| TMP="$(mktemp -d)" | ||
| clean() { rm -rf "$TMP"; } | ||
| trap clean EXIT | ||
|
|
||
| cat << 'EOF' > "$TMP/schema.json" | ||
| true | ||
| EOF | ||
|
|
||
| cat << 'EOF' > "$TMP/instance.json" | ||
| {} | ||
| EOF | ||
|
|
||
| "$1" validate --default-dialect "https://json-schema.org/draft/2020-12/schema" \ | ||
| "$TMP/schema.json" "$TMP/instance.json" > "$TMP/output.txt" 2>&1 | ||
|
|
||
| cat << 'EOF' > "$TMP/expected.txt" | ||
| EOF | ||
|
|
||
| diff "$TMP/output.txt" "$TMP/expected.txt" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.