From: Junio C Hamano <gitster@pobox.com>
To: Brandon Casey <casey@nrlssc.navy.mil>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] test-lib.sh: work around ksh's trap shortcomings
Date: Mon, 18 Aug 2008 16:48:51 -0700 [thread overview]
Message-ID: <7vbpzplw9o.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <gPlIc7E6mNDrXE6mwaHXFoin7rDpLmjvuzlhJfCp-YmuyVK3pEzqNA@cipher.nrlssc.navy.mil> (Brandon Casey's message of "Mon, 18 Aug 2008 18:16:11 -0500")
Brandon Casey <casey@nrlssc.navy.mil> writes:
> In ksh, if trap is called within a function with 0 or EXIT as its signal,
> then the trap will be executed at the time the function returns. This
> causes a problem in the test functions since 'trap - exit' is called
> within the test_done function
Your alias test_done that calls function test_done look ugly and confusing
beyond words. Perhaps test_done() can instead set a global variable and
die() can notice it instead, like this? I haven't bothered to change the
other "trap - exit" but I think you got the idea...
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 11c0275..010bfda 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -156,10 +156,16 @@ test_count=0
test_fixed=0
test_broken=0
test_success=0
+test_exit_ok=0
die () {
- echo >&5 "FATAL: Unexpected exit with code $?"
- exit 1
+ status=$?
+ if test 1 != $test_exit_ok
+ then
+ echo >&5 "FATAL: Unexpected exit with code $status"
+ exit 1
+ fi
+ exit $status
}
trap 'die' exit
@@ -415,6 +421,7 @@ test_create_repo () {
}
test_done () {
+ test_exit_ok=1
trap - exit
test_results_dir="$TEST_DIRECTORY/test-results"
mkdir -p "$test_results_dir"
next prev parent reply other threads:[~2008-08-18 23:50 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-18 22:55 [FYI] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh Brandon Casey
2008-08-18 23:02 ` [PATCH] Makefile: add section for SGI IRIX Brandon Casey
2008-08-18 23:05 ` [PATCH] git-compat-util.h: adjust for SGI IRIX 6.5 Brandon Casey
2008-08-18 23:09 ` [PATCH] unpack-trees.c: work around run-time array initialization flaw on " Brandon Casey
2008-08-18 23:14 ` [PATCH] templates/Makefile: work around SGI install which assumes / if ROOT not defined Brandon Casey
2008-08-18 23:37 ` Junio C Hamano
2008-08-19 0:52 ` Brandon Casey
2008-08-22 0:31 ` [PATCH] templates/Makefile: install is unnecessary, just use mkdir -p Brandon Casey
2008-08-18 23:16 ` [PATCH] test-lib.sh: work around ksh's trap shortcomings Brandon Casey
2008-08-18 23:48 ` Junio C Hamano [this message]
2008-08-19 0:06 ` Brandon Casey
2008-08-19 7:39 ` Junio C Hamano
2008-08-19 14:59 ` Brandon Casey
2008-08-19 1:27 ` Brandon Casey
2008-08-20 0:19 ` Brandon Casey
2008-08-20 11:36 ` Mike Ralphson
2008-08-18 23:17 ` [PATCH] t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0' Brandon Casey
2008-08-18 23:20 ` [PATCH] t9301-fast-export.sh: don't unset config variable while we're skipping test 4 Brandon Casey
2008-08-19 0:32 ` Junio C Hamano
2008-08-19 0:39 ` Brandon Casey
2008-08-22 0:48 ` [PATCH] t9301-fast-export: move unset of config variable into its own test function Brandon Casey
2008-08-22 8:18 ` Junio C Hamano
2008-08-22 8:23 ` Junio C Hamano
2008-08-22 9:02 ` Johannes Sixt
2008-08-22 21:11 ` Junio C Hamano
2008-08-18 23:51 ` [FYI] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh Brandon Casey
2008-08-19 1:18 ` Boyd Lynn Gerber
2008-08-19 1:25 ` Brandon Casey
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=7vbpzplw9o.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=casey@nrlssc.navy.mil \
--cc=git@vger.kernel.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).