diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/setup | 2 | ||||
-rwxr-xr-x | tests/shtest | 33 |
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/setup b/tests/setup index 94bcf1eb..9ce382ba 100755 --- a/tests/setup +++ b/tests/setup @@ -15,9 +15,11 @@ JQ=$JQBASEDIR/jq if [ -z "${NO_VALGRIND-}" ] && which valgrind > /dev/null; then VALGRIND="valgrind --error-exitcode=1 --leak-check=full \ --suppressions=$JQTESTDIR/onig.supp" + VG_EXIT0=--error-exitcode=0 Q=-q else VALGRIND= + VG_EXIT0= Q= fi diff --git a/tests/shtest b/tests/shtest index 9a17aea4..cec1fc59 100755 --- a/tests/shtest +++ b/tests/shtest @@ -211,4 +211,37 @@ if ! $VALGRIND $Q $JQ -L tests/modules -ne 'import "test_bind_order" as check; c exit 1 fi +## Halt + +if ! $VALGRIND $Q $JQ -n halt; then + echo "jq halt didn't work as expected" 1>&2 + exit 1 +fi +if $VALGRIND $Q $VG_EXIT0 $JQ -n 'halt_error(1)'; then + echo "jq halt_error(1) didn't work as expected" 1>&2 + exit 1 +elif [ $? -ne 1 ]; then + echo "jq halt_error(1) had wrong error code" 1>&2 + exit 1 +fi +if $VALGRIND $Q $VG_EXIT0 $JQ -n 'halt_error(11)'; then + echo "jq halt_error(11) didn't work as expected" 1>&2 + exit 1 +elif [ $? -ne 11 ]; then + echo "jq halt_error(11) had wrong error code" 1>&2 + exit 1 +fi +if [ -n "`$VALGRIND $Q $JQ -n 'halt_error(1)' 2>&1`" ]; then + echo "jq halt_error(1) had unexpected output" 1>&2 + exit 1 +fi +if [ -n "`$VALGRIND $Q $JQ -n '"xyz\n"|halt_error(1)' 2>/dev/null`" ]; then + echo "jq halt_error(1) had unexpected output on stdout" 1>&2 + exit 1 +fi +if [ "`$VALGRIND $Q $JQ -n '"xyz\n"|halt_error(1)' 2>&1`" != xyz ]; then + echo "jq halt_error(1) had unexpected output" 1>&2 + exit 1 +fi + exit 0 |