]> Savannah Git Hosting - gnulib.git/commitdiff
test-framework-sh: Fix 'returns_' to not turn off tracing permanently.
authorBruno Haible <bruno@clisp.org>
Tue, 11 Jun 2024 18:42:12 +0000 (20:42 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 13 Jun 2024 15:12:27 +0000 (17:12 +0200)
* tests/init.sh (returns_): Restore tracing if it was enabled before.

ChangeLog
tests/init.sh

index bf6a2ddcb0d4cae4d0f9fe9e25a5334665950a9e..e8d05a9c070d64f973ff31c5c38eb4a69959b388 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-06-11  Bruno Haible  <bruno@clisp.org>
+
+       test-framework-sh: Fix 'returns_' to not turn off tracing permanently.
+       * tests/init.sh (returns_): Restore tracing if it was enabled before.
+
 2024-06-09  Bruno Haible  <bruno@clisp.org>
 
        c32width tests: Avoid a test failure on Solaris 11 OpenIndiana, OmniOS.
index 6effae27c7a4d4e7099844c7ad923e359777d65c..237db02fb063e38d10ae32ff872019f764201205 100644 (file)
@@ -598,6 +598,7 @@ fi
 #   returns_ 1 command ... || fail
 returns_ () {
   # Disable tracing so it doesn't interfere with stderr of the wrapped command
+  local is_tracing=`{ :; } 2>&1`
   { set +x; } 2>/dev/null
 
   local exp_exit="$1"
@@ -605,7 +606,8 @@ returns_ () {
   "$@"
   test $? -eq $exp_exit && ret_=0 || ret_=1
 
-  if test "$VERBOSE" = yes && test "$gl_set_x_corrupts_stderr_" = false; then
+  # Restore tracing if it was enabled.
+  if test -n "$is_tracing"; then
     set -x
   fi
   { return $ret_; } 2>/dev/null