diff --git a/docs/test.markdown b/docs/test.markdown index 18eba8b9..75c4615b 100644 --- a/docs/test.markdown +++ b/docs/test.markdown @@ -30,6 +30,7 @@ To create a test definition, you must write JSON documents that look like this: ```json { "$schema": "http://json-schema.org/draft-04/schema#", + "$comment": "An arbitrary comment! Put whatever you want here", "tests": [ { "description": "The empty object is valid", diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4ad92a87..4bc35a44 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -87,6 +87,7 @@ add_jsonschema_test_unix(test/pass_empty) add_jsonschema_test_unix(test/pass_empty_verbose) add_jsonschema_test_unix(test/pass_single_resolve) add_jsonschema_test_unix(test/pass_single_resolve_verbose) +add_jsonschema_test_unix(test/pass_single_comment_verbose) add_jsonschema_test_unix(test/pass_single_no_description_verbose) add_jsonschema_test_unix(test/pass_single_no_test_description_verbose) add_jsonschema_test_unix(test/pass_multi_directory_resolve) diff --git a/test/test/pass_single_comment_verbose.sh b/test/test/pass_single_comment_verbose.sh new file mode 100755 index 00000000..c153518c --- /dev/null +++ b/test/test/pass_single_comment_verbose.sh @@ -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": "string" +} +EOF + +cat << 'EOF' > "$TMP/test.json" +{ + "$schema": "https://example.com", + "$comment": "A random comment", + "tests": [ + { + "valid": true, + "data": "foo" + }, + { + "valid": false, + "data": 1 + } + ] +} +EOF + +"$1" test "$TMP/test.json" --resolve "$TMP/schema.json" --verbose 1> "$TMP/output.txt" 2>&1 + +cat << EOF > "$TMP/expected.txt" +Importing schema into the resolution context: $(realpath "$TMP")/schema.json +$(realpath "$TMP")/test.json: + 1/2 PASS + 2/2 PASS +EOF + +diff "$TMP/output.txt" "$TMP/expected.txt"