1 Return-Path: <too@guru-group.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by arlo.cworth.org (Postfix) with ESMTP id A40176DE0130
\r
6 for <notmuch@notmuchmail.org>; Tue, 7 Jun 2016 15:00:07 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org
\r
11 X-Spam-Status: No, score=0.243 tagged_above=-999 required=5 tests=[AWL=0.252,
\r
12 HEADER_FROM_DIFFERENT_DOMAINS=0.001, T_RP_MATCHES_RCVD=-0.01]
\r
14 Received: from arlo.cworth.org ([127.0.0.1])
\r
15 by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)
\r
16 with ESMTP id 7Ue-Jj8TytsH for <notmuch@notmuchmail.org>;
\r
17 Tue, 7 Jun 2016 14:59:59 -0700 (PDT)
\r
18 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
19 by arlo.cworth.org (Postfix) with ESMTP id BB0E86DE00BF
\r
20 for <notmuch@notmuchmail.org>; Tue, 7 Jun 2016 14:59:58 -0700 (PDT)
\r
21 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
22 id CF6B51001A6; Wed, 8 Jun 2016 00:59:38 +0300 (EEST)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: notmuch@notmuchmail.org
\r
25 Cc: tomi.ollila@iki.fi
\r
26 Subject: [PATCH v2] test: add "set -u" to test-lib.sh
\r
27 Date: Wed, 8 Jun 2016 00:59:37 +0300
\r
28 Message-Id: <1465336777-31225-1-git-send-email-tomi.ollila@iki.fi>
\r
29 X-Mailer: git-send-email 2.8.2
\r
30 X-BeenThere: notmuch@notmuchmail.org
\r
31 X-Mailman-Version: 2.1.20
\r
33 List-Id: "Use and development of the notmuch mail system."
\r
34 <notmuch.notmuchmail.org>
\r
35 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,
\r
36 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>
\r
38 List-Post: <mailto:notmuch@notmuchmail.org>
\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
40 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,
\r
41 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
42 X-List-Received-Date: Tue, 07 Jun 2016 22:00:07 -0000
\r
44 This prohibits unset variables to expand to empty strings.
\r
45 Without this e.g misspelled variables cause unintentional results.
\r
47 Now all the test variables are either initialized, or in case of
\r
48 optional arguments and user-provided environment variables (i.e.
\r
49 when it is not know whethet the variable is set) the form
\r
50 ${variable-} is used.
\r
52 Two unusable lines (leftovers?) in T360-symbol-hiding.sh were removed;
\r
53 this was the only non-lib test code that needed to be edited for this
\r
57 This is v2 of id:1441307395-2218-1-git-send-email-tomi.ollila@iki.fi
\r
59 (basically added ensuring that $TERM is set)
\r
63 id:1465043356-23420-2-git-send-email-david@tethera.net
\r
64 id:1465043356-23420-4-git-send-email-david@tethera.net
\r
66 (in *-4-* if [ "${NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK}" = "0" ]
\r
67 always returns false as $NOTMUCH_HAVE_XAPIAN_DB_RETRY_LOCK
\r
68 is not defined, -> string comparison "" = "0" is false)
\r
70 I created this on top of current master (6a833a6e83) plus
\r
72 id:1464212261-26892-1-git-send-email-tomi.ollila@iki.fi
\r
73 id:1464212261-26892-2-git-send-email-tomi.ollila@iki.fi
\r
74 id:1464439170-25978-1-git-send-email-tomi.ollila@iki.fi
\r
75 id:1464439170-25978-2-git-send-email-tomi.ollila@iki.fi
\r
76 id:1464439170-25978-3-git-send-email-tomi.ollila@iki.fi
\r
78 (so i could test this on 2 systems) -- but this applies on
\r
79 top of 6a833a6e83 (current master) too.
\r
81 test/T360-symbol-hiding.sh | 3 ---
\r
82 test/test-lib.sh | 63 +++++++++++++++++++++++++++-------------------
\r
83 2 files changed, 37 insertions(+), 29 deletions(-)
\r
85 diff --git a/test/T360-symbol-hiding.sh b/test/T360-symbol-hiding.sh
\r
86 index b3dbb1b..3fec3b7 100755
\r
87 --- a/test/T360-symbol-hiding.sh
\r
88 +++ b/test/T360-symbol-hiding.sh
\r
89 @@ -22,9 +22,6 @@ caught No backend database found at path 'CWD/nonexistent'
\r
91 test_expect_equal_file EXPECTED OUTPUT
\r
93 -test_begin_subtest 'checking output'
\r
94 -test_expect_equal "$result" "$output"
\r
96 test_begin_subtest 'comparing existing to exported symbols'
\r
97 nm -P $TEST_DIRECTORY/../lib/libnotmuch.so | awk '$2 == "T" && $1 ~ "^notmuch" {print $1}' | sort | uniq > ACTUAL
\r
98 sed -n 's/[[:blank:]]*\(notmuch_[^;]*\);/\1/p' $TEST_DIRECTORY/../notmuch.sym | sort | uniq > EXPORTED
\r
99 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
100 index 54c65b6..6cde453 100644
\r
101 --- a/test/test-lib.sh
\r
102 +++ b/test/test-lib.sh
\r
103 @@ -23,6 +23,9 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then
\r
107 +# Exit immediately when attempting to expand unset variable.
\r
110 # Make sure echo builtin does not expand backslash-escape sequences by default.
\r
113 @@ -32,7 +35,7 @@ this_test_bare=${this_test#T[0-9][0-9][0-9]-}
\r
115 # if --tee was passed, write the output not only to the terminal, but
\r
116 # additionally to the file test-results/$BASENAME.out, too.
\r
117 -case "$GIT_TEST_TEE_STARTED, $* " in
\r
118 +case "${GIT_TEST_TEE_STARTED-}, $* " in
\r
120 # do not redirect again
\r
122 @@ -53,7 +56,7 @@ BASH_XTRACEFD=7
\r
123 export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
\r
125 # Keep the original TERM for say_color and test_emacs
\r
126 -ORIGINAL_TERM=$TERM
\r
127 +ORIGINAL_TERM=${TERM:-dumb}
\r
129 # dtach(1) provides more capable terminal environment to anything
\r
130 # that requires more than dumb terminal...
\r
131 @@ -67,8 +70,8 @@ TZ=UTC
\r
133 export LANG LC_ALL PAGER TERM TZ
\r
134 GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
\r
135 -if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \
\r
136 - ( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then
\r
137 +if [[ ( -n "${TEST_EMACS-}" && -z "${TEST_EMACSCLIENT-}" ) || \
\r
138 + ( -z "${TEST_EMACS-}" && -n "${TEST_EMACSCLIENT-}" ) ]]; then
\r
139 echo "error: must specify both or neither of TEST_EMACS and TEST_EMACSCLIENT" >&2
\r
142 @@ -110,7 +113,10 @@ _x32="$_x04$_x04$_x04$_x04$_x04$_x04$_x04$_x04"
\r
143 tput setaf 1 >/dev/null 2>&1 &&
\r
144 tput sgr0 >/dev/null 2>&1
\r
147 + color=t || color=
\r
149 +debug= immediate= help= verbose= quiet=
\r
150 +with_dashes= valgrind= verbose= root=
\r
152 while test "$#" -ne 0
\r
154 @@ -212,7 +218,7 @@ print_test_description ()
\r
155 echo $this_test: "Testing ${test_description}"
\r
156 test_description_printed=1
\r
158 -if [ -z "$NOTMUCH_TEST_QUIET" ]
\r
159 +if [ -z "${NOTMUCH_TEST_QUIET=}" ]
\r
161 print_test_description
\r
163 @@ -345,6 +351,7 @@ remove_cr () {
\r
165 gen_msg_filename=""
\r
167 +test_subtest_name=
\r
168 generate_message ()
\r
170 # This is our (bash-specific) magic for doing named parameters
\r
171 @@ -352,48 +359,48 @@ generate_message ()
\r
172 local additional_headers
\r
174 gen_msg_cnt=$((gen_msg_cnt + 1))
\r
175 - if [ -z "${template[filename]}" ]; then
\r
176 + if [ -z "${template[filename]-}" ]; then
\r
177 gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)"
\r
179 gen_msg_name=${template[filename]}
\r
182 - if [ -z "${template[id]}" ]; then
\r
183 + if [ -z "${template[id]-}" ]; then
\r
184 gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"
\r
186 gen_msg_id="${template[id]}"
\r
189 - if [ -z "${template[dir]}" ]; then
\r
190 + if [ -z "${template[dir]-}" ]; then
\r
191 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
\r
193 gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
\r
194 mkdir -p "$(dirname "$gen_msg_filename")"
\r
197 - if [ -z "${template[body]}" ]; then
\r
198 + if [ -z "${template[body]-}" ]; then
\r
199 template[body]="This is just a test message (#${gen_msg_cnt})"
\r
202 - if [ -z "${template[from]}" ]; then
\r
203 + if [ -z "${template[from]-}" ]; then
\r
204 template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"
\r
207 - if [ -z "${template[to]}" ]; then
\r
208 + if [ -z "${template[to]-}" ]; then
\r
209 template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"
\r
212 - if [ -z "${template[subject]}" ]; then
\r
213 + if [ -z "${template[subject]-}" ]; then
\r
214 if [ -n "$test_subtest_name" ]; then
\r
215 template[subject]="$test_subtest_name"
\r
217 template[subject]="Test message #${gen_msg_cnt}"
\r
219 - elif [ "${template[subject]}" = "@FORCE_EMPTY" ]; then
\r
220 + elif [ "${template[subject]-}" = "@FORCE_EMPTY" ]; then
\r
221 template[subject]=""
\r
224 - if [ -z "${template[date]}" ]; then
\r
225 + if [ -z "${template[date]-}" ]; then
\r
226 # we use decreasing timestamps here for historical reasons;
\r
227 # the existing test suite when we converted to unique timestamps just
\r
228 # happened to have signicantly fewer failures with that choice.
\r
229 @@ -406,42 +413,42 @@ generate_message ()
\r
232 additional_headers=""
\r
233 - if [ ! -z "${template[header]}" ]; then
\r
234 + if [ ! -z "${template[header]-}" ]; then
\r
235 additional_headers="${template[header]}
\r
236 ${additional_headers}"
\r
239 - if [ ! -z "${template[reply-to]}" ]; then
\r
240 + if [ ! -z "${template[reply-to]-}" ]; then
\r
241 additional_headers="Reply-To: ${template[reply-to]}
\r
242 ${additional_headers}"
\r
245 - if [ ! -z "${template[in-reply-to]}" ]; then
\r
246 + if [ ! -z "${template[in-reply-to]-}" ]; then
\r
247 additional_headers="In-Reply-To: ${template[in-reply-to]}
\r
248 ${additional_headers}"
\r
251 - if [ ! -z "${template[cc]}" ]; then
\r
252 + if [ ! -z "${template[cc]-}" ]; then
\r
253 additional_headers="Cc: ${template[cc]}
\r
254 ${additional_headers}"
\r
257 - if [ ! -z "${template[bcc]}" ]; then
\r
258 + if [ ! -z "${template[bcc]-}" ]; then
\r
259 additional_headers="Bcc: ${template[bcc]}
\r
260 ${additional_headers}"
\r
263 - if [ ! -z "${template[references]}" ]; then
\r
264 + if [ ! -z "${template[references]-}" ]; then
\r
265 additional_headers="References: ${template[references]}
\r
266 ${additional_headers}"
\r
269 - if [ ! -z "${template[content-type]}" ]; then
\r
270 + if [ ! -z "${template[content-type]-}" ]; then
\r
271 additional_headers="Content-Type: ${template[content-type]}
\r
272 ${additional_headers}"
\r
275 - if [ ! -z "${template[content-transfer-encoding]}" ]; then
\r
276 + if [ ! -z "${template[content-transfer-encoding]-}" ]; then
\r
277 additional_headers="Content-Transfer-Encoding: ${template[content-transfer-encoding]}
\r
278 ${additional_headers}"
\r
280 @@ -559,6 +566,7 @@ add_email_corpus ()
\r
285 test_begin_subtest ()
\r
287 if [ -n "$inside_subtest" ]; then
\r
288 @@ -811,7 +819,7 @@ $binary () {
\r
289 # Returns success if dependency is available, failure otherwise.
\r
290 test_require_external_prereq () {
\r
292 - if [[ ${test_missing_external_prereq_["${binary}"]} == t ]]; then
\r
293 + if [[ ${test_missing_external_prereq_["${binary}"]-} == t ]]; then
\r
294 # dependency is missing, call the replacement function to note it
\r
297 @@ -882,6 +890,7 @@ test_run_ () {
\r
301 +: ${NOTMUCH_SKIP_TESTS=}
\r
303 test_count=$(($test_count+1))
\r
305 @@ -1146,6 +1155,7 @@ EOF
\r
306 chmod a+x "$TMP_DIRECTORY/run_emacs"
\r
311 # test dependencies beforehand to avoid the waiting loop below
\r
312 missing_dependencies=
\r
313 @@ -1246,6 +1256,7 @@ notmuch_counter_value () {
\r
318 test_reset_state_ () {
\r
319 test -z "$test_init_done_" && test_init_
\r
321 @@ -1345,8 +1356,8 @@ case $(uname -s) in
\r
325 -test -z "$NO_PERL" && test_set_prereq PERL
\r
326 -test -z "$NO_PYTHON" && test_set_prereq PYTHON
\r
327 +test -z "${NO_PERL-}" && test_set_prereq PERL
\r
328 +test -z "${NO_PYTHON-}" && test_set_prereq PYTHON
\r
330 # test whether the filesystem supports symbolic links
\r
331 ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS
\r