From: Bruno Haible Date: Tue, 11 Jun 2024 18:42:12 +0000 (+0200) Subject: test-framework-sh: Fix 'returns_' to not turn off tracing permanently. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=277d259de1617d0cb7dc5d75f9287a117024ef94;p=gnulib.git test-framework-sh: Fix 'returns_' to not turn off tracing permanently. * tests/init.sh (returns_): Restore tracing if it was enabled before. --- diff --git a/ChangeLog b/ChangeLog index dc37db37f1..a8d28c4765 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2024-06-11 Bruno Haible + + 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 maint: avoid duplicate tight-scope work diff --git a/tests/init.sh b/tests/init.sh index 4689b6b758..2724f5ab67 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -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