|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +set -o errexit |
| 4 | +set -o nounset |
| 5 | + |
| 6 | +TMP="$(mktemp -d)" |
| 7 | +clean() { rm -rf "$TMP"; } |
| 8 | +trap clean EXIT |
| 9 | + |
| 10 | +cat << EOF > "$TMP/one.json" |
| 11 | +{ |
| 12 | + "url": "https://sourcemeta.com/", |
| 13 | + "contents": { |
| 14 | + "example": { |
| 15 | + "contents": { |
| 16 | + "schemas": { |
| 17 | + "baseUri": "https://example.com/", |
| 18 | + "path": "./schemas" |
| 19 | + } |
| 20 | + } |
| 21 | + } |
| 22 | + } |
| 23 | +} |
| 24 | +EOF |
| 25 | + |
| 26 | +mkdir "$TMP/schemas" |
| 27 | + |
| 28 | +cat << 'EOF' > "$TMP/schemas/custom-meta.json" |
| 29 | +{ |
| 30 | + "$schema": "https://json-schema.org/draft/2020-12/schema", |
| 31 | + "$id": "https://example.com/custom-meta", |
| 32 | + "$vocabulary": "not-an-object" |
| 33 | +} |
| 34 | +EOF |
| 35 | + |
| 36 | +cat << 'EOF' > "$TMP/schemas/test.json" |
| 37 | +{ |
| 38 | + "$schema": "https://example.com/custom-meta", |
| 39 | + "$id": "https://example.com/test", |
| 40 | + "type": "string" |
| 41 | +} |
| 42 | +EOF |
| 43 | + |
| 44 | +"$1" --skip-banner "$TMP/one.json" "$TMP/output" --concurrency 1 2> "$TMP/output.txt" && CODE="$?" || CODE="$?" |
| 45 | +test "$CODE" = "1" || exit 1 |
| 46 | + |
| 47 | +# Remove thread information |
| 48 | +if [ "$(uname)" = "Darwin" ] |
| 49 | +then |
| 50 | + sed -i '' 's/ \[.*\]//g' "$TMP/output.txt" |
| 51 | +else |
| 52 | + sed -i 's/ \[.*\]//g' "$TMP/output.txt" |
| 53 | +fi |
| 54 | + |
| 55 | +cat << EOF > "$TMP/expected.txt" |
| 56 | +Writing output to: $(realpath "$TMP")/output |
| 57 | +Using configuration: $(realpath "$TMP")/one.json |
| 58 | +Detecting: $(realpath "$TMP")/schemas/custom-meta.json (#1) |
| 59 | +Detecting: $(realpath "$TMP")/schemas/test.json (#2) |
| 60 | +( 50%) Resolving: custom-meta.json |
| 61 | +(100%) Resolving: test.json |
| 62 | +( 2%) Producing: configuration.json |
| 63 | +( 5%) Producing: version.json |
| 64 | +( 8%) Producing: explorer/%/404.metapack |
| 65 | +( 11%) Producing: schemas/example/schemas/custom-meta/%/schema.metapack |
| 66 | +error: The schema does not adhere to its metaschema |
| 67 | +The value was expected to be of type object but it was of type string |
| 68 | + at instance location "/\$vocabulary" |
| 69 | + at evaluate path "/allOf/0/\$ref/properties/\$vocabulary/type" |
| 70 | +The object value was expected to validate against the 9 defined properties subschemas |
| 71 | + at instance location "" |
| 72 | + at evaluate path "/allOf/0/\$ref/properties" |
| 73 | +The object value was expected to validate against the referenced schema |
| 74 | + at instance location "" |
| 75 | + at evaluate path "/allOf/0/\$ref" |
| 76 | +The object value was expected to validate against the 7 given subschemas |
| 77 | + at instance location "" |
| 78 | + at evaluate path "/allOf" |
| 79 | +EOF |
| 80 | + |
| 81 | +diff "$TMP/output.txt" "$TMP/expected.txt" |
0 commit comments