Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / ae / 5e50ad6d78680b230cef4318e49f6a08b40c7e
1 Return-Path: <dmitry.kurochkin@gmail.com>\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 olra.theworths.org (Postfix) with ESMTP id 1953C429E29\r
6         for <notmuch@notmuchmail.org>; Thu, 17 Nov 2011 05:06:29 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id UDG2OSOd438P for <notmuch@notmuchmail.org>;\r
17         Thu, 17 Nov 2011 05:06:28 -0800 (PST)\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 1A2EC429E27\r
22         for <notmuch@notmuchmail.org>; Thu, 17 Nov 2011 05:06:27 -0800 (PST)\r
23 Received: by bkaq10 with SMTP id q10so2108356bka.26\r
24         for <notmuch@notmuchmail.org>; Thu, 17 Nov 2011 05:06:26 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=qHAItwn6YX98hjr7287H7ty64yyMlQ+UH4HMcVeAvWg=;\r
28         b=gt+uNf41kVqjfAY++jJmC/9nwPRUDqvvoUjg0Zau4FvIjaxeW+I3t9w0AlwtOcvWIB\r
29         b1jX365JKCwtmL7fEfjS2y3/uoKADsIPwe9FGouGkHNxadkrsG50RM6RZOMYhCoPsuJ3\r
30         ydWPXSKcXe/pBM4Xmj2Dm3RGI9ybd3ShvwMQ8=\r
31 Received: by 10.204.148.75 with SMTP id o11mr33811874bkv.95.1321535186394;\r
32         Thu, 17 Nov 2011 05:06:26 -0800 (PST)\r
33 Received: from localhost ([91.144.186.21])\r
34         by mx.google.com with ESMTPS id dq2sm40613011bkb.11.2011.11.17.05.06.24\r
35         (version=TLSv1/SSLv3 cipher=OTHER);\r
36         Thu, 17 Nov 2011 05:06:25 -0800 (PST)\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH v2 01/10] test: move subtest variables reset into a dedicated\r
40         function\r
41 Date: Thu, 17 Nov 2011 17:05:54 +0400\r
42 Message-Id: <1321535163-4895-2-git-send-email-dmitry.kurochkin@gmail.com>\r
43 X-Mailer: git-send-email 1.7.7.2\r
44 In-Reply-To: <1321535163-4895-1-git-send-email-dmitry.kurochkin@gmail.com>\r
45 References: <1321535163-4895-1-git-send-email-dmitry.kurochkin@gmail.com>\r
46 X-BeenThere: notmuch@notmuchmail.org\r
47 X-Mailman-Version: 2.1.13\r
48 Precedence: list\r
49 List-Id: "Use and development of the notmuch mail system."\r
50         <notmuch.notmuchmail.org>\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
54 List-Post: <mailto:notmuch@notmuchmail.org>\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
58 X-List-Received-Date: Thu, 17 Nov 2011 13:06:29 -0000\r
59 \r
60 Currently, there is only one such variable test_subtest_known_broken_.\r
61 But more will be added in the future.\r
62 ---\r
63  test/test-lib.sh |   12 ++++++++----\r
64  1 files changed, 8 insertions(+), 4 deletions(-)\r
65 \r
66 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
67 index 1ea7fa9..222b5e4 100755\r
68 --- a/test/test-lib.sh\r
69 +++ b/test/test-lib.sh\r
70 @@ -407,41 +407,41 @@ emacs_deliver_message ()\r
71  # number of messages.\r
72  add_email_corpus ()\r
73  {\r
74      rm -rf ${MAIL_DIR}\r
75      if [ -d $TEST_DIRECTORY/corpus.mail ]; then\r
76         cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR}\r
77      else\r
78         cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}\r
79         notmuch new >/dev/null\r
80         cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail\r
81      fi\r
82  }\r
83  \r
84  test_begin_subtest ()\r
85  {\r
86      if [ -n "$inside_subtest" ]; then\r
87         exec 1>&6 2>&7          # Restore stdout and stderr\r
88         error "bug in test script: Missing test_expect_equal in ${BASH_SOURCE[1]}:${BASH_LINENO[0]}"\r
89      fi\r
90      test_subtest_name="$1"\r
91 -    test_subtest_known_broken_=\r
92 +    test_reset_state_\r
93      # Remember stdout and stderr file descriptors and redirect test\r
94      # output to the previously prepared file descriptors 3 and 4 (see\r
95      # below)\r
96      if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
97      exec 6>&1 7>&2 >&3 2>&4\r
98      inside_subtest=t\r
99  }\r
100  \r
101  # Pass test if two arguments match\r
102  #\r
103  # Note: Unlike all other test_expect_* functions, this function does\r
104  # not accept a test name. Instead, the caller should call\r
105  # test_begin_subtest before calling this function in order to set the\r
106  # name.\r
107  test_expect_equal ()\r
108  {\r
109         exec 1>&6 2>&7          # Restore stdout and stderr\r
110         inside_subtest=\r
111         test "$#" = 3 && { prereq=$1; shift; } || prereq=\r
112         test "$#" = 2 ||\r
113 @@ -559,84 +559,84 @@ test_ok_ () {\r
114  test_failure_ () {\r
115         if test "$test_subtest_known_broken_" = "t"; then\r
116                 test_known_broken_failure_ "$@"\r
117                 return\r
118         fi\r
119         test_failure=$(($test_failure + 1))\r
120         test_failure_message_ "FAIL" "$@"\r
121         test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; }\r
122         return 1\r
123  }\r
124  \r
125  test_failure_message_ () {\r
126         say_color error "%-6s" "$1"\r
127         echo " $2"\r
128         shift 2\r
129         echo "$@" | sed -e 's/^/        /'\r
130         if test "$verbose" != "t"; then cat test.output; fi\r
131  }\r
132  \r
133  test_known_broken_ok_ () {\r
134 -       test_subtest_known_broken_=\r
135 +       test_reset_state_\r
136         test_fixed=$(($test_fixed+1))\r
137         say_color pass "%-6s" "FIXED"\r
138         echo " $@"\r
139  }\r
140  \r
141  test_known_broken_failure_ () {\r
142 -       test_subtest_known_broken_=\r
143 +       test_reset_state_\r
144         test_broken=$(($test_broken+1))\r
145         test_failure_message_ "BROKEN" "$@"\r
146         return 1\r
147  }\r
148  \r
149  test_debug () {\r
150         test "$debug" = "" || eval "$1"\r
151  }\r
152  \r
153  test_run_ () {\r
154         test_cleanup=:\r
155         if test "$verbose" != "t"; then exec 4>test.output 3>&4; fi\r
156         eval >&3 2>&4 "$1"\r
157         eval_ret=$?\r
158         eval >&3 2>&4 "$test_cleanup"\r
159         return 0\r
160  }\r
161  \r
162  test_skip () {\r
163         test_count=$(($test_count+1))\r
164         to_skip=\r
165         for skp in $NOTMUCH_SKIP_TESTS\r
166         do\r
167                 case $this_test.$test_count in\r
168                 $skp)\r
169                         to_skip=t\r
170                 esac\r
171         done\r
172         if test -z "$to_skip" && test -n "$prereq" &&\r
173            ! test_have_prereq "$prereq"\r
174         then\r
175                 to_skip=t\r
176         fi\r
177         case "$to_skip" in\r
178         t)\r
179 -               test_subtest_known_broken_=\r
180 +               test_reset_state_\r
181                 say_color skip >&3 "skipping test: $@"\r
182                 say_color skip "%-6s" "SKIP"\r
183                 echo " $1"\r
184                 : true\r
185                 ;;\r
186         *)\r
187                 false\r
188                 ;;\r
189         esac\r
190  }\r
191  \r
192  test_subtest_known_broken () {\r
193         test_subtest_known_broken_=t\r
194  }\r
195  \r
196  test_expect_success () {\r
197         test "$#" = 3 && { prereq=$1; shift; } || prereq=\r
198         test "$#" = 2 ||\r
199         error "bug in the test script: not 2 or 3 parameters to test-expect-success"\r
200         if ! test_skip "$@"\r
201 @@ -842,40 +842,44 @@ test_emacs () {\r
202         if [ -z "$EMACS_SERVER" ]; then\r
203                 EMACS_SERVER="notmuch-test-suite-$$"\r
204                 # start a detached session with an emacs server\r
205                 # user's TERM is given to dtach which assumes a minimally\r
206                 # VT100-compatible terminal -- and emacs inherits that\r
207                 TERM=$ORIGINAL_TERM dtach -n "$TMP_DIRECTORY/emacs-dtach-socket.$$" \\r
208                         sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \\r
209                                 --no-window-system \\r
210                                 --eval '(setq server-name \"$EMACS_SERVER\")' \\r
211                                 --eval '(server-start)' \\r
212                                 --eval '(orphan-watchdog $$)'" || return\r
213                 # wait until the emacs server is up\r
214                 until test_emacs '()' 2>/dev/null; do\r
215                         sleep 1\r
216                 done\r
217         fi\r
218  \r
219         emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"\r
220  }\r
221  \r
222 +test_reset_state_ () {\r
223 +       test_subtest_known_broken_=\r
224 +}\r
225 +\r
226  \r
227  find_notmuch_path ()\r
228  {\r
229      dir="$1"\r
230  \r
231      while [ -n "$dir" ]; do\r
232         bin="$dir/notmuch"\r
233         if [ -x "$bin" ]; then\r
234             echo "$dir"\r
235             return\r
236         fi\r
237         dir="$(dirname "$dir")"\r
238         if [ "$dir" = "/" ]; then\r
239             break\r
240         fi\r
241      done\r
242  }\r
243  \r
244  # Test the binaries we have just built.  The tests are kept in\r
245  # test/ subdirectory and are run in 'trash directory' subdirectory.\r
246 -- \r
247 1.7.7.2\r
248 \r