git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: evgeny <illumsoft.org@gmail.com>, git@vger.kernel.org
Subject: Re: t0005-signals.sh fails with ksh
Date: Fri, 8 May 2015 16:55:48 -0400	[thread overview]
Message-ID: <20150508205548.GB13457@peff.net> (raw)
In-Reply-To: <xmqq1tiqkdue.fsf@gitster.dls.corp.google.com>

On Fri, May 08, 2015 at 01:34:49PM -0700, Junio C Hamano wrote:

> evgeny <illumsoft.org@gmail.com> writes:
> 
> > expecting success: 
> >         OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
> >         test "$OUT" -eq 141
> >
> > t0005-signals.sh[499]: eval: syntax error at line 4: `(' unmatched
> > Memory fault
> 
> Does this work if you did
> 
> 	OUT=$( ( (large_git ; echo $? 1>&3) | : ) 3>&2 ) &&
> 
> instead?

It does for me. I've tested our suite with mksh before, and it passed
(that's why the earlier check already covers ksh). But using the ksh I
get from "apt-get install ksh" on Debian (ksh93, it looks like?) fails
as described. The change above prevents the shell from crashing, and
then if we also massage the code, the test passes (i.e., the patch
below).

I'm on the fence, though, on declaring ksh93 to be unsupported. I don't
know how many other instances of this are in our test suite, and it's
one more maintenance headache to deal with. Are there really platforms
with no actual POSIX shell (on Solaris, for example, the xpg6 shell is a
much better choice)?


diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh
index e7f27eb..cbf778e 100755
--- a/t/t0005-signals.sh
+++ b/t/t0005-signals.sh
@@ -9,14 +9,23 @@ two
 one
 EOF
 
+# $1 - expected signal number
+# $2 - actual exit code
+check_signal_exit () {
+	if test "$2" = "$(($1 + 128))"; then
+		return 0; # POSIX
+	elif test "$2" = "$(($1 + 256))"; then
+		return 0; # ksh
+	elif test "$2" = 3; then
+		return 0; # Windows
+	fi
+	echo >&2 "expected death by signal $1, got exit code $2"
+	return 1
+}
+
 test_expect_success 'sigchain works' '
 	{ test-sigchain >actual; ret=$?; } &&
-	case "$ret" in
-	143) true ;; # POSIX w/ SIGTERM=15
-	271) true ;; # ksh w/ SIGTERM=15
-	  3) true ;; # Windows
-	  *) false ;;
-	esac &&
+	check_signal_exit 15 $ret &&
 	test_cmp expect actual
 '
 
@@ -40,13 +49,13 @@ test_expect_success 'create blob' '
 '
 
 test_expect_success !MINGW 'a constipated git dies with SIGPIPE' '
-	OUT=$( ((large_git; echo $? 1>&3) | :) 3>&1 ) &&
-	test "$OUT" -eq 141
+	OUT=$( ( (large_git; echo $? 1>&3) | :) 3>&1 ) &&
+	check_signal_exit 13 $OUT
 '
 
 test_expect_success !MINGW 'a constipated git dies with SIGPIPE even if parent ignores it' '
-	OUT=$( ((trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
-	test "$OUT" -eq 141
+	OUT=$( ( (trap "" PIPE; large_git; echo $? 1>&3) | :) 3>&1 ) &&
+	check_signal_exit 13 $OUT
 '
 
 test_done

  reply	other threads:[~2015-05-08 20:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08 20:15 t0005-signals.sh fails with ksh evgeny
2015-05-08 20:34 ` Junio C Hamano
2015-05-08 20:55   ` Jeff King [this message]
2015-05-08 21:14     ` Jeff King
2015-05-08 21:39       ` Junio C Hamano
2015-05-08 23:43         ` evgeny
2015-05-09  8:20         ` Andreas Schwab
2015-05-08 21:16     ` Junio C Hamano
2015-05-08 21:21       ` Jeff King
2015-05-09 20:01         ` brian m. carlson
2015-05-08 23:05   ` evgeny

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=20150508205548.GB13457@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=illumsoft.org@gmail.com \
    /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).