git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] test-lib: limit the output of the yes utility
Date: Tue, 2 Feb 2016 09:21:10 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1602020907290.2964@virtualbox> (raw)
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...

> 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
 }
 

  reply	other threads:[~2016-02-02  8:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02  7:28 [PATCH] test-lib: limit the output of the yes utility Johannes Sixt
2016-02-02  8:21 ` Johannes Schindelin [this message]
2016-02-02 18:15   ` [PATCH v2] " Johannes Sixt
2016-02-03 12:11     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1602020907290.2964@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).