diff options
Diffstat (limited to 'tests/init.sh')
-rwxr-xr-x | tests/init.sh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/init.sh b/tests/init.sh index 37fc7b62e..added1760 100755 --- a/tests/init.sh +++ b/tests/init.sh @@ -93,6 +93,19 @@ skip_ () { warn_ "$ME_: skipped test: $@"; Exit 77; } fatal_ () { warn_ "$ME_: hard error: $@"; Exit 99; } framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; } +# This is used to simplify checking of the return value +# which is useful when ensuring a command fails as desired. +# I.E. just doing `command ... &&fail=1` will not catch +# a segfault in command for example. With this helper you +# instead check an explicit exit code like +# returns_ 1 command ... || fail +returns_ () { + local exp_exit="$1" + shift + "$@" + test $? -eq $exp_exit +} + # Sanitize this shell to POSIX mode, if possible. DUALCASE=1; export DUALCASE if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then |