]> Savannah Git Hosting - gnulib.git/commitdiff
tests: support stderr verification with returns_()
authorPádraig Brady <P@draigBrady.com>
Mon, 16 Feb 2015 17:20:39 +0000 (17:20 +0000)
committerPádraig Brady <P@draigBrady.com>
Tue, 24 Feb 2015 17:38:01 +0000 (17:38 +0000)
* 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.

ChangeLog
tests/init.sh

index 47b3b032700e833fa14b3c2c868c4d07d3a8ecae..2262efad907a74989208a7699f67f5d0cf73f6ef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2015-02-24  Pádraig Brady  <P@draigBrady.com>
+
+       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.
+
 2015-02-24  Pavel Hrdina  <phrdina@redhat.com>
 
        passfd: avoid valgrind uninitalised data warning
index ac1e1a21154b538dfbe1d92000cf94ca70279215..9f403c51d2ed9cd0f85f492df721df97c573d65b 100644 (file)
@@ -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.