You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tests/test_validate_json.sh
+19-11Lines changed: 19 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -64,31 +64,33 @@ echo
64
64
echo"Now trying broken / non-json files to test failure detection:"
65
65
check_broken(){
66
66
filename="$1"
67
+
expected_exitcode="${2:-2}"
67
68
set +e
68
-
./validate_json.py "$filename"${@:2}
69
-
result=$?
69
+
./validate_json.py "$filename"${@:3}
70
+
exitcode=$?
70
71
set -e
71
-
if [ $result=2 ];then
72
-
echo"successfully detected broken json in '$filename', returned exit code $result"
72
+
if [ $exitcode=$expected_exitcode ];then
73
+
echo"successfully detected broken json in '$filename', returned exit code $exitcode"
73
74
echo
74
-
#elif [ $result != 0 ]; then
75
-
# echo "returned unexpected non-zero exit code $result for broken json in '$filename'"
75
+
#elif [ $exitcode != 0 ]; then
76
+
# echo "returned unexpected non-zero exit code $exitcode for broken json in '$filename'"
76
77
# exit 1
77
78
else
78
-
echo"FAILED, returned unexpected exit code $result for broken json in '$filename'"
79
+
echo"FAILED, returned unexpected exit code $exitcode for broken json in '$filename'"
79
80
exit 1
80
81
fi
81
82
}
82
83
84
+
echo"checking normal json file breakage using --multi-record switch"
83
85
set +e
84
86
./validate_json.py - -m <"$data_dir/test.json"
85
-
result=$?
87
+
exitcode=$?
86
88
set -e
87
-
if [ $result= 2 ];then
89
+
if [ $exitcode= 2 ];then
88
90
echo"successfully detected breakage for --multi-line stdin vs normal json"
89
91
echo
90
92
else
91
-
echo"FAILED to detect breakage when feeding normal multi-line json doc to stdin with --multi-line (expecting one json doc per line)"
93
+
echo"FAILED to detect breakage when feeding normal multi-line json doc to stdin with --multi-line (expecting one json doc per line), returned unexpected exit code $exitcode"
0 commit comments