Re: [PATCH] test-lib: limit the output of the yes utility
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Feb 2, 2016, 08:21 UTC
- Message-ID
- <alpine.DEB.2.20.1602020907290.2964@virtualbox>
- In-Reply-To
- <56B05A95.3000808@kdbg.org>
Hi Hannes,
On Tue, 2 Feb 2016, Johannes Sixt wrote:
> On Windows, there is no SIGPIPE.
True. But we do get some sort of write failure, no? Otherwise https://github.com/git/git/commit/2b86292ed would not work...
Show 25 quoted lines
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index bd4b02e..97e6491 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -902,15 +902,15 @@ fi
> yes () {
> if test $# = 0
> then
> - y=y
> + set -- y
> else
> - y="$*"
> + set -- "$*"
> fi
> -
> - while echo "$y"
> - do
> - :
> - done
> + # we do not need an infinite supply of output for tests
> + set -- "$@" "$@" "$@" "$@" # 4
> + set -- "$@" "$@" "$@" "$@" # 16
> + set -- "$@" "$@" "$@" "$@" # 64
> + printf "%s\n" "$@"
> }I agree with the idea, but I would like to have a less intrusive patch. Something like this should do the job as well, and is a little easier on the eyes IMHO:
-- snipsnap --
diff --git a/t/test-lib.sh b/t/test-lib.sh index 32ac1a6..ae381b9 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -907,9 +907,11 @@ yes () { y="$*" fi - while echo "$y" + i=0 + while test $i -lt 99 do - : + echo "$y" + i=$(($i+1)) done }