git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: Jeff King <peff@peff.net>, Jonathan Nieder <jrnieder@gmail.com>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: [RFC/PATCH] t0081-*.sh: Fix failure of the 'long read' tests
Date: Tue, 26 Apr 2011 19:05:38 +0100	[thread overview]
Message-ID: <4DB70972.20308@ramsay1.demon.co.uk> (raw)


In particular, the subshell feeding the input pipe, using the
shell function generate_tens_of_lines(), dies early due to a
broken pipe (SIGPIPE). The test-line-buffer command reads all
of the data it needs and closes the pipe, but the generate_\
tens_of_lines() function is still attempting to write to the
pipe, since it is in an infinite loop. This causes the later
"kill $!" to fail, since the process no longer exists.

The infinite loop is caused by the loop variable increment
expression, which looks something like this:

    : $((i = $i + 1)) || return

This expression does not actually increment the loop variable
at all, so $i remains at zero, leading to the infinite loop.

A simple fix, for some shells, would be to remove the '$'
from the '$i' within the arithmetic expansion. However, some
older shells don't support assignment as part of an arithmetic
expansion. Therefore, in order to fix the problem, we replace
the loop increment expression with the simpler:

    i=$(($i + 1))

which solves the problem, while also being more portable.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

Junio,

I only remembered last night that I have been skipping some tests
on Linux (oops!); this fixes one of the failures for me. One of
the reasons for me simply skipping this test, rather than fixing
it up earlier, was that it looked like (indeed *is*) another
example of a syntax error due to using an older dash shell.
(Also, I thought there was some talk of scrapping this test).

However, when I tried bash and an up-to-date dash, the problem
changed from a syntax error to an infinite loop! ;-P

The reason for the RFC is that I don't understand why (apparently)
I'm the only person seeing this failure; I suspect that a newer
version of bash than I have does not have this problem (ie the
original arithmetic expansion actually works). dunno :-(

Also, I considered changing the kill statement thus:

    -	kill $! &&
    +	if kill -0 $! 2>/dev/null
    +	then
    +		kill $!
    +	fi &&

but I'm not sure that actually helps, and was not necessary to
fix the failure for me.

[BTW, the other tests failing for me are t4034 tests #21 (diff 
driver 'bibtex'), #25 (diff driver 'html); I haven't had time to
investigate yet]

ATB,
Ramsay Jones

 t/t0081-line-buffer.sh |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/t/t0081-line-buffer.sh b/t/t0081-line-buffer.sh
index 5067d1e..9b79e3b 100755
--- a/t/t0081-line-buffer.sh
+++ b/t/t0081-line-buffer.sh
@@ -25,8 +25,7 @@ generate_tens_of_lines () {
 		do
 			echo "$line"
 		done &&
-		: $((i = $i + 1)) ||
-		return
+		i=$(($i + 1))
 	done
 }
 
-- 
1.7.4

             reply	other threads:[~2011-04-26 18:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-26 18:05 Ramsay Jones [this message]
2011-04-26 19:35 ` [RFC/PATCH] t0081-*.sh: Fix failure of the 'long read' tests Jonathan Nieder
2011-04-30 17:12   ` Ramsay Jones
2011-04-26 23:48 ` Jeff King
2011-04-30 17:25   ` Ramsay Jones
2011-05-26  4:33     ` [PULL svn-fe/maint] " Jonathan Nieder
2011-05-26 16:03       ` Junio C Hamano

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=4DB70972.20308@ramsay1.demon.co.uk \
    --to=ramsay@ramsay1.demon.co.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=peff@peff.net \
    /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).