From: Pádraig Brady Date: Mon, 16 Feb 2015 17:20:39 +0000 (+0000) Subject: tests: support stderr verification with returns_() X-Git-Tag: v8.24~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ced120406f47584eb672f9731d5fee0e62761c0c;p=thirdparty%2Fcoreutils.git tests: support stderr verification with returns_() * tests/init.sh (returns_): Disable tracing for this wrapper function, so that stderr of the wrapped command is unchanged, allowing for verification of the contents. --- diff --git a/tests/init.sh b/tests/init.sh index ac1e1a2115..9f403c51d2 100755 --- a/tests/init.sh +++ b/tests/init.sh @@ -100,10 +100,18 @@ framework_failure_ () { warn_ "$ME_: set-up failure: $@"; Exit 99; } # instead check an explicit exit code like # returns_ 1 command ... || fail returns_ () { + # Disable tracing so it doesn't interfere with stderr of the wrapped command + { set +x; } 2>/dev/null + local exp_exit="$1" shift "$@" - test $? -eq $exp_exit + test $? -eq $exp_exit && ret_=0 || ret_=1 + + if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then + set -x + fi + { return $ret_; } 2>/dev/null } # Sanitize this shell to POSIX mode, if possible.