Re: [PATCH] test-lib: set BASH_XTRACEFD automatically

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> The patch itself is a trivial-looking one-liner, but there
> are a few subtleties worth mentioning:
>
>   - the variable is _not_ exported; the "set -x" is local to
>     our process, and so the tracefd should match
>
>   - this line has to come after we do the redirection for fd
>     4, as bash will otherwise complain during the variable
>     assignment
>
>   - likewise, we cannot ever unset this variable, as it
>     would close descriptor 4
>
>   - setting it once here is sufficient to cover both the
>     regular "-x" case (which implies "--verbose"), as well
>     as "--verbose-only=1". This works because the latter
>     flips "set -x" off and on for particular tests (if it
>     didn't, we would get tracing for all tests, as going to
>     descriptor 4 effectively circumvents the verbose flag).

Thanks.  Some of them may deserve to be next to the one-liner to
prevent people from making changes that tickle them?

> Signed-off-by: Jeff King <peff@xxxxxxxx>
> ---
>  t/README      | 6 +++---
>  t/test-lib.sh | 1 +
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/t/README b/t/README
> index 1dc908e..76a0daa 100644
> --- a/t/README
> +++ b/t/README
> @@ -84,9 +84,9 @@ appropriately before running "make".
>  
>  -x::
>  	Turn on shell tracing (i.e., `set -x`) during the tests
> -	themselves. Implies `--verbose`. Note that this can cause
> -	failures in some tests which redirect and test the
> -	output of shell functions. Use with caution.
> +	themselves. Implies `--verbose`. Note that in non-bash shells,
> +	this can cause failures in some tests which redirect and test
> +	the output of shell functions. Use with caution.
>  
>  -d::
>  --debug::
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 286c5f3..482ec11 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -321,6 +321,7 @@ then
>  else
>  	exec 4>/dev/null 3>/dev/null
>  fi
> +BASH_XTRACEFD=4
>  
>  test_failure=0
>  test_count=0
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]