--- /dev/null
+Return-Path: <too@guru-group.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 01A466DE1502\r
+ for <notmuch@notmuchmail.org>; Thu, 3 Sep 2015 12:11:32 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.215\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.215 tagged_above=-999 required=5 tests=[AWL=0.755, \r
+ RP_MATCHES_RCVD=-0.55, T_HEADER_FROM_DIFFERENT_DOMAINS=0.01]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id 1KF7CbfJxemo for <notmuch@notmuchmail.org>;\r
+ Thu, 3 Sep 2015 12:11:29 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 1503D6DE1479\r
+ for <notmuch@notmuchmail.org>; Thu, 3 Sep 2015 12:11:29 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+ id B959C10019C; Thu, 3 Sep 2015 22:09:57 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] test: add "set -u" to test-lib.sh\r
+Date: Thu, 3 Sep 2015 22:09:55 +0300\r
+Message-Id: <1441307395-2218-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 2.0.0\r
+Cc: tomi.ollila@iki.fi\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.18\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 03 Sep 2015 19:11:32 -0000\r
+\r
+This prohibits unset variables to expand to empty strings.\r
+Without this e.g misspelled variables cause unintentional results.\r
+\r
+Now all the test variables are either initialized, or in case of\r
+optional arguments and user-provided environment variables the\r
+form ${variable-} is used.\r
+\r
+Two unusable lines (leftovers?) in T360-symbol-hiding.sh were removed;\r
+this was the only non-lib test code that needed to be edited for this\r
+change to work.\r
+---\r
+ test/T360-symbol-hiding.sh | 3 ---\r
+ test/test-lib.sh | 63 ++++++++++++++++++++++++++--------------------\r
+ 2 files changed, 36 insertions(+), 30 deletions(-)\r
+\r
+diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh\r
+index 4ec0ea6..1e6814b 100755\r
+--- a/test/T360-symbol-hiding.sh\r
++++ b/test/T360-symbol-hiding.sh\r
+@@ -23,9 +23,6 @@ caught No chert database found at path \`CWD/nonexistent'\r
+ EOF\r
+ test_expect_equal_file EXPECTED OUTPUT\r
+ \r
+-test_begin_subtest 'checking output'\r
+-test_expect_equal "$result" "$output"\r
+-\r
+ test_begin_subtest 'comparing existing to exported symbols'\r
+ nm -P $TEST_DIRECTORY/../lib/libnotmuch.so | awk '$2 == "T" && $1 ~ "^notmuch" {print $1}' | sort | uniq > ACTUAL\r
+ sed -n 's/[[:blank:]]*\(notmuch_[^;]*\);/\1/p' $TEST_DIRECTORY/../notmuch.sym | sort | uniq > EXPORTED\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 126911f..c85d149 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -22,6 +22,9 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then\r
+ exit 1\r
+ fi\r
+ \r
++# Make sure misspelled variables are not to be expanded to empty strings.\r
++set -u\r
++\r
+ # Make sure echo builtin does not expand backslash-escape sequences by default.\r
+ shopt -u xpg_echo\r
+ \r
+@@ -31,7 +34,7 @@ this_test_bare=${this_test#T[0-9][0-9][0-9]-}\r
+ \r
+ # if --tee was passed, write the output not only to the terminal, but\r
+ # additionally to the file test-results/$BASENAME.out, too.\r
+-case "$GIT_TEST_TEE_STARTED, $* " in\r
++case "${GIT_TEST_TEE_STARTED-}, $* " in\r
+ done,*)\r
+ # do not redirect again\r
+ ;;\r
+@@ -66,8 +69,8 @@ TZ=UTC\r
+ TERM=dumb\r
+ export LANG LC_ALL PAGER TERM TZ\r
+ GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}\r
+-if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \\r
+- ( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then\r
++if [[ ( -n "${TEST_EMACS-}" && -z "${TEST_EMACSCLIENT-}" ) || \\r
++ ( -z "${TEST_EMACS-}" && -n "${TEST_EMACSCLIENT-}" ) ]]; then\r
+ echo "error: must specify both or neither of TEST_EMACS and TEST_EMACSCLIENT" >&2\r
+ exit 1\r
+ fi\r
+@@ -98,6 +101,9 @@ _x32="$_x04$_x04$_x04$_x04$_x04$_x04$_x04$_x04"\r
+ # '\r
+ # . ./test-lib.sh || exit 1\r
+ \r
++debug= immediate= GIT_TEST_LONG= help= verbose= quiet= with_dashes=\r
++color= valgrind= verbose= root=\r
++\r
+ [ "x$ORIGINAL_TERM" != "xdumb" ] && (\r
+ TERM=$ORIGINAL_TERM &&\r
+ export TERM &&\r
+@@ -208,7 +214,7 @@ print_test_description ()\r
+ echo $this_test: "Testing ${test_description}"\r
+ test_description_printed=1\r
+ }\r
+-if [ -z "$NOTMUCH_TEST_QUIET" ]\r
++if [ -z "${NOTMUCH_TEST_QUIET-}" ]\r
+ then\r
+ print_test_description\r
+ fi\r
+@@ -331,6 +337,7 @@ remove_cr () {\r
+ gen_msg_cnt=0\r
+ gen_msg_filename=""\r
+ gen_msg_id=""\r
++test_subtest_name=\r
+ generate_message ()\r
+ {\r
+ # This is our (bash-specific) magic for doing named parameters\r
+@@ -338,38 +345,38 @@ generate_message ()\r
+ local additional_headers\r
+ \r
+ gen_msg_cnt=$((gen_msg_cnt + 1))\r
+- if [ -z "${template[filename]}" ]; then\r
++ if [ -z "${template[filename]-}" ]; then\r
+ gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)"\r
+ else\r
+ gen_msg_name=${template[filename]}\r
+ fi\r
+ \r
+- if [ -z "${template[id]}" ]; then\r
++ if [ -z "${template[id]-}" ]; then\r
+ gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"\r
+ else\r
+ gen_msg_id="${template[id]}"\r
+ fi\r
+ \r
+- if [ -z "${template[dir]}" ]; then\r
++ if [ -z "${template[dir]-}" ]; then\r
+ gen_msg_filename="${MAIL_DIR}/$gen_msg_name"\r
+ else\r
+ gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"\r
+ mkdir -p "$(dirname "$gen_msg_filename")"\r
+ fi\r
+ \r
+- if [ -z "${template[body]}" ]; then\r
++ if [ -z "${template[body]-}" ]; then\r
+ template[body]="This is just a test message (#${gen_msg_cnt})"\r
+ fi\r
+ \r
+- if [ -z "${template[from]}" ]; then\r
++ if [ -z "${template[from]-}" ]; then\r
+ template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"\r
+ fi\r
+ \r
+- if [ -z "${template[to]}" ]; then\r
++ if [ -z "${template[to]-}" ]; then\r
+ template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"\r
+ fi\r
+ \r
+- if [ -z "${template[subject]}" ]; then\r
++ if [ -z "${template[subject]-}" ]; then\r
+ if [ -n "$test_subtest_name" ]; then\r
+ template[subject]="$test_subtest_name"\r
+ else\r
+@@ -379,7 +386,7 @@ generate_message ()\r
+ template[subject]=""\r
+ fi\r
+ \r
+- if [ -z "${template[date]}" ]; then\r
++ if [ -z "${template[date]-}" ]; then\r
+ # we use decreasing timestamps here for historical reasons;\r
+ # the existing test suite when we converted to unique timestamps just\r
+ # happened to have signicantly fewer failures with that choice.\r
+@@ -392,42 +399,42 @@ generate_message ()\r
+ fi\r
+ \r
+ additional_headers=""\r
+- if [ ! -z "${template[header]}" ]; then\r
++ if [ ! -z "${template[header]-}" ]; then\r
+ additional_headers="${template[header]}\r
+ ${additional_headers}"\r
+ fi\r
+ \r
+- if [ ! -z "${template[reply-to]}" ]; then\r
++ if [ ! -z "${template[reply-to]-}" ]; then\r
+ additional_headers="Reply-To: ${template[reply-to]}\r
+ ${additional_headers}"\r
+ fi\r
+ \r
+- if [ ! -z "${template[in-reply-to]}" ]; then\r
++ if [ ! -z "${template[in-reply-to]-}" ]; then\r
+ additional_headers="In-Reply-To: ${template[in-reply-to]}\r
+ ${additional_headers}"\r
+ fi\r
+ \r
+- if [ ! -z "${template[cc]}" ]; then\r
++ if [ ! -z "${template[cc]-}" ]; then\r
+ additional_headers="Cc: ${template[cc]}\r
+ ${additional_headers}"\r
+ fi\r
+ \r
+- if [ ! -z "${template[bcc]}" ]; then\r
++ if [ ! -z "${template[bcc]-}" ]; then\r
+ additional_headers="Bcc: ${template[bcc]}\r
+ ${additional_headers}"\r
+ fi\r
+ \r
+- if [ ! -z "${template[references]}" ]; then\r
++ if [ ! -z "${template[references]-}" ]; then\r
+ additional_headers="References: ${template[references]}\r
+ ${additional_headers}"\r
+ fi\r
+ \r
+- if [ ! -z "${template[content-type]}" ]; then\r
++ if [ ! -z "${template[content-type]-}" ]; then\r
+ additional_headers="Content-Type: ${template[content-type]}\r
+ ${additional_headers}"\r
+ fi\r
+ \r
+- if [ ! -z "${template[content-transfer-encoding]}" ]; then\r
++ if [ ! -z "${template[content-transfer-encoding]-}" ]; then\r
+ additional_headers="Content-Transfer-Encoding: ${template[content-transfer-encoding]}\r
+ ${additional_headers}"\r
+ fi\r
+@@ -545,6 +552,7 @@ add_email_corpus ()\r
+ fi\r
+ }\r
+ \r
++inside_subtest=\r
+ test_begin_subtest ()\r
+ {\r
+ if [ -n "$inside_subtest" ]; then\r
+@@ -775,7 +783,7 @@ $binary () {\r
+ # Returns success if dependency is available, failure otherwise.\r
+ test_require_external_prereq () {\r
+ binary="$1"\r
+- if [[ ${test_missing_external_prereq_["${binary}"]} == t ]]; then\r
++ if [[ ${test_missing_external_prereq_["${binary}"]-} == t ]]; then\r
+ # dependency is missing, call the replacement function to note it\r
+ eval "$binary"\r
+ else\r
+@@ -792,7 +800,7 @@ test_ok_ () {\r
+ return\r
+ fi\r
+ test_success=$(($test_success + 1))\r
+- if test -n "$NOTMUCH_TEST_QUIET"; then\r
++ if test -n "${NOTMUCH_TEST_QUIET-}"; then\r
+ return 0\r
+ fi\r
+ say_color pass "%-6s" "PASS"\r
+@@ -849,7 +857,7 @@ test_run_ () {\r
+ test_skip () {\r
+ test_count=$(($test_count+1))\r
+ to_skip=\r
+- for skp in $NOTMUCH_SKIP_TESTS\r
++ for skp in ${NOTMUCH_SKIP_TESTS-}\r
+ do\r
+ case $this_test.$test_count in\r
+ $skp)\r
+@@ -1109,7 +1117,7 @@ exec ${TEST_EMACS} --quick \\r
+ EOF\r
+ chmod a+x "$TMP_DIRECTORY/run_emacs"\r
+ }\r
+-\r
++EMACS_SERVER=\r
+ test_emacs () {\r
+ # test dependencies beforehand to avoid the waiting loop below\r
+ missing_dependencies=\r
+@@ -1213,6 +1221,7 @@ notmuch_counter_value () {\r
+ echo $count\r
+ }\r
+ \r
++test_init_done_=\r
+ test_reset_state_ () {\r
+ test -z "$test_init_done_" && test_init_\r
+ \r
+@@ -1245,7 +1254,7 @@ else\r
+ exec 4>test.output 3>&4\r
+ fi\r
+ \r
+-for skp in $NOTMUCH_SKIP_TESTS\r
++for skp in ${NOTMUCH_SKIP_TESTS-}\r
+ do\r
+ to_skip=\r
+ for skp in $NOTMUCH_SKIP_TESTS\r
+@@ -1312,8 +1321,8 @@ case $(uname -s) in\r
+ ;;\r
+ esac\r
+ \r
+-test -z "$NO_PERL" && test_set_prereq PERL\r
+-test -z "$NO_PYTHON" && test_set_prereq PYTHON\r
++test -z "${NO_PERL-}" && test_set_prereq PERL\r
++test -z "${NO_PYTHON-}" && test_set_prereq PYTHON\r
+ \r
+ # test whether the filesystem supports symbolic links\r
+ ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS\r
+-- \r
+1.9.3\r
+\r