git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Git Mailing List <git@vger.kernel.org>
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH] test-lib: limit the output of the yes utility
Date: Tue, 2 Feb 2016 08:28:21 +0100	[thread overview]
Message-ID: <56B05A95.3000808@kdbg.org> (raw)

On Windows, there is no SIGPIPE. A consequence of this is that the
upstream process of a pipe does not notice the death of the downstream
process until the pipe buffer is full and writing more data returns an
error. This behavior is the reason for an annoying delay during the
execution of t7610-mergetool.sh: There are a number of test cases where
'yes' is invoked upstream. Since the utility is basically an endless
loop it runs, on Windows, until the pipe buffer is full. This does take
a few seconds.

The test suite has its own implementation of 'yes'. Modify it to produce
only a limited amount of output that is sufficient for the test suite.
The amount chosen should be sufficiently high for any test case, assuming
that future test cases will not exaggerate their demands of input from
an upstream 'yes' invocation.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 This does not fix an error, but only an unnecessary sink of CPU cycles
 and wasted wall clock time.

 t/test-lib.sh | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

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" "$@"
 }
 
 # Fix some commands on Windows
-- 
2.7.0.118.g90056ae

             reply	other threads:[~2016-02-02  7:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02  7:28 Johannes Sixt [this message]
2016-02-02  8:21 ` [PATCH] test-lib: limit the output of the yes utility Johannes Schindelin
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=56B05A95.3000808@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    /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).