Skip to content

Commit

Permalink
Fix segmentation fault on describing objects failures in test
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Nov 7, 2024
1 parent 7f08123 commit 6e59fec
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ add_jsonschema_test_unix(metaschema/pass_single)
add_jsonschema_test_unix(metaschema/pass_2020_12)

# Test
add_jsonschema_test_unix(test/fail_additional_properties)
add_jsonschema_test_unix(test/fail_true_single_resolve)
add_jsonschema_test_unix(test/fail_true_single_resolve_verbose)
add_jsonschema_test_unix(test/fail_false_single_resolve)
Expand Down
44 changes: 44 additions & 0 deletions test/test/fail_additional_properties.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/sh

set -o errexit
set -o nounset

TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT

cat << 'EOF' > "$TMP/schema.json"
{
"id": "https://example.com",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"additionalProperties": false,
"properties": {
"foo": true,
"bar": true
}
}
EOF

cat << 'EOF' > "$TMP/test.json"
{
"target": "https://example.com",
"tests": [
{
"valid": false,
"data": { "fo": true }
}
]
}
EOF

"$1" test "$TMP/test.json" --resolve "$TMP/schema.json" 1> "$TMP/output.txt" 2>&1 \
&& CODE="$?" || CODE="$?"
test "$CODE" = "1" || exit 1

cat << EOF > "$TMP/expected.txt"
$(realpath "$TMP")/test.json:
1/1 FAIL <no description>
EOF

diff "$TMP/output.txt" "$TMP/expected.txt"

0 comments on commit 6e59fec

Please sign in to comment.