* [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function
@ 2016-04-13 5:35 Tomi Ollila
2016-04-13 5:35 ` [PATCH 2/2] test: add_email_corpus: exit early if notmuch new fails Tomi Ollila
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tomi Ollila @ 2016-04-13 5:35 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
The generic die function is now usable in future changes.
---
test/test-lib.sh | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index ac04b15a96ba..5620b8cef553 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -229,7 +229,7 @@ _die_common () {
rm -rf "$TEST_TMPDIR"
}
-die () {
+die_exit () {
_die_common
if test -n "$GIT_EXIT_OK"
then
@@ -250,10 +250,19 @@ die_signal () {
exit $code
}
+die () {
+ _die_common
+ say_color error '%-6s' FATAL
+ echo " $*"
+ echo
+ echo "Unexpected exit while executing $0."
+ exit 1
+}
+
GIT_EXIT_OK=
# Note: TEST_TMPDIR *NOT* exported!
TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX")
-trap 'die' EXIT
+trap 'die_exit' EXIT
trap 'die_signal' HUP INT TERM
test_decode_color () {
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] test: add_email_corpus: exit early if notmuch new fails
2016-04-13 5:35 [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function Tomi Ollila
@ 2016-04-13 5:35 ` Tomi Ollila
2016-04-15 12:17 ` [PATCH] test: fix die() in test-lib.sh and test-lib-common.sh Tomi Ollila
2016-05-15 13:44 ` [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function David Bremner
2 siblings, 0 replies; 4+ messages in thread
From: Tomi Ollila @ 2016-04-13 5:35 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
If notmuch new fails during email corpus addition the database is
most probably inexistent or broken and the added corpus would be
unusable while running single tests, giving misleading failures
("only" full 'make test' cleans out old corpus).
---
test/test-lib.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 5620b8cef553..668e4270135a 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -552,7 +552,7 @@ add_email_corpus ()
cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR}
else
cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}
- notmuch new >/dev/null
+ notmuch new >/dev/null || die "'notmuch new' failed while adding email corpus"
cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail
fi
}
--
2.6.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] test: fix die() in test-lib.sh and test-lib-common.sh
2016-04-13 5:35 [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function Tomi Ollila
2016-04-13 5:35 ` [PATCH 2/2] test: add_email_corpus: exit early if notmuch new fails Tomi Ollila
@ 2016-04-15 12:17 ` Tomi Ollila
2016-05-15 13:44 ` [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function David Bremner
2 siblings, 0 replies; 4+ messages in thread
From: Tomi Ollila @ 2016-04-15 12:17 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
Restoring fd was forgotten in die() implemented in test-lib.sh
(so far it did not matter as the only place die was called the
standard fd redirections were not in effect).
In scripts that include test-lib-common.sh but not test-lib.sh
the die() implementation needs to be a bit different due to
fd redirection differences. test-lib-common.sh implements die()
only if it was not implemented already.
---
test/test-lib-common.sh | 6 ++++++
test/test-lib.sh | 1 +
2 files changed, 7 insertions(+)
diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index 4e17b78..f3b00d8 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -17,6 +17,12 @@
# This file contains common code to be used by both the regular
# (correctness) tests and the performance tests.
+# test-lib.sh defines die() which echoes to nonstandard fd where
+# output was redirected earlier in that file. If test-lib.sh is not
+# loaded, neither this redirection nor die() function were defined.
+#
+type die >/dev/null 2>&1 || die () { echo "$@" >&2; exit 1; }
+
find_notmuch_path ()
{
dir="$1"
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 2951a8f..b000232 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -252,6 +252,7 @@ die_signal () {
die () {
_die_common
+ exec >&6
say_color error '%-6s' FATAL
echo " $*"
echo
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function
2016-04-13 5:35 [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function Tomi Ollila
2016-04-13 5:35 ` [PATCH 2/2] test: add_email_corpus: exit early if notmuch new fails Tomi Ollila
2016-04-15 12:17 ` [PATCH] test: fix die() in test-lib.sh and test-lib-common.sh Tomi Ollila
@ 2016-05-15 13:44 ` David Bremner
2 siblings, 0 replies; 4+ messages in thread
From: David Bremner @ 2016-05-15 13:44 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
Tomi Ollila <tomi.ollila@iki.fi> writes:
> The generic die function is now usable in future changes.
Lazy readers like me would appreciate just a bit more information about
what the difference between the old and new die() is
d
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-15 13:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-13 5:35 [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function Tomi Ollila
2016-04-13 5:35 ` [PATCH 2/2] test: add_email_corpus: exit early if notmuch new fails Tomi Ollila
2016-04-15 12:17 ` [PATCH] test: fix die() in test-lib.sh and test-lib-common.sh Tomi Ollila
2016-05-15 13:44 ` [PATCH 1/2] test-lib.sh: renamed die() to die_exit() and added generic die() function David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
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 read-only IMAP folder(s) and NNTP newsgroup(s).