From: Brandon Casey <casey@nrlssc.navy.mil>
To: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH FYI] test-lib.sh: work around ksh's trap shortcomings
Date: Mon, 18 Aug 2008 19:11:41 -0500 [thread overview]
Message-ID: <20fxFRoix9DAAeLmqmpHU-KsSuokk8Un2zipN8uZkXEQln3EHA-Paw@cipher.nrlssc.navy.mil> (raw)
In-Reply-To: <IH0MHSTEimhAN93AedvpRKq4qfzm1QA814ZYyhbSBtSdNbq8vuE6aw@cipher.nrlssc.navy.mil>
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 in order to remove the trap which calls
die() on exit. This means trap has to be called from the scripts top-level.
Do so using an alias.
Additionally, there is some strangeness with respect to aliases and
sourced script files; the alias hack doesn't work. So call 'trap - 0'
directly in lib-git-svn.sh before calling the test_done function.
---
This is the same patch I posted earlier with respect to compiling on IRIX
and Junio has suggested a more elegant solution.
-brandon
t/lib-git-svn.sh | 3 +++
t/test-lib.sh | 2 +-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index a841df2..e2e8cf3 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -3,6 +3,7 @@
if test -n "$NO_SVN_TESTS"
then
test_expect_success 'skipping git-svn tests, NO_SVN_TESTS defined' :
+ trap - exit
test_done
exit
fi
@@ -15,6 +16,7 @@ svn >/dev/null 2>&1
if test $? -ne 1
then
test_expect_success 'skipping git-svn tests, svn not found' :
+ trap - exit
test_done
exit
fi
@@ -39,6 +41,7 @@ then
err='Perl SVN libraries not found or unusable, skipping test'
fi
test_expect_success "$err" :
+ trap - exit
test_done
exit
fi
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 11c0275..6a3fc93 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -415,7 +415,6 @@ test_create_repo () {
}
test_done () {
- trap - exit
test_results_dir="$TEST_DIRECTORY/test-results"
mkdir -p "$test_results_dir"
test_results_path="$test_results_dir/${0%-*}-$$"
@@ -457,6 +456,7 @@ test_done () {
esac
}
+alias test_done='trap - exit && test_done'
# Test the binaries we have just built. The tests are kept in
# t/ subdirectory and are run in 'trash directory' subdirectory.
--
1.6.0.11.gecc7e
next prev parent reply other threads:[~2008-08-19 0:12 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-18 23:39 [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh Brandon Casey
2008-08-18 23:55 ` [PATCH] Makefile: configuration for SunOS 5.7 Brandon Casey
2008-08-18 23:57 ` [PATCH] dir.c: avoid c99 array initialization Brandon Casey
2008-08-28 15:32 ` David Kågedal
2008-08-28 15:41 ` Andreas Ericsson
2008-08-28 16:45 ` Brandon Casey
2008-08-28 18:50 ` Junio C Hamano
2008-08-28 21:01 ` Brandon Casey
2008-08-28 21:12 ` Alex Riesen
2008-08-28 21:45 ` Brandon Casey
2008-08-28 20:01 ` Alex Riesen
2008-08-28 20:16 ` Shawn O. Pearce
2008-08-28 20:21 ` Junio C Hamano
2008-08-28 22:47 ` [PATCH v2] dir.c: Avoid " Brandon Casey
2008-08-28 22:56 ` Alex Riesen
2008-08-28 23:03 ` Brandon Casey
2008-08-28 20:27 ` [PATCH] dir.c: avoid " Alex Riesen
2008-08-29 11:08 ` Johannes Schindelin
2008-08-19 0:08 ` [PATCH FYI] reset,cat-file: remove const declaration from array Brandon Casey
2008-08-19 0:11 ` Brandon Casey [this message]
2008-08-19 0:13 ` [PATCH FYI] t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0' Brandon Casey
2008-08-19 0:18 ` [PATCH FYI] Work around sed issues Brandon Casey
2008-08-19 0:20 ` [PATCH FYI] t9301-fast-export.sh: don't unset config variable while we're skipping test 4 Brandon Casey
2008-08-19 0:20 ` [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh Jeff King
2008-08-19 0:47 ` Brandon Casey
2008-08-19 2:01 ` Jeff King
2008-08-19 0:22 ` [PATCH FYI] t9700/test.pl: backwards compatibility improvements Brandon Casey
2008-09-15 11:54 ` Tom G. Christensen
2008-09-15 16:20 ` Brandon Casey
2008-09-15 16:32 ` Brandon Casey
2008-09-15 16:20 ` [PATCH 1/3] t9700/test.pl: no longer requires File::Basename Brandon Casey
2008-09-15 16:23 ` [PATCH 2/3] t9700/test.pl: avoid bareword 'STDERR' in 3-argument open() Brandon Casey
2008-09-15 16:25 ` [PATCH 3/3] t9700/test.pl: remove File::Temp requirement Brandon Casey
2008-09-15 18:27 ` Tom G. Christensen
2008-08-19 6:13 ` [FYI] How I compile on SunOS 5.7 with the SUNWspro compiler and ksh Alex Riesen
2008-08-19 15:42 ` 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=20fxFRoix9DAAeLmqmpHU-KsSuokk8Un2zipN8uZkXEQln3EHA-Paw@cipher.nrlssc.navy.mil \
--to=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).