@@ -19,15 +19,16 @@ srcdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1919
2020cd " $srcdir /.." ;
2121
22+ # shellcheck disable=SC1091
2223. ./tests/utils.sh
2324
2425section " Testing validate_json.py"
2526
2627export TIMEOUT=${TIMEOUT:- 3}
2728
2829if [ $# -gt 0 ]; then
29- echo " validate_json.py $@ "
30- ./validate_json.py $@
30+ echo " validate_json.py $* "
31+ ./validate_json.py " $@ "
3132 echo
3233fi
3334
@@ -68,6 +69,7 @@ echo "testing stdin"
6869./validate_json.py - < " $data_dir /test.json"
6970./validate_json.py < " $data_dir /test.json"
7071echo " testing stdin and file mix"
72+ # shellcheck disable=SC2094
7173./validate_json.py " $data_dir /test.json" - < " $data_dir /test.json"
7274echo " testing stdin with multirecord"
7375./validate_json.py -m - < " $data_dir /multirecord.json"
@@ -89,7 +91,7 @@ check_broken(){
8991 ./validate_json.py $options " $filename "
9092 exitcode=$?
9193 set -e
92- if [ $exitcode = $expected_exitcode ]; then
94+ if [ " $exitcode " = " $expected_exitcode " ]; then
9395 echo " successfully detected broken json in '$filename ', returned exit code $exitcode "
9496 echo
9597 # elif [ $exitcode != 0 ]; then
@@ -210,17 +212,21 @@ echo "checking --permit-single-quotes mode infers multirecord single quoted json
210212echo
211213
212214echo " checking --permit-single-quotes mode works with multirecord single quoted json with mixed quoting (should result in a WARNING message)"
213- ./validate_json.py -s " $data_dir /multirecord_single_double_mixed_quotes.notjson" -m 2>&1 |
214- grep -q WARNING &&
215- echo " Found warning message" ||
216- { echo " failed to raise a WARNING message for mixed quoting" ; exit 1; }
215+ if ./validate_json.py -s " $data_dir /multirecord_single_double_mixed_quotes.notjson" -m 2>&1 | grep -q WARNING; then
216+ echo " Found warning message"
217+ else
218+ echo " failed to raise a WARNING message for mixed quoting"
219+ exit 1
220+ fi
217221echo
218222
219223echo " checking --permit-single-quotes mode infers multirecord single quoted json with mixed quoting (should result in a WARNING message)"
220- ./validate_json.py -s " $data_dir /multirecord_single_double_mixed_quotes.notjson" 2>&1 |
221- grep -q WARNING &&
222- echo " Found warning message" ||
223- { echo " failed to raise a WARNING message for mixed quoting" ; exit 1; }
224+ if ./validate_json.py -s " $data_dir /multirecord_single_double_mixed_quotes.notjson" 2>&1 | grep -q WARNING; then
225+ echo " Found warning message"
226+ else
227+ echo " failed to raise a WARNING message while inferring mixed quoting"
228+ exit 1
229+ fi
224230echo
225231
226232# ============================================================================ #
@@ -309,7 +315,7 @@ echo "checking blank content is invalid for multirecord via stdin"
309315check_broken - 2 -m < " $broken_dir /blank.json"
310316
311317echo " checking blank content is invalid for multirecord via stdin piped from /dev/null"
312- cat /dev/null | check_broken - 2 -m
318+ check_broken - 2 -m < /dev/null
313319echo
314320
315321check_broken_sample_files json
0 commit comments