-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
--trace
option for validation-related commands
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
17 changed files
with
445 additions
and
26 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
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,62 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"minimum": "foo" | ||
} | ||
EOF | ||
|
||
"$1" metaschema "$TMP/schema.json" --trace > "$TMP/output.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
# Order of execution can vary | ||
|
||
cat << 'EOF' > "$TMP/expected-1.txt" | ||
-> (push) "/dependencies" | ||
at "" | ||
<- (pass) "/dependencies" | ||
at "" | ||
-> (push) "/properties" | ||
at "" | ||
-> (push) "/properties/$schema/type" | ||
at "/$schema" | ||
<- (pass) "/properties/$schema/type" | ||
at "/$schema" | ||
-> (push) "/properties/minimum/type" | ||
at "/minimum" | ||
<- (fail) "/properties/minimum/type" | ||
at "/minimum" | ||
<- (fail) "/properties" | ||
at "" | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/expected-2.txt" | ||
-> (push) "/dependencies" | ||
at "" | ||
<- (pass) "/dependencies" | ||
at "" | ||
-> (push) "/properties" | ||
at "" | ||
-> (push) "/properties/minimum/type" | ||
at "/minimum" | ||
<- (fail) "/properties/minimum/type" | ||
at "/minimum" | ||
-> (push) "/properties/$schema/type" | ||
at "/$schema" | ||
<- (pass) "/properties/$schema/type" | ||
at "/$schema" | ||
<- (fail) "/properties" | ||
at "" | ||
EOF | ||
|
||
diff "$TMP/output.txt" "$TMP/expected-1.txt" || \ | ||
diff "$TMP/output.txt" "$TMP/expected-2.txt" |
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,35 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ "$schema": "http://json-schema.org/draft-04/schema#" } | ||
EOF | ||
|
||
"$1" metaschema "$TMP/schema.json" --trace > "$TMP/output.txt" | ||
|
||
cat << 'EOF' > "$TMP/expected.txt" | ||
-> (push) "/dependencies" | ||
at "" | ||
<- (pass) "/dependencies" | ||
at "" | ||
-> (push) "/properties" | ||
at "" | ||
-> (push) "/properties/$schema/type" | ||
at "/$schema" | ||
<- (pass) "/properties/$schema/type" | ||
at "/$schema" | ||
<- (pass) "/properties" | ||
at "" | ||
-> (push) "/type" | ||
at "" | ||
<- (pass) "/type" | ||
at "" | ||
EOF | ||
|
||
diff "$TMP/output.txt" "$TMP/expected.txt" |
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,36 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/schema.json" | ||
{ | ||
"$schema": "https://json-schema.org/draft/2020-12/schema", | ||
"properties": { | ||
"foo": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/instance.json" | ||
{ "foo": 1 } | ||
EOF | ||
|
||
"$1" validate "$TMP/schema.json" "$TMP/instance.json" --trace > "$TMP/output.txt" \ | ||
&& CODE="$?" || CODE="$?" | ||
test "$CODE" = "1" || exit 1 | ||
|
||
cat << EOF > "$TMP/expected.txt" | ||
-> (push) "/properties/foo/type" | ||
at "/foo" | ||
<- (fail) "/properties/foo/type" | ||
at "/foo" | ||
EOF | ||
|
||
diff "$TMP/output.txt" "$TMP/expected.txt" |
Oops, something went wrong.