summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-02-16 17:20:39 +0000
committerPádraig Brady <P@draigBrady.com>2015-02-24 17:38:01 +0000
commit0d3024546a8d5cd0294fa3c40862e64477048c2e (patch)
treeb2767539a651ae57014c5c461d400852b6c25556 /tests
parent8be5f2c10eeb05e52cc4a33cdcd37078742ff5db (diff)
downloadgnulib-0d3024546a8d5cd0294fa3c40862e64477048c2e.tar.gz
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/init.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/init.sh b/tests/init.sh
index ac1e1a2115..9f403c51d2 100644
--- 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.