File tree Expand file tree Collapse file tree 6 files changed +11
-5
lines changed
Expand file tree Collapse file tree 6 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ jsonschema metaschema [schemas-or-directories...]
1313Ensure that a schema or a set of schemas are considered valid with regards to
1414their metaschemas.
1515
16+ To help scripts distinguish validation errors, these are reported using exit
17+ code 2.
18+
1619Examples
1720--------
1821
Original file line number Diff line number Diff line change @@ -68,5 +68,8 @@ auto sourcemeta::jsonschema::cli::metaschema(
6868 }
6969 }
7070
71- return result ? EXIT_SUCCESS : EXIT_FAILURE;
71+ return result ? EXIT_SUCCESS
72+ // Report a different exit code for validation failures, to
73+ // distinguish them from other errors
74+ : 2 ;
7275}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ cat << 'EOF' > "$TMP/schemas/schema_2.json"
2424EOF
2525
2626" $1 " metaschema " $TMP /schemas" 2> " $TMP /stderr.txt" && CODE=" $? " || CODE=" $? "
27- test " $CODE " = " 1 " || exit 1
27+ test " $CODE " = " 2 " || exit 1
2828
2929cat << EOF > "$TMP /expected.txt"
3030fail: $( realpath " $TMP " ) /schemas/schema_2.json
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ cat << 'EOF' > "$TMP/schema.json"
1515EOF
1616
1717" $1 " metaschema " $TMP /schema.json" 2> " $TMP /stderr.txt" && CODE=" $? " || CODE=" $? "
18- test " $CODE " = " 1 " || exit 1
18+ test " $CODE " = " 2 " || exit 1
1919
2020cat << EOF > "$TMP /expected.txt"
2121fail: $( realpath " $TMP " ) /schema.json
Original file line number Diff line number Diff line change 1616
1717" $1 " metaschema " $TMP /schema.json" --trace > " $TMP /output.txt" \
1818 && CODE=" $? " || CODE=" $? "
19- test " $CODE " = " 1 " || exit 1
19+ test " $CODE " = " 2 " || exit 1
2020
2121# Order of execution can vary
2222
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ type: 1
1313EOF
1414
1515" $1 " metaschema " $TMP /schema.yaml" 2> " $TMP /stderr.txt" && CODE=" $? " || CODE=" $? "
16- test " $CODE " = " 1 " || exit 1
16+ test " $CODE " = " 2 " || exit 1
1717
1818cat << EOF > "$TMP /expected.txt"
1919fail: $( realpath " $TMP " ) /schema.yaml
You can’t perform that action at this time.
0 commit comments