[PATCH] test: make script exit (1) if it "fails" to source (.) a file

Tomi Ollila tomi.ollila at iki.fi
Thu Aug 6 02:13:36 PDT 2015


The files (test) scripts source (with builtin command `.`) provides
information which the scripts depend, and without the `source` to
succeed allowing script to continue may lead to dangerous situations
(e.g. rm -rf "${undefined_variable}"/*).

At the end of all source (.) lines construct ' || exit 1' was added;
In our case the script script will exit if it cannot find (or read) the
file to be sourced. Additionally script would also exits if the last
command of the sourced file exited nonzero.
---


I did ./test/T050-new.sh, and in T050-new.sh there is line
`rm -rf "${MAIL_DIR}"/* "${MAIL_DIR}"/.notmuch`
as the `test-lib.sh` did not reside in notmuch root directory,
T050-new.sh could not read it -- but continued to execute that `rm`
line w/o ${MAIL_DIR} defined...
... I saw rm complaining it cannot remove files from /etc/ ... and /home/
was next. I lost almost all of my files in my $HOME directory before
I realized I have to press Ctrl-C


 devel/gen-testdb.sh                           | 2 +-
 performance-test/M00-new.sh                   | 2 +-
 performance-test/M01-dump-restore.sh          | 2 +-
 performance-test/T00-new.sh                   | 2 +-
 performance-test/T01-dump-restore.sh          | 2 +-
 performance-test/T02-tag.sh                   | 2 +-
 performance-test/perf-test-lib.sh             | 4 ++--
 test/README                                   | 2 +-
 test/T000-basic.sh                            | 2 +-
 test/T010-help-test.sh                        | 2 +-
 test/T020-compact.sh                          | 2 +-
 test/T030-config.sh                           | 2 +-
 test/T040-setup.sh                            | 2 +-
 test/T050-new.sh                              | 2 +-
 test/T060-count.sh                            | 2 +-
 test/T070-insert.sh                           | 2 +-
 test/T080-search.sh                           | 2 +-
 test/T090-search-output.sh                    | 2 +-
 test/T095-address.sh                          | 2 +-
 test/T100-search-by-folder.sh                 | 2 +-
 test/T110-search-position-overlap-bug.sh      | 2 +-
 test/T120-search-insufficient-from-quoting.sh | 2 +-
 test/T130-search-limiting.sh                  | 2 +-
 test/T140-excludes.sh                         | 2 +-
 test/T150-tagging.sh                          | 2 +-
 test/T160-json.sh                             | 2 +-
 test/T170-sexp.sh                             | 2 +-
 test/T180-text.sh                             | 2 +-
 test/T190-multipart.sh                        | 2 +-
 test/T200-thread-naming.sh                    | 2 +-
 test/T205-author-naming.sh                    | 2 +-
 test/T210-raw.sh                              | 2 +-
 test/T220-reply.sh                            | 2 +-
 test/T230-reply-to-sender.sh                  | 2 +-
 test/T240-dump-restore.sh                     | 2 +-
 test/T250-uuencode.sh                         | 2 +-
 test/T260-thread-order.sh                     | 2 +-
 test/T270-author-order.sh                     | 2 +-
 test/T280-from-guessing.sh                    | 2 +-
 test/T290-long-id.sh                          | 2 +-
 test/T300-encoding.sh                         | 2 +-
 test/T310-emacs.sh                            | 2 +-
 test/T320-emacs-large-search-buffer.sh        | 2 +-
 test/T330-emacs-subject-to-filename.sh        | 2 +-
 test/T340-maildir-sync.sh                     | 2 +-
 test/T350-crypto.sh                           | 2 +-
 test/T360-symbol-hiding.sh                    | 2 +-
 test/T370-search-folder-coherence.sh          | 2 +-
 test/T380-atomicity.sh                        | 2 +-
 test/T390-python.sh                           | 2 +-
 test/T395-ruby.sh                             | 2 +-
 test/T400-hooks.sh                            | 2 +-
 test/T410-argument-parsing.sh                 | 2 +-
 test/T420-emacs-test-functions.sh             | 2 +-
 test/T430-emacs-address-cleaning.sh           | 2 +-
 test/T440-emacs-hello.sh                      | 2 +-
 test/T450-emacs-show.sh                       | 2 +-
 test/T455-emacs-charsets.sh                   | 2 +-
 test/T460-emacs-tree.sh                       | 2 +-
 test/T470-missing-headers.sh                  | 2 +-
 test/T480-hex-escaping.sh                     | 2 +-
 test/T490-parse-time-string.sh                | 2 +-
 test/T500-search-date.sh                      | 2 +-
 test/T510-thread-replies.sh                   | 2 +-
 test/T520-show.sh                             | 2 +-
 test/T530-upgrade.sh                          | 2 +-
 test/T550-db-features.sh                      | 2 +-
 test/T560-lib-error.sh                        | 2 +-
 test/test-lib-common.sh                       | 2 +-
 test/test-lib.sh                              | 5 +++--
 test/test-verbose                             | 2 +-
 71 files changed, 74 insertions(+), 73 deletions(-)

diff --git a/devel/gen-testdb.sh b/devel/gen-testdb.sh
index 621b31e..61ae48a 100755
--- a/devel/gen-testdb.sh
+++ b/devel/gen-testdb.sh
@@ -79,7 +79,7 @@ while getopts v:c:s: opt; do
 done
 shift `expr $OPTIND - 1`
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 SHORT_CORPUS=$(basename ${CORPUS:-database})
 DBNAME=${SHORT_CORPUS}${SUFFIX}
diff --git a/performance-test/M00-new.sh b/performance-test/M00-new.sh
index 99c3f52..a040a97 100755
--- a/performance-test/M00-new.sh
+++ b/performance-test/M00-new.sh
@@ -2,7 +2,7 @@
 
 test_description='notmuch new'
 
-. ./perf-test-lib.sh
+. ./perf-test-lib.sh || exit 1
 
 # ensure initial 'notmuch new' is run by memory_start
 uncache_database
diff --git a/performance-test/M01-dump-restore.sh b/performance-test/M01-dump-restore.sh
index be5894a..8fea982 100755
--- a/performance-test/M01-dump-restore.sh
+++ b/performance-test/M01-dump-restore.sh
@@ -2,7 +2,7 @@
 
 test_description='dump and restore'
 
-. ./perf-test-lib.sh
+. ./perf-test-lib.sh || exit 1
 
 memory_start
 
diff --git a/performance-test/T00-new.sh b/performance-test/T00-new.sh
index 553bb8b..b9f2115 100755
--- a/performance-test/T00-new.sh
+++ b/performance-test/T00-new.sh
@@ -2,7 +2,7 @@
 
 test_description='notmuch new'
 
-. ./perf-test-lib.sh
+. ./perf-test-lib.sh || exit 1
 
 uncache_database
 
diff --git a/performance-test/T01-dump-restore.sh b/performance-test/T01-dump-restore.sh
index b2ff940..9cfd5cd 100755
--- a/performance-test/T01-dump-restore.sh
+++ b/performance-test/T01-dump-restore.sh
@@ -2,7 +2,7 @@
 
 test_description='dump and restore'
 
-. ./perf-test-lib.sh
+. ./perf-test-lib.sh || exit 1
 
 time_start
 
diff --git a/performance-test/T02-tag.sh b/performance-test/T02-tag.sh
index 78ceccc..dacb50b 100755
--- a/performance-test/T02-tag.sh
+++ b/performance-test/T02-tag.sh
@@ -2,7 +2,7 @@
 
 test_description='tagging'
 
-. ./perf-test-lib.sh
+. ./perf-test-lib.sh || exit 1
 
 time_start
 
diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh
index 88601fc..00d2f1c 100644
--- a/performance-test/perf-test-lib.sh
+++ b/performance-test/perf-test-lib.sh
@@ -1,4 +1,4 @@
-. ./version.sh
+. ./version.sh || exit 1
 
 corpus_size=large
 
@@ -25,7 +25,7 @@ do
 		echo "error: unknown performance test option '$1'" >&2; exit 1 ;;
 	esac
 done
-. ../test/test-lib-common.sh
+. ../test/test-lib-common.sh || exit 1
 
 set -e
 
diff --git a/test/README b/test/README
index daf4160..ce403ce 100644
--- a/test/README
+++ b/test/README
@@ -138,7 +138,7 @@ Source 'test-lib.sh'
 After assigning test_description, the test script should source
 test-lib.sh like this:
 
-	. ./test-lib.sh
+	. ./test-lib.sh || exit 1
 
 This test harness library does the following things:
 
diff --git a/test/T000-basic.sh b/test/T000-basic.sh
index ef64245..d6811bd 100755
--- a/test/T000-basic.sh
+++ b/test/T000-basic.sh
@@ -14,7 +14,7 @@ then
 	exit 1
 fi
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 ################################################################
 # Test harness
diff --git a/test/T010-help-test.sh b/test/T010-help-test.sh
index d7266ff..c173237 100755
--- a/test/T010-help-test.sh
+++ b/test/T010-help-test.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="online help"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_expect_success 'notmuch --help' 'notmuch --help'
 test_expect_success 'notmuch help' 'notmuch help'
diff --git a/test/T020-compact.sh b/test/T020-compact.sh
index 507f769..8b4dbbc 100755
--- a/test/T020-compact.sh
+++ b/test/T020-compact.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch compact"'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_message '[subject]=One'
 add_message '[subject]=Two'
diff --git a/test/T030-config.sh b/test/T030-config.sh
index 7d14a85..f404908 100755
--- a/test/T030-config.sh
+++ b/test/T030-config.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description='"notmuch config"'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Get string value"
 test_expect_equal "$(notmuch config get user.name)" "Notmuch Test Suite"
diff --git a/test/T040-setup.sh b/test/T040-setup.sh
index 0e9f279..cf0c00b 100755
--- a/test/T040-setup.sh
+++ b/test/T040-setup.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description='"notmuch setup"'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Notmuch new without a config suggests notmuch setup"
 output=$(notmuch --config=new-notmuch-config new 2>&1)
diff --git a/test/T050-new.sh b/test/T050-new.sh
index ff1c354..6257392 100755
--- a/test/T050-new.sh
+++ b/test/T050-new.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch new" in several variations'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "No new messages"
 output=$(NOTMUCH_NEW --debug)
diff --git a/test/T060-count.sh b/test/T060-count.sh
index da86c8c..5ef3879 100755
--- a/test/T060-count.sh
+++ b/test/T060-count.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch count" for messages and threads'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T070-insert.sh b/test/T070-insert.sh
index 7e71c3b..e7ec6a6 100755
--- a/test/T070-insert.sh
+++ b/test/T070-insert.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch insert"'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_require_external_prereq gdb
 
diff --git a/test/T080-search.sh b/test/T080-search.sh
index 05027fb..5e8b20c 100755
--- a/test/T080-search.sh
+++ b/test/T080-search.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch search" in several variations'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T090-search-output.sh b/test/T090-search-output.sh
index fe2ec9a..a28eaf2 100755
--- a/test/T090-search-output.sh
+++ b/test/T090-search-output.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='various settings for "notmuch search --output="'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T095-address.sh b/test/T095-address.sh
index ed0cac7..8eecb2a 100755
--- a/test/T095-address.sh
+++ b/test/T095-address.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch address" in several variants'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T100-search-by-folder.sh b/test/T100-search-by-folder.sh
index 583bdf5..2844ec6 100755
--- a/test/T100-search-by-folder.sh
+++ b/test/T100-search-by-folder.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch search" by folder: and path: (with variations)'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_message '[dir]=bad' '[subject]="To the bone"'
 add_message '[dir]=.' '[subject]="Top level"'
diff --git a/test/T110-search-position-overlap-bug.sh b/test/T110-search-position-overlap-bug.sh
index 5da6ad6..2a4238f 100755
--- a/test/T110-search-position-overlap-bug.sh
+++ b/test/T110-search-position-overlap-bug.sh
@@ -18,7 +18,7 @@
 # id:3wd4o8wa7fx.fsf at testarossa.amd.com
 
 test_description='that notmuch does not overlap term positions'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_message '[to]="a at b.c, x at y.z"'
 
diff --git a/test/T120-search-insufficient-from-quoting.sh b/test/T120-search-insufficient-from-quoting.sh
index e83ea3d..4862d82 100755
--- a/test/T120-search-insufficient-from-quoting.sh
+++ b/test/T120-search-insufficient-from-quoting.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='messages with unquoted . in name'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_message \
   '[from]="Some.Name for Someone <bugs at quoting.com>"' \
diff --git a/test/T130-search-limiting.sh b/test/T130-search-limiting.sh
index 303762c..c8986f4 100755
--- a/test/T130-search-limiting.sh
+++ b/test/T130-search-limiting.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch search" --offset and --limit parameters'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T140-excludes.sh b/test/T140-excludes.sh
index 8bbbc2d..f91d4d7 100755
--- a/test/T140-excludes.sh
+++ b/test/T140-excludes.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch search, count and show" with excludes in several variations'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 # Generates a thread consisting of a top level message and 'length'
 # replies. The subject of the top message 'subject: top message"
diff --git a/test/T150-tagging.sh b/test/T150-tagging.sh
index 4a2673d..821d393 100755
--- a/test/T150-tagging.sh
+++ b/test/T150-tagging.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='"notmuch tag"'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_message '[subject]=One'
 add_message '[subject]=Two'
diff --git a/test/T160-json.sh b/test/T160-json.sh
index c1cf649..b346f37 100755
--- a/test/T160-json.sh
+++ b/test/T160-json.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="--format=json output"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Show message: json"
 add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc at notmuchmail.org\"" "[reply-to]=\"test_suite+replyto at notmuchmail.org\"" "[body]=\"json-show-message\""
diff --git a/test/T170-sexp.sh b/test/T170-sexp.sh
index 667e319..800ebc6 100755
--- a/test/T170-sexp.sh
+++ b/test/T170-sexp.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="--format=sexp output"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Show message: sexp"
 add_message "[subject]=\"sexp-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[bcc]=\"test_suite+bcc at notmuchmail.org\"" "[reply-to]=\"test_suite+replyto at notmuchmail.org\"" "[body]=\"sexp-show-message\""
diff --git a/test/T180-text.sh b/test/T180-text.sh
index b5ccefc..3a265db 100755
--- a/test/T180-text.sh
+++ b/test/T180-text.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="--format=text output"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Show message: text"
 add_message "[subject]=\"text-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"text-show-message\""
diff --git a/test/T190-multipart.sh b/test/T190-multipart.sh
index ad8d29e..7c4c9f7 100755
--- a/test/T190-multipart.sh
+++ b/test/T190-multipart.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="output of multipart message"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 cat <<EOF > embedded_message
 From: Carl Worth <cworth at cworth.org>
diff --git a/test/T200-thread-naming.sh b/test/T200-thread-naming.sh
index dcfc1b3..132c1d7 100755
--- a/test/T200-thread-naming.sh
+++ b/test/T200-thread-naming.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="naming of threads with changing subject"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Initial thread name (oldest-first search)"
 add_message '[subject]="thread-naming: Initial thread subject"' \
diff --git a/test/T205-author-naming.sh b/test/T205-author-naming.sh
index cb678ae..69d8dc5 100755
--- a/test/T205-author-naming.sh
+++ b/test/T205-author-naming.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="naming of authors with unusual addresses"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Add author with empty quoted real name"
 add_message '[subject]="author-naming: Initial thread subject"' \
diff --git a/test/T210-raw.sh b/test/T210-raw.sh
index daf5735..dfea2d1 100755
--- a/test/T210-raw.sh
+++ b/test/T210-raw.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description='notmuch show --format=raw'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_message
 add_message
diff --git a/test/T220-reply.sh b/test/T220-reply.sh
index b0d854a..30b78f6 100755
--- a/test/T220-reply.sh
+++ b/test/T220-reply.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="\"notmuch reply\" in several variations"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Basic reply"
 add_message '[from]="Sender <sender at example.com>"' \
diff --git a/test/T230-reply-to-sender.sh b/test/T230-reply-to-sender.sh
index 30e5e38..608334d 100755
--- a/test/T230-reply-to-sender.sh
+++ b/test/T230-reply-to-sender.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="\"notmuch reply --reply-to=sender\" in several variations"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Basic reply-to-sender"
 add_message '[from]="Sender <sender at example.com>"' \
diff --git a/test/T240-dump-restore.sh b/test/T240-dump-restore.sh
index efe463e..e6976ff 100755
--- a/test/T240-dump-restore.sh
+++ b/test/T240-dump-restore.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="\"notmuch dump\" and \"notmuch restore\""
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T250-uuencode.sh b/test/T250-uuencode.sh
index b3e1ac1..6f45d39 100755
--- a/test/T250-uuencode.sh
+++ b/test/T250-uuencode.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="handling of uuencoded data"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
 '[body]="This message is used to ensure that notmuch correctly handles a
diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh
index 5239bd4..f720c99 100755
--- a/test/T260-thread-order.sh
+++ b/test/T260-thread-order.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="threading when messages received out of order"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 # Generate all single-root four message thread structures.  We'll use
 # this for multiple tests below.
diff --git a/test/T270-author-order.sh b/test/T270-author-order.sh
index 6ffeffc..9124ece 100755
--- a/test/T270-author-order.sh
+++ b/test/T270-author-order.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="author reordering;"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Adding parent message"
 generate_message [body]=findme [id]=new-parent-id [subject]=author-reorder-threadtest '[from]="User <user at example.com>"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
diff --git a/test/T280-from-guessing.sh b/test/T280-from-guessing.sh
index 6dfaa40..7c562fb 100755
--- a/test/T280-from-guessing.sh
+++ b/test/T280-from-guessing.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="From line heuristics (with multiple configured addresses)"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Magic from guessing (nothing to go on)"
 add_message '[from]="Sender <sender at example.com>"' \
diff --git a/test/T290-long-id.sh b/test/T290-long-id.sh
index 85e620f..1fb7c03 100755
--- a/test/T290-long-id.sh
+++ b/test/T290-long-id.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="messages with ridiculously-long message IDs"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Referencing long ID before adding"
 generate_message '[subject]="Reference of ridiculously-long message ID"' \
diff --git a/test/T300-encoding.sh b/test/T300-encoding.sh
index b6c86bf..8d201c7 100755
--- a/test/T300-encoding.sh
+++ b/test/T300-encoding.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="encoding issues"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Message with text of unknown charset"
 add_message '[content-type]="text/plain; charset=unknown-8bit"' \
diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh
index d72799b..61bc369 100755
--- a/test/T310-emacs.sh
+++ b/test/T310-emacs.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs interface"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
 
diff --git a/test/T320-emacs-large-search-buffer.sh b/test/T320-emacs-large-search-buffer.sh
index 8b1251f..3fd6958 100755
--- a/test/T320-emacs-large-search-buffer.sh
+++ b/test/T320-emacs-large-search-buffer.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="Emacs with large search results buffer"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 x=xxxxxxxxxx # 10
 x=$x$x$x$x$x$x$x$x$x$x # 100
diff --git a/test/T330-emacs-subject-to-filename.sh b/test/T330-emacs-subject-to-filename.sh
index 230c324..517fa83 100755
--- a/test/T330-emacs-subject-to-filename.sh
+++ b/test/T330-emacs-subject-to-filename.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs: mail subject to filename"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 # emacs server can't be started in a child process with $(test_emacs ...)
 test_emacs '(ignore)' > /dev/null
diff --git a/test/T340-maildir-sync.sh b/test/T340-maildir-sync.sh
index 3186e70..efeaa3f 100755
--- a/test/T340-maildir-sync.sh
+++ b/test/T340-maildir-sync.sh
@@ -2,7 +2,7 @@
 
 test_description="maildir synchronization"
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 # Create the expected maildir structure
 mkdir $MAIL_DIR/cur
diff --git a/test/T350-crypto.sh b/test/T350-crypto.sh
index 477b397..3656cce 100755
--- a/test/T350-crypto.sh
+++ b/test/T350-crypto.sh
@@ -5,7 +5,7 @@
 # - verification of signatures from expired/revoked keys
 
 test_description='PGP/MIME signature verification and decryption'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_gnupg_home ()
 {
diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh
index 98e4d4d..4ec0ea6 100755
--- a/test/T360-symbol-hiding.sh
+++ b/test/T360-symbol-hiding.sh
@@ -9,7 +9,7 @@
 
 test_description='exception symbol hiding'
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest 'running test' run_test
 mkdir -p ${PWD}/fakedb/.notmuch
diff --git a/test/T370-search-folder-coherence.sh b/test/T370-search-folder-coherence.sh
index 5e72a6c..da4ec2b 100755
--- a/test/T370-search-folder-coherence.sh
+++ b/test/T370-search-folder-coherence.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='folder tags removed and added through file renames remain consistent'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "No new messages"
 output=$(NOTMUCH_NEW)
diff --git a/test/T380-atomicity.sh b/test/T380-atomicity.sh
index ee1e2f4..845dfde 100755
--- a/test/T380-atomicity.sh
+++ b/test/T380-atomicity.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='atomicity'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 # This script tests the effects of killing and restarting "notmuch
 # new" at arbitrary points.  If notmuch new is properly atomic, the
diff --git a/test/T390-python.sh b/test/T390-python.sh
index c3f24f7..4726bc3 100755
--- a/test/T390-python.sh
+++ b/test/T390-python.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="python bindings"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_require_external_prereq ${NOTMUCH_PYTHON}
 
diff --git a/test/T395-ruby.sh b/test/T395-ruby.sh
index 8b8e6d2..d5cade8 100755
--- a/test/T395-ruby.sh
+++ b/test/T395-ruby.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="ruby bindings"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 if [ "${NOTMUCH_HAVE_RUBY_DEV}" = "0" ]; then
     test_subtest_missing_external_prereq_["ruby development files"]=t
diff --git a/test/T400-hooks.sh b/test/T400-hooks.sh
index 1adab2f..ed11913 100755
--- a/test/T400-hooks.sh
+++ b/test/T400-hooks.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='hooks'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 HOOK_DIR=${MAIL_DIR}/.notmuch/hooks
 
diff --git a/test/T410-argument-parsing.sh b/test/T410-argument-parsing.sh
index 2e5d7ae..f8ff8ff 100755
--- a/test/T410-argument-parsing.sh
+++ b/test/T410-argument-parsing.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="argument parsing"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "sanity check"
 $TEST_DIRECTORY/arg-test  pos1  --keyword=one --string=foo pos2 --int=7 --flag=one --flag=three > OUTPUT
diff --git a/test/T420-emacs-test-functions.sh b/test/T420-emacs-test-functions.sh
index ca4a798..955c5f7 100755
--- a/test/T420-emacs-test-functions.sh
+++ b/test/T420-emacs-test-functions.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs test function sanity"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "emacs test function sanity"
 test_emacs_expect_t 't'
diff --git a/test/T430-emacs-address-cleaning.sh b/test/T430-emacs-address-cleaning.sh
index 0472346..664b79d 100755
--- a/test/T430-emacs-address-cleaning.sh
+++ b/test/T430-emacs-address-cleaning.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs address cleaning"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "notmuch-test-address-clean part 1"
 test_emacs_expect_t '(notmuch-test-address-cleaning-1)'
diff --git a/test/T440-emacs-hello.sh b/test/T440-emacs-hello.sh
index f729616..a8ed228 100755
--- a/test/T440-emacs-hello.sh
+++ b/test/T440-emacs-hello.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs notmuch-hello view"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
 
diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index bfcd5ef..0342a87 100755
--- a/test/T450-emacs-show.sh
+++ b/test/T450-emacs-show.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs notmuch-show view"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 EXPECTED=$TEST_DIRECTORY/emacs-show.expected-output
 
diff --git a/test/T455-emacs-charsets.sh b/test/T455-emacs-charsets.sh
index 3078f9c..7624fa4 100755
--- a/test/T455-emacs-charsets.sh
+++ b/test/T455-emacs-charsets.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs notmuch-show charset handling"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 
 UTF8_YEN=$'\xef\xbf\xa5'
diff --git a/test/T460-emacs-tree.sh b/test/T460-emacs-tree.sh
index 8e9f37c..b6181b5 100755
--- a/test/T460-emacs-tree.sh
+++ b/test/T460-emacs-tree.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
 test_description="emacs tree view interface"
-. test-lib.sh
+. ./test-lib.sh || exit 1
 
 EXPECTED=$TEST_DIRECTORY/tree.expected-output
 
diff --git a/test/T470-missing-headers.sh b/test/T470-missing-headers.sh
index cb38301..e256c10 100755
--- a/test/T470-missing-headers.sh
+++ b/test/T470-missing-headers.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description='messages with missing headers'
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 # Notmuch requires at least one of from, subject, or to or it will
 # ignore the file.  Generate two messages so that together they cover
diff --git a/test/T480-hex-escaping.sh b/test/T480-hex-escaping.sh
index ad50e1b..10527b1 100755
--- a/test/T480-hex-escaping.sh
+++ b/test/T480-hex-escaping.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="hex encoding and decoding"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "round trip"
 find $TEST_DIRECTORY/corpus -type f -print | sort | xargs cat > EXPECTED
diff --git a/test/T490-parse-time-string.sh b/test/T490-parse-time-string.sh
index 6aa9d43..ab90fcc 100755
--- a/test/T490-parse-time-string.sh
+++ b/test/T490-parse-time-string.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="date/time parser module"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 # Sanity/smoke tests for the date/time parser independent of notmuch
 
diff --git a/test/T500-search-date.sh b/test/T500-search-date.sh
index 70bcf34..b28496b 100755
--- a/test/T500-search-date.sh
+++ b/test/T500-search-date.sh
@@ -1,6 +1,6 @@
 #!/usr/bin/env bash
 test_description="date:since..until queries"
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T510-thread-replies.sh b/test/T510-thread-replies.sh
index 1392fbe..5ab066a 100755
--- a/test/T510-thread-replies.sh
+++ b/test/T510-thread-replies.sh
@@ -9,7 +9,7 @@ test_description='test of proper handling of in-reply-to and references headers'
 # database is constructed properly, even in the presence of
 # non-RFC-compliant headers'
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "Use References when In-Reply-To is broken"
 add_message '[id]="foo at one.com"' \
diff --git a/test/T520-show.sh b/test/T520-show.sh
index 0657c99..fb232a3 100755
--- a/test/T520-show.sh
+++ b/test/T520-show.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description='"notmuch show"'
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 add_email_corpus
 
diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh
index 6b42a69..7faf03d 100755
--- a/test/T530-upgrade.sh
+++ b/test/T530-upgrade.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="database upgrade"
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 dbtarball=database-v1.tar.xz
 
diff --git a/test/T550-db-features.sh b/test/T550-db-features.sh
index 5569768..f94a660 100755
--- a/test/T550-db-features.sh
+++ b/test/T550-db-features.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="database version and feature compatibility"
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_begin_subtest "future database versions abort open"
 ${TEST_DIRECTORY}/make-db-version ${MAIL_DIR} 9999 ""
diff --git a/test/T560-lib-error.sh b/test/T560-lib-error.sh
index b1e77aa..1ef4ff2 100755
--- a/test/T560-lib-error.sh
+++ b/test/T560-lib-error.sh
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 test_description="error reporting for library"
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 backup_database () {
     rm -rf notmuch-dir-backup
diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh
index f99ed11..b1fc33d 100644
--- a/test/test-lib-common.sh
+++ b/test/test-lib-common.sh
@@ -40,7 +40,7 @@ TEST_DIRECTORY=$(pwd)
 notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"`
 
 # configure output
-. $notmuch_path/sh.config
+. $notmuch_path/sh.config || exit 1
 
 if test -n "$valgrind"
 then
diff --git a/test/test-lib.sh b/test/test-lib.sh
index db3b6aa..a1620e5 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -96,7 +96,8 @@ _x32="$_x04$_x04$_x04$_x04$_x04$_x04$_x04$_x04"
 # test_description='Description of this test...
 # This test checks if command xyzzy does the right thing...
 # '
-# . ./test-lib.sh
+# . ./test-lib.sh || exit 1
+
 [ "x$ORIGINAL_TERM" != "xdumb" ] && (
 		TERM=$ORIGINAL_TERM &&
 		export TERM &&
@@ -1223,7 +1224,7 @@ test_init_ () {
 }
 
 
-. ./test-lib-common.sh
+. ./test-lib-common.sh || exit 1
 
 emacs_generate_script
 
diff --git a/test/test-verbose b/test/test-verbose
index 4100c05..1723ce6 100755
--- a/test/test-verbose
+++ b/test/test-verbose
@@ -2,7 +2,7 @@
 
 test_description='the verbosity options of the test framework itself.'
 
-. ./test-lib.sh
+. ./test-lib.sh || exit 1
 
 test_expect_success 'print something in test_expect_success and pass' '
   echo "hello stdout" &&
-- 
2.4.1



More information about the notmuch mailing list