[PATCH v2 05/14] cli/reply: reorganize create_reply_message()
[notmuch-archives.git] / e2 / 4c60d0ceb4a4419acabf2a308e3ac06188452f
1 Return-Path: <ma.skies@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 88E25431FD0\r
6         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 09:09:38 -0700 (PDT)\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 RMkjpFOR43JX for <notmuch@notmuchmail.org>;\r
17         Mon, 27 Jun 2011 09:09:37 -0700 (PDT)\r
18 Received: from mail-iy0-f181.google.com (mail-iy0-f181.google.com\r
19         [209.85.210.181]) (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 A438A431FB6\r
22         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 09:09:37 -0700 (PDT)\r
23 Received: by iyf40 with SMTP id 40so5032154iyf.26\r
24         for <notmuch@notmuchmail.org>; Mon, 27 Jun 2011 09:09:37 -0700 (PDT)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=domainkey-signature:from:to:subject:user-agent:date:message-id\r
27         :mime-version:content-type;\r
28         bh=L7Vq8CxhzsFv5o+5ZhAHCq201JEfXvFTQXTXLgOAkN8=;\r
29         b=w/4MofnAswBUtuNtb7dv6EuzdqVpAK8RaWZ2prdWKhUxF4KtLzwS4jtX05XH4vVd7t\r
30         fVQsoOGIPVBqXH3GAboh8cIRFn6Mp7RpeK0MPMGowCwXETsE4lAXVDhowXuduDYffwp2\r
31         N71LAeylrxRyfjUCXOgElpU8nbDHJYa1E9POc=\r
32 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
33         h=from:to:subject:user-agent:date:message-id:mime-version\r
34         :content-type;\r
35         b=CNZpzV0Ixs8w1wfW0JNbh27Wpjxyy5Svl026y8nsBDCCmZvYEjRtaFzyAHrB8ZTKTU\r
36         CGqmb/plBiqJODs34hLTB/pU59Sau0ZxPob+XLC4DTQMuDlqd0slOUUr3WasacUyA+eA\r
37         COytPBxLIvkd3873j7rhIBg8A4oy8zjMkd0Jc=\r
38 Received: by 10.231.95.143 with SMTP id d15mr4358532ibn.149.1309190975804;\r
39         Mon, 27 Jun 2011 09:09:35 -0700 (PDT)\r
40 Received: from localhost ([74.205.145.146])\r
41         by mx.google.com with ESMTPS id v15sm3122393ibh.45.2011.06.27.09.09.34\r
42         (version=TLSv1/SSLv3 cipher=OTHER);\r
43         Mon, 27 Jun 2011 09:09:34 -0700 (PDT)\r
44 From: Mark Anderson <ma.skies@gmail.com>\r
45 To: notmuch@notmuchmail.org\r
46 Subject: [PATCH] test:Improve test behaviors when --root is used\r
47 User-Agent: Notmuch/0.5-283-gb744eac (http://notmuchmail.org) Emacs/23.2.1\r
48         (i686-pc-linux-gnu)\r
49 Date: Mon, 27 Jun 2011 10:09:32 -0600\r
50 Message-ID: <87vcvrw91f.fsf@gmail.com>\r
51 MIME-Version: 1.0\r
52 Content-Type: text/plain; charset=us-ascii\r
53 X-BeenThere: notmuch@notmuchmail.org\r
54 X-Mailman-Version: 2.1.13\r
55 Precedence: list\r
56 List-Id: "Use and development of the notmuch mail system."\r
57         <notmuch.notmuchmail.org>\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
61 List-Post: <mailto:notmuch@notmuchmail.org>\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
64         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
65 X-List-Received-Date: Mon, 27 Jun 2011 16:09:38 -0000\r
66 \r
67 \r
68 Change add_email_corpus, emacs_deliver_message and tests to use\r
69 $TEST_DIRECTORY instead of '..'.\r
70 \r
71 This improves the behavior of the usage of --root=<dir>, as the\r
72 assumption of '..' will be incorrect if the option is specified.\r
73 \r
74 Document -root option in README and update valgrind to work with\r
75 -root.\r
76 ---\r
77 \r
78 I discovered the -root option when I wanted to run my test suite on\r
79 tmpfs, since my main drive is still spinning rust, and found test run\r
80 relocation is already implemented.\r
81 \r
82 However, many tests were not well behaved when --root was specified,\r
83 which makes sense since it wasn't documented in the README, added in\r
84 this patch.\r
85 \r
86 It seems like a good idea to try and run the test suite on a tmpfs\r
87 drive, but I don't know if there is a sufficiently generic standard\r
88 location or detection mechanism.  I use /dev/shm/notmuch_test, which\r
89 works for me.  I do wish I didn't have to keep specifying it, but I'm\r
90 not sure how well received putting this in notmuch's configure file\r
91 would be.\r
92 \r
93 \r
94  test/README        |    9 +++++++++\r
95  test/basic         |   10 +++++-----\r
96  test/crypto        |    2 +-\r
97  test/emacs         |    4 ++--\r
98  test/symbol-hiding |    4 ++--\r
99  test/test-lib.sh   |   18 +++++++++---------\r
100  6 files changed, 28 insertions(+), 19 deletions(-)\r
101 \r
102 diff --git a/test/README b/test/README\r
103 index be75e0e..8fbf78d 100644\r
104 --- a/test/README\r
105 +++ b/test/README\r
106 @@ -41,6 +41,15 @@ The following command-line options are available when running tests:\r
107         As the names depend on the tests' file names, it is safe to\r
108         run the tests with this option in parallel.\r
109  \r
110 +--root=<dir>::\r
111 +       This runs the testsuites specified under a seperate directory.\r
112 +       However, caution is advised, as not all tests are maintained\r
113 +       with this relocation in mind, so some tests may behave\r
114 +       differently.\r
115 +\r
116 +       Pointing this argument at a tmpfs filesystem can improve the\r
117 +       speed of the test suite for some users.\r
118 +\r
119  When invoking the test suite via "make test" any of the above options\r
120  can be specified as follows:\r
121  \r
122 diff --git a/test/basic b/test/basic\r
123 index d6e8c10..33bf711 100755\r
124 --- a/test/basic\r
125 +++ b/test/basic\r
126 @@ -51,9 +51,9 @@ test_expect_code 2 'failure to clean up causes the test to fail' '\r
127  \r
128  # Ensure that all tests are being run\r
129  test_begin_subtest 'Ensure that all available tests will be run by notmuch-test'\r
130 -eval $(sed -n -e '/^TESTS="$/,/^"$/p' notmuch-test ../notmuch-test)\r
131 +eval $(sed -n -e '/^TESTS="$/,/^"$/p' notmuch-test $TEST_DIRECTORY/notmuch-test)\r
132  tests_in_suite=$(for i in $TESTS; do echo $i; done | sort)\r
133 -available=$(ls -1 ../ | \\r
134 +available=$(ls -1 $TEST_DIRECTORY/ | \\r
135      sed -r -e "/^(aggregate-results.sh|Makefile|Makefile.local|notmuch-test)/d" \\r
136            -e "/^(README|test-lib.sh|test-lib.el|test-results|tmp.*|valgrind|corpus*)/d" \\r
137            -e "/^(emacs.expected-output|smtp-dummy|smtp-dummy.c|test-verbose|symbol-test.cc)/d" \\r
138 @@ -63,19 +63,19 @@ available=$(ls -1 ../ | \\r
139            | sort)\r
140  test_expect_equal "$tests_in_suite" "$available"\r
141  \r
142 -EXPECTED=../test.expected-output\r
143 +EXPECTED=$TEST_DIRECTORY/test.expected-output\r
144  suppress_diff_date() {\r
145      sed -e 's/\(.*\-\-\- test-verbose\.4\.\expected\).*/\1/' \\r
146         -e 's/\(.*\+\+\+ test-verbose\.4\.\output\).*/\1/'\r
147  }\r
148  \r
149  test_begin_subtest "Ensure that test output is suppressed unless the test fails"\r
150 -output=$(cd ..; ./test-verbose 2>&1 | suppress_diff_date)\r
151 +output=$(cd $TEST_DIRECTORY; ./test-verbose 2>&1 | suppress_diff_date)\r
152  expected=$(cat $EXPECTED/test-verbose-no | suppress_diff_date)\r
153  test_expect_equal "$output" "$expected"\r
154  \r
155  test_begin_subtest "Ensure that -v does not suppress test output"\r
156 -output=$(cd ..; ./test-verbose -v 2>&1 | suppress_diff_date)\r
157 +output=$(cd $TEST_DIRECTORY; ./test-verbose -v 2>&1 | suppress_diff_date)\r
158  expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date)\r
159  # Do not include the results of test-verbose in totals\r
160  rm $TEST_DIRECTORY/test-results/test-verbose-*\r
161 diff --git a/test/crypto b/test/crypto\r
162 index 01daffe..7eb3559 100755\r
163 --- a/test/crypto\r
164 +++ b/test/crypto\r
165 @@ -12,7 +12,7 @@ add_gnupg_home ()\r
166      local output\r
167      [ -d ${GNUPGHOME} ] && return\r
168      mkdir -m 0700 "$GNUPGHOME"\r
169 -    gpg --no-tty --import <../gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
170 +    gpg --no-tty --import <$TEST_DIRECTORY/gnupg-secret-key.asc >"$GNUPGHOME"/import.log 2>&1\r
171      test_debug "cat $GNUPGHOME/import.log"\r
172      if (gpg --quick-random --version >/dev/null 2>&1) ; then\r
173         echo quick-random >> "$GNUPGHOME"/gpg.conf\r
174 diff --git a/test/emacs b/test/emacs\r
175 index 6f82b08..f91078e 100755\r
176 --- a/test/emacs\r
177 +++ b/test/emacs\r
178 @@ -2,7 +2,7 @@\r
179  test_description="emacs interface"\r
180  . test-lib.sh\r
181  \r
182 -EXPECTED=../emacs.expected-output\r
183 +EXPECTED=$TEST_DIRECTORY/emacs.expected-output\r
184  \r
185  add_email_corpus\r
186  \r
187 @@ -81,7 +81,7 @@ mkdir -p mail/sent/cur\r
188  mkdir -p mail/sent/new\r
189  mkdir -p mail/sent/tmp\r
190  \r
191 -../smtp-dummy sent_message &\r
192 +$TEST_DIRECTORY/smtp-dummy sent_message &\r
193  smtp_dummy_pid=$!\r
194  test_emacs "(setq message-send-mail-function 'message-smtpmail-send-it) (setq smtpmail-smtp-server \"localhost\") (setq smtpmail-smtp-service \"25025\") (notmuch-hello) (notmuch-mua-mail) (message-goto-to) (insert \"user@example.com\nDate: Fri, 29 Mar 1974 10:00:00 -0000\") (message-goto-subject) (insert \"Testing message sent via SMTP\") (message-goto-body) (insert \"This is a test that messages are sent via SMTP\") (message-send-and-exit)" >/dev/null 2>&1\r
195  wait ${smtp_dummy_pid}\r
196 diff --git a/test/symbol-hiding b/test/symbol-hiding\r
197 index bb55524..5d38fb7 100755\r
198 --- a/test/symbol-hiding\r
199 +++ b/test/symbol-hiding\r
200 @@ -12,13 +12,13 @@ test_description='exception symbol hiding'\r
201  . ./test-lib.sh\r
202  \r
203  run_test(){\r
204 -    result=$(LD_LIBRARY_PATH=../../lib ./symbol-test 2>&1)\r
205 +    result=$(LD_LIBRARY_PATH=$TEST_DIRECTORY/../../lib ./symbol-test 2>&1)\r
206  }\r
207  \r
208  output="A Xapian exception occurred opening database: Couldn't stat 'fakedb/.notmuch/xapian'\r
209  caught No chert database found at path \`./nonexistant'"\r
210  \r
211 -g++ -o symbol-test -I../../lib ../symbol-test.cc -L../../lib -lnotmuch -lxapian\r
212 +g++ -o symbol-test -I$TEST_DIRECTORY/../lib $TEST_DIRECTORY/symbol-test.cc -L$TEST_DIRECTORY/../lib -lnotmuch -lxapian\r
213  mkdir -p fakedb/.notmuch\r
214  test_expect_success 'running test' run_test\r
215  test_begin_subtest 'checking output'\r
216 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
217 index cc20f41..352be39 100755\r
218 --- a/test/test-lib.sh\r
219 +++ b/test/test-lib.sh\r
220 @@ -392,7 +392,7 @@ emacs_deliver_message ()\r
221      shift 2\r
222      # before we can send a message, we have to prepare the FCC maildir\r
223      mkdir -p "$MAIL_DIR"/sent/{cur,new,tmp}\r
224 -    ../smtp-dummy sent_message &\r
225 +    $TEST_DIRECTORY/smtp-dummy sent_message &\r
226      smtp_dummy_pid=$!\r
227      test_emacs "(setq message-send-mail-function 'message-smtpmail-send-it) (setq smtpmail-smtp-server \"localhost\") (setq smtpmail-smtp-service \"25025\") (notmuch-hello) (notmuch-mua-mail) (message-goto-to) (insert \"test_suite@notmuchmail.org\nDate: 01 Jan 2000 12:00:00 -0000\") (message-goto-subject) (insert \"${subject}\") (message-goto-body) (insert \"${body}\") $@ (message-send-and-exit)" >/dev/null 2>&1\r
228      wait ${smtp_dummy_pid}\r
229 @@ -408,12 +408,12 @@ emacs_deliver_message ()\r
230  add_email_corpus ()\r
231  {\r
232      rm -rf ${MAIL_DIR}\r
233 -    if [ -d ../corpus.mail ]; then\r
234 -       cp -a ../corpus.mail ${MAIL_DIR}\r
235 +    if [ -d $TEST_DIRECTORY/corpus.mail ]; then\r
236 +       cp -a $TEST_DIRECTORY/corpus.mail ${MAIL_DIR}\r
237      else\r
238 -       cp -a ../corpus ${MAIL_DIR}\r
239 +       cp -a $TEST_DIRECTORY/corpus ${MAIL_DIR}\r
240         notmuch new >/dev/null\r
241 -       cp -a ${MAIL_DIR} ../corpus.mail\r
242 +       cp -a ${MAIL_DIR} $TEST_DIRECTORY/corpus.mail\r
243      fi\r
244  }\r
245  \r
246 @@ -860,8 +860,8 @@ fi\r
247  # set-frame-width      80 columns (avoids crazy 10-column default of --batch)\r
248  \r
249  emacs \$BATCH --no-init-file --no-site-file \\r
250 -       --directory ../../emacs --load notmuch.el \\r
251 -       --directory .. --load test-lib.el \\r
252 +       --directory $TEST_DIRECTORY/../emacs --load notmuch.el \\r
253 +       --directory $TEST_DIRECTORY --load test-lib.el \\r
254         --eval "(defun notmuch-test-wait ()\r
255                         (while (get-buffer-process (current-buffer))\r
256                                 (sleep-for 0.1)))" \\r
257 @@ -925,11 +925,11 @@ then\r
258                     test ! -d "$symlink_target" &&\r
259                     test "#!" != "$(head -c 2 < "$symlink_target")"\r
260                 then\r
261 -                       symlink_target=../valgrind.sh\r
262 +                       symlink_target=$TEST_DIRECTORY/valgrind.sh\r
263                 fi\r
264                 case "$base" in\r
265                 *.sh|*.perl)\r
266 -                       symlink_target=../unprocessed-script\r
267 +                       symlink_target=$TEST_DIRECTORY/unprocessed-script\r
268                 esac\r
269                 # create the link, or replace it if it is out of date\r
270                 make_symlink "$symlink_target" "$GIT_VALGRIND/bin/$base" || exit\r
271 -- \r
272 1.7.4.1\r
273 \r