]> 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>
Tue, 11 Jun 2024 18:42:12 +0000 (20:42 +0200)
* tests/init.sh (returns_): Restore tracing if it was enabled before.

ChangeLog
tests/init.sh

index dc37db37f119f2507d0e0ed4e52ce8cc736399e9..a8d28c4765b7af6ae8206188859623d74df13c24 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-11  Paul Eggert  <eggert@cs.ucla.edu>
 
        maint: avoid duplicate tight-scope work
index 4689b6b758c27009848ef51bf7fe01db95daa205..2724f5ab6724d04b146572909b26a555c1363e5a 100644 (file)
@@ -594,6 +594,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"
@@ -601,7 +602,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