Skip to content

Commit ff84978

Browse files
authored
Test meta-schema validation of invalid $vocabulary (#789)
Signed-off-by: Juan Cruz Viotti <[email protected]>
1 parent e9f466c commit ff84978

33 files changed

+420
-218
lines changed

test/cli/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ if(ONE_INDEX)
5959
sourcemeta_one_test_cli(common index fail-self-referencing-metaschema)
6060
sourcemeta_one_test_cli(common index fail-unknown-dialect)
6161
sourcemeta_one_test_cli(common index fail-unknown-option)
62+
sourcemeta_one_test_cli(common index fail-vocabulary-not-object)
6263
sourcemeta_one_test_cli(common index draft4-ignore-vocabulary)
6364
sourcemeta_one_test_cli(common index extra-files-on-rebuild)
6465
sourcemeta_one_test_cli(common index directory-schema-same-name)

test/cli/index/common/collection-path-dot.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ EOF
2727
2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
2828
test "$CODE" = "0" || exit 1
2929

30-
# Remove thread information
31-
if [ "$(uname)" = "Darwin" ]
32-
then
33-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
34-
else
35-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
36-
fi
30+
remove_threads_information() {
31+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
32+
if [ "$(uname -s)" = "Darwin" ]; then
33+
sed -i '' "$expr" "$1"
34+
else
35+
sed -i "$expr" "$1"
36+
fi
37+
}
38+
39+
remove_threads_information "$TMP/output.txt"
3740

3841
cat << EOF > "$TMP/expected.txt"
3942
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/collection-path-empty.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ EOF
2727
2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
2828
test "$CODE" = "0" || exit 1
2929

30-
# Remove thread information
31-
if [ "$(uname)" = "Darwin" ]
32-
then
33-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
34-
else
35-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
36-
fi
30+
remove_threads_information() {
31+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
32+
if [ "$(uname -s)" = "Darwin" ]; then
33+
sed -i '' "$expr" "$1"
34+
else
35+
sed -i "$expr" "$1"
36+
fi
37+
}
38+
39+
remove_threads_information "$TMP/output.txt"
3740

3841
cat << EOF > "$TMP/expected.txt"
3942
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/collection-path-skips-config-files.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ EOF
4848
2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
4949
test "$CODE" = "0" || exit 1
5050

51-
# Remove thread information
52-
if [ "$(uname)" = "Darwin" ]
53-
then
54-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
55-
else
56-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
57-
fi
51+
remove_threads_information() {
52+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
53+
if [ "$(uname -s)" = "Darwin" ]; then
54+
sed -i '' "$expr" "$1"
55+
else
56+
sed -i "$expr" "$1"
57+
fi
58+
}
59+
60+
remove_threads_information "$TMP/output.txt"
5861

5962
cat << EOF > "$TMP/expected.txt"
6063
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/draft4-ignore-vocabulary.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,17 @@ cat << 'EOF' > "$TMP/schemas/test.json"
3636
}
3737
EOF
3838

39-
"$1" --skip-banner "$TMP/one.json" "$TMP/output" --concurrency 1 2> "$TMP/output.txt"
39+
remove_threads_information() {
40+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
41+
if [ "$(uname -s)" = "Darwin" ]; then
42+
sed -i '' "$expr" "$1"
43+
else
44+
sed -i "$expr" "$1"
45+
fi
46+
}
4047

41-
# Remove thread information
42-
if [ "$(uname)" = "Darwin" ]
43-
then
44-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
45-
else
46-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
47-
fi
48+
"$1" --skip-banner "$TMP/one.json" "$TMP/output" --concurrency 1 2> "$TMP/output.txt"
49+
remove_threads_information "$TMP/output.txt"
4850

4951
cat << EOF > "$TMP/expected.txt"
5052
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/fail-bundle-ref-no-fragment.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,16 @@ EOF
3737
2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
3838
test "$CODE" = "1" || exit 1
3939

