]> rtime.felk.cvut.cz Git - notmuch.git/commitdiff
test: fix die() in test-lib-common.sh
authorTomi Ollila <tomi.ollila@iki.fi>
Sat, 28 May 2016 12:39:30 +0000 (15:39 +0300)
committerDavid Bremner <david@tethera.net>
Sat, 11 Jun 2016 16:03:44 +0000 (13:03 -0300)
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

index fe92cdd3ca58768b3bd0014e267ac99fb35f2d62..0fdeeb72479252618fec80a7fa62a792287d5e01 100644 (file)
 # 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"