git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t0005: ksh93 portability workaround
@ 2016-05-31 22:47 Junio C Hamano
  2016-05-31 22:49 ` Eric Sunshine
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Junio C Hamano @ 2016-05-31 22:47 UTC (permalink / raw)
  To: git

The test has two things ksh93 does not happy about:

 * It thinks "(( command1; command2 ) | command3)" is a perfectly
   sane way to write a pipeline.  ksh93, unlike other POSIX shells,
   does not like the two open parentheses next to each other for
   whatever reason it has.

 * It adds 256, unlike 128 that are used by other POSIX shells, to
   the signal number that caused the process to die when coming up
   with the exit status.

What is interesting is that we knew about the latter issue and had a
workaround in the test-sigchain test when verifying that SIGTERM
works OK, but we didn't have corresponding workaround for SIGPIPE.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t0005-signals.sh | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh
index e7f27eb..12b4efb 100755
--- a/t/t0005-signals.sh
+++ b/t/t0005-signals.sh
@@ -9,6 +9,16 @@ two
 one
 EOF
 
+died_with_sigpipe () {
+	case "$1" in
+	141 | 269)
+		# POSIX w/ SIGPIPE=13 gives 141
+		# ksh w/ SIGPIPE=13 gives 269
+		true ;;
+	*)	false ;;
+	esac
+}
+
 test_expect_success 'sigchain works' '
 	{ test-sigchain >actual; ret=$?; } &&
 	case "$ret" in
@@ -40,13 +50,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 ) &&
+	died_with_sigpipe "$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 ) &&
+	died_with_sigpipe "$OUT"
 '
 
 test_done

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-05-31 23:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 22:47 [PATCH] t0005: ksh93 portability workaround Junio C Hamano
2016-05-31 22:49 ` Eric Sunshine
2016-05-31 23:03 ` Jeff King
2016-05-31 23:17   ` Junio C Hamano
2016-05-31 23:04 ` [PATCH] t/lib-git-daemon: ksh " Junio C Hamano
2016-05-31 23:05   ` Jeff King

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).