40-
# Remove thread information
41-
if [ "$(uname)" = "Darwin" ]
42-
then
43-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
44-
else
45-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
46-
fi
40+
remove_threads_information() {
41+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
42+
if [ "$(uname -s)" = "Darwin" ]; then
43+
sed -i '' "$expr" "$1"
44+
else
45+
sed -i "$expr" "$1"
46+
fi
47+
}
48+
49+
remove_threads_information "$TMP/output.txt"
4750

4851
cat << EOF > "$TMP/expected.txt"
4952
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/fail-external-reference.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ EOF
3636
"$1" --skip-banner "$TMP/one.json" "$TMP/output" --concurrency 1 2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
3737
test "$CODE" = "1" || exit 1
3838

39-
# Remove thread information
40-
if [ "$(uname)" = "Darwin" ]
41-
then
42-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
43-
else
44-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
45-
fi
39+
remove_threads_information() {
40+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
41+
if [ "$(uname -s)" = "Darwin" ]; then
42+
sed -i '' "$expr" "$1"
43+
else
44+
sed -i "$expr" "$1"
45+
fi
46+
}
47+
48+
remove_threads_information "$TMP/output.txt"
4649

4750
cat << EOF > "$TMP/expected.txt"
4851
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/fail-invalid-schema-json.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,16 @@ EOF
3232
"$1" --skip-banner "$TMP/one.json" "$TMP/output" --concurrency 1 2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
3333
test "$CODE" = "1" || exit 1
3434

35-
# Remove thread information
36-
if [ "$(uname)" = "Darwin" ]
37-
then
38-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
39-
else
40-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
41-
fi
35+
remove_threads_information() {
36+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
37+
if [ "$(uname -s)" = "Darwin" ]; then
38+
sed -i '' "$expr" "$1"
39+
else
40+
sed -i "$expr" "$1"
41+
fi
42+
}
43+
44+
remove_threads_information "$TMP/output.txt"
4245

4346
cat << EOF > "$TMP/expected.txt"
4447
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/fail-invalid-schema-non-string-dialect.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ EOF
3535
"$1" --skip-banner "$TMP/one.json" "$TMP/output" --concurrency 1 2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
3636
test "$CODE" = "1" || exit 1
3737

38-
# Remove thread information
39-
if [ "$(uname)" = "Darwin" ]
40-
then
41-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
42-
else
43-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
44-
fi
38+
remove_threads_information() {
39+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
40+
if [ "$(uname -s)" = "Darwin" ]; then
41+
sed -i '' "$expr" "$1"
42+
else
43+
sed -i "$expr" "$1"
44+
fi
45+
}
46+
47+
remove_threads_information "$TMP/output.txt"
4548

4649
cat << EOF > "$TMP/expected.txt"
4750
Writing output to: $(realpath "$TMP")/output

test/cli/index/common/fail-invalid-schema-non-string-id.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ EOF
3535
"$1" --skip-banner "$TMP/one.json" "$TMP/output" --concurrency 1 2> "$TMP/output.txt" && CODE="$?" || CODE="$?"
3636
test "$CODE" = "1" || exit 1
3737

38-
# Remove thread information
39-
if [ "$(uname)" = "Darwin" ]
40-
then
41-
sed -i '' 's/ \[.*\]//g' "$TMP/output.txt"
42-
else
43-
sed -i 's/ \[.*\]//g' "$TMP/output.txt"
44-
fi
38+
remove_threads_information() {
39+
expr='s/ \[[^]]*[^a-z-][^]]*\]//g'
40+
if [ "$(uname -s)" = "Darwin" ]; then
41+
sed -i '' "$expr" "$1"
42+
else
43+
sed -i "$expr" "$1"
44+
fi
45+
}
46+
47+
remove_threads_information "$TMP/output.txt"
4548

4649
cat << EOF > "$TMP/expected.txt"
4750
Writing output to: $(realpath "$TMP")/output

0 commit comments

Comments
 (0)