Re: [PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 03 / ae00e2a2cac93a17c11655b89ec6722cda1213
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 7274D429E2E\r
6         for <notmuch@notmuchmail.org>; Wed, 16 Nov 2011 17:57:07 -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 aa18-wP9EFfC for <notmuch@notmuchmail.org>;\r
17         Wed, 16 Nov 2011 17:57:04 -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 BD6C3429E39\r
22         for <notmuch@notmuchmail.org>; Wed, 16 Nov 2011 17:56:56 -0800 (PST)\r
23 Received: by mail-bw0-f53.google.com with SMTP id q10so1456807bka.26\r
24         for <notmuch@notmuchmail.org>; Wed, 16 Nov 2011 17:56:56 -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=LGlH135A5PBHZD5TmjaxaIQwi1a4gGc2zhsQSt4gfHo=;\r
28         b=fLNqGh+6xhD0OIe9RWFoVuWp98yni4Tjpe2bJaQktM0WIvsy3eqv3HzKjFw2osqzyR\r
29         hjYvNAcnQvYghz+ldu5U6trNrYnCZITiVnSWYBPz4z9wTeFMksH43348zxYB9Cbpkkip\r
30         K6rZ1LGtaLM6VpeYPOx0MXBM692eSwbKCctBc=\r
31 Received: by 10.205.130.1 with SMTP id hk1mr14119258bkc.68.1321495016273;\r
32         Wed, 16 Nov 2011 17:56:56 -0800 (PST)\r
33 Received: from localhost ([91.144.186.21])\r
34         by mx.google.com with ESMTPS id cc2sm37989464bkb.8.2011.11.16.17.56.55\r
35         (version=TLSv1/SSLv3 cipher=OTHER);\r
36         Wed, 16 Nov 2011 17:56:55 -0800 (PST)\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
38 To: notmuch@notmuchmail.org\r
39 Subject: [PATCH 4/9] test: add support for external executable dependencies\r
40 Date: Thu, 17 Nov 2011 05:56:21 +0400\r
41 Message-Id: <1321494986-18998-5-git-send-email-dmitry.kurochkin@gmail.com>\r
42 X-Mailer: git-send-email 1.7.7.2\r
43 In-Reply-To: <1321494986-18998-1-git-send-email-dmitry.kurochkin@gmail.com>\r
44 References: <1321494986-18998-1-git-send-email-dmitry.kurochkin@gmail.com>\r
45 X-BeenThere: notmuch@notmuchmail.org\r
46 X-Mailman-Version: 2.1.13\r
47 Precedence: list\r
48 List-Id: "Use and development of the notmuch mail system."\r
49         <notmuch.notmuchmail.org>\r
50 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
51         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
53 List-Post: <mailto:notmuch@notmuchmail.org>\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
55 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
57 X-List-Received-Date: Thu, 17 Nov 2011 01:57:07 -0000\r
58 \r
59 There is existing support for general prerequisites in the test suite.\r
60 But it is not very convenient to use: every test case has to keep\r
61 track for it's dependencies and they have to be explicitly listed.\r
62 \r
63 The patch aims to add better support for a particular type of external\r
64 dependencies: external executables.  The main idea is to replace\r
65 missing external binaries with shell functions that have the same\r
66 name.  These functions always fail and keep track of missing\r
67 dependencies for a subtest.  The result reporting functions later can\r
68 check that an external binaries are missing and correctly report SKIP\r
69 result instead of FAIL.  The primary benefit is that the test cases do\r
70 not need to declare their dependencies or be changed in any way.\r
71 ---\r
72  test/test-lib.sh |   49 +++++++++++++++++++++++++++++++++++++++++--------\r
73  1 files changed, 41 insertions(+), 8 deletions(-)\r
74 \r
75 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
76 index f21e45e..ab8c6fd 100755\r
77 --- a/test/test-lib.sh\r
78 +++ b/test/test-lib.sh\r
79 @@ -526,40 +526,53 @@ notmuch_json_show_sanitize ()\r
80  # - Implicitly by specifying the prerequisite tag in the calls to\r
81  #   test_expect_{success,failure,code}.\r
82  #\r
83  # The single parameter is the prerequisite tag (a simple word, in all\r
84  # capital letters by convention).\r
85  \r
86  test_set_prereq () {\r
87         satisfied="$satisfied$1 "\r
88  }\r
89  satisfied=" "\r
90  \r
91  test_have_prereq () {\r
92         case $satisfied in\r
93         *" $1 "*)\r
94                 : yes, have it ;;\r
95         *)\r
96                 ! : nope ;;\r
97         esac\r
98  }\r
99  \r
100 +# declare prerequisite for the given external binary\r
101 +test_declare_external_prereq () {\r
102 +       binary="$1"\r
103 +       test "$#" = 2 && name=$2 || name="$binary(1)"\r
104 +\r
105 +        hash $binary 2>/dev/null || eval "\r
106 +$1 () {\r
107 +       echo -n \"\$test_subtest_missing_external_prereqs_\" | grep -e \" $name \" ||\r
108 +       test_subtest_missing_external_prereqs_=\"$test_subtest_missing_external_prereqs_ $name\"\r
109 +       false\r
110 +}"\r
111 +}\r
112 +\r
113  # You are not expected to call test_ok_ and test_failure_ directly, use\r
114  # the text_expect_* functions instead.\r
115  \r
116  test_ok_ () {\r
117         if test "$test_subtest_known_broken_" = "t"; then\r
118                 test_known_broken_ok_ "$@"\r
119                 return\r
120         fi\r
121         test_success=$(($test_success + 1))\r
122         say_color pass "%-6s" "PASS"\r
123         echo " $@"\r
124  }\r
125  \r
126  test_failure_ () {\r
127         if test "$test_subtest_known_broken_" = "t"; then\r
128                 test_known_broken_failure_ "$@"\r
129                 return\r
130         fi\r
131         test_failure=$(($test_failure + 1))\r
132         test_failure_message_ "FAIL" "$@"\r
133 @@ -602,82 +615,101 @@ test_run_ () {\r
134         return 0\r
135  }\r
136  \r
137  test_skip () {\r
138         test_count=$(($test_count+1))\r
139         to_skip=\r
140         for skp in $NOTMUCH_SKIP_TESTS\r
141         do\r
142                 case $this_test.$test_count in\r
143                 $skp)\r
144                         to_skip=t\r
145                 esac\r
146         done\r
147         if test -z "$to_skip" && test -n "$prereq" &&\r
148            ! test_have_prereq "$prereq"\r
149         then\r
150                 to_skip=t\r
151         fi\r
152         case "$to_skip" in\r
153         t)\r
154 -               test_reset_state_\r
155 -               say_color skip >&3 "skipping test: $@"\r
156 -               say_color skip "%-6s" "SKIP"\r
157 -               echo " $1"\r
158 -               : true\r
159 +               test_report_skip_ "$@"\r
160                 ;;\r
161         *)\r
162 -               false\r
163 +               test_check_missing_external_prereqs_ "$@"\r
164                 ;;\r
165         esac\r
166  }\r
167  \r
168 +test_check_missing_external_prereqs_ () {\r
169 +       if test -n "$test_subtest_missing_external_prereqs_"; then\r
170 +               say_color skip >&3 "missing prerequisites:"\r
171 +               echo "$test_subtest_missing_external_prereqs_" >&3\r
172 +               test_report_skip_ "$@"\r
173 +       else\r
174 +               false\r
175 +       fi\r
176 +}\r
177 +\r
178 +test_report_skip_ () {\r
179 +       test_reset_state_\r
180 +       say_color skip >&3 "skipping test: $@"\r
181 +       say_color skip "%-6s" "SKIP"\r
182 +       echo " $1"\r
183 +}\r
184 +\r
185  test_subtest_known_broken () {\r
186         test_subtest_known_broken_=t\r
187  }\r
188  \r
189  test_expect_success () {\r
190         test "$#" = 3 && { prereq=$1; shift; } || prereq=\r
191         test "$#" = 2 ||\r
192         error "bug in the test script: not 2 or 3 parameters to test-expect-success"\r
193         test_reset_state_\r
194         if ! test_skip "$@"\r
195         then\r
196                 test_run_ "$2"\r
197 -               if [ "$?" = 0 -a "$eval_ret" = 0 ]\r
198 +               run_ret="$?"\r
199 +               # test_run_ may update missing external prerequisites\r
200 +               test_check_missing_external_prereqs_ "$@" ||\r
201 +               if [ "$run_ret" = 0 -a "$eval_ret" = 0 ]\r
202                 then\r
203                         test_ok_ "$1"\r
204                 else\r
205                         test_failure_ "$@"\r
206                 fi\r
207         fi\r
208  }\r
209  \r
210  test_expect_code () {\r
211         test "$#" = 4 && { prereq=$1; shift; } || prereq=\r
212         test "$#" = 3 ||\r
213         error "bug in the test script: not 3 or 4 parameters to test-expect-code"\r
214         test_reset_state_\r
215         if ! test_skip "$@"\r
216         then\r
217                 test_run_ "$3"\r
218 -               if [ "$?" = 0 -a "$eval_ret" = "$1" ]\r
219 +               run_ret="$?"\r
220 +               # test_run_ may update missing external prerequisites,\r
221 +               test_check_missing_external_prereqs_ "$@" ||\r
222 +               if [ "$run_ret" = 0 -a "$eval_ret" = "$1" ]\r
223                 then\r
224                         test_ok_ "$2"\r
225                 else\r
226                         test_failure_ "$@"\r
227                 fi\r
228         fi\r
229  }\r
230  \r
231  # test_external runs external test scripts that provide continuous\r
232  # test output about their progress, and succeeds/fails on\r
233  # zero/non-zero exit code.  It outputs the test output on stdout even\r
234  # in non-verbose mode, and announces the external script with "* run\r
235  # <n>: ..." before running it.  When providing relative paths, keep in\r
236  # mind that all scripts run in "trash directory".\r
237  # Usage: test_external description command arguments...\r
238  # Example: test_external 'Perl API' perl ../path/to/test.pl\r
239  test_external () {\r
240         test "$#" = 4 && { prereq=$1; shift; } || prereq=\r
241         test "$#" = 3 ||\r
242         error >&5 "bug in the test script: not 3 or 4 parameters to test_external"\r
243 @@ -848,40 +880,41 @@ test_emacs () {\r
244                 # user's TERM is given to dtach which assumes a minimally\r
245                 # VT100-compatible terminal -- and emacs inherits that\r
246                 TERM=$ORIGINAL_TERM dtach -n "$TMP_DIRECTORY/emacs-dtach-socket.$$" \\r
247                         sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \\r
248                                 --no-window-system \\r
249                                 --eval '(setq server-name \"$server_name\")' \\r
250                                 --eval '(server-start)' \\r
251                                 --eval '(orphan-watchdog $$)'" || return\r
252                 EMACS_SERVER="$server_name"\r
253                 # wait until the emacs server is up\r
254                 until test_emacs '()' 2>/dev/null; do\r
255                         sleep 1\r
256                 done\r
257         fi\r
258  \r
259         emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"\r
260  }\r
261  \r
262  test_reset_state_ () {\r
263         test_subtest_known_broken_=\r
264 +       test_subtest_missing_external_prereqs_=\r
265  }\r
266  \r
267  \r
268  find_notmuch_path ()\r
269  {\r
270      dir="$1"\r
271  \r
272      while [ -n "$dir" ]; do\r
273         bin="$dir/notmuch"\r
274         if [ -x "$bin" ]; then\r
275             echo "$dir"\r
276             return\r
277         fi\r
278         dir="$(dirname "$dir")"\r
279         if [ "$dir" = "/" ]; then\r
280             break\r
281         fi\r
282      done\r
283  }\r
284  \r
285 -- \r
286 1.7.7.2\r
287 \r