[PATCH 8/8] cli: optionally restore message properties from dump file
[notmuch-archives.git] / 51 / 8837137eb7c033f65fda506923d32c46c43703
1 Return-Path: <amdragon@mit.edu>\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 54158431FC2\r
6         for <notmuch@notmuchmail.org>; Fri, 17 May 2013 21:32:21 -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.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id H5abnrBeF5kz for <notmuch@notmuchmail.org>;\r
16         Fri, 17 May 2013 21:32:15 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU\r
18         [18.9.25.12])\r
19         by olra.theworths.org (Postfix) with ESMTP id EE3EA431FC9\r
20         for <notmuch@notmuchmail.org>; Fri, 17 May 2013 21:32:14 -0700 (PDT)\r
21 X-AuditID: 1209190c-b7f566d000004c69-63-5197044e7391\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id BE.94.19561.E4407915; Sat, 18 May 2013 00:32:14 -0400 (EDT)\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH-1.MIT.EDU [18.9.28.11])\r
26         by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id r4I4WCc1009843; \r
27         Sat, 18 May 2013 00:32:13 -0400\r
28 Received: from drake.dyndns.org\r
29         (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [216.15.114.40]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id r4I4WBLA018834\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Sat, 18 May 2013 00:32:12 -0400\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1UdYo1-0001Yy-KF; Sat, 18 May 2013 00:31:41 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject: [PATCH 3/5] emacs: Use async process helper for search\r
41 Date: Sat, 18 May 2013 00:31:10 -0400\r
42 Message-Id: <1368851472-5382-4-git-send-email-amdragon@mit.edu>\r
43 X-Mailer: git-send-email 1.7.10.4\r
44 In-Reply-To: <1368851472-5382-1-git-send-email-amdragon@mit.edu>\r
45 References: <1368851472-5382-1-git-send-email-amdragon@mit.edu>\r
46 X-Brightmail-Tracker:\r
47  H4sIAAAAAAAAA+NgFtrDIsWRmVeSWpSXmKPExsUixG6nruvHMj3QYOZPOYvVc3ksrt+cyezA\r
48         5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZdz9sZi9YLZyxYVvD1kbGG9LdzFyckgImEg8\r
49         fP6LCcIWk7hwbz1bFyMXh5DAPkaJn99bGSGcjYwSd081MoNUCQncYZKYfiofIjGXUeJ2200W\r
50         kASbgIbEtv3LGUFsEQFpiZ13Z7OC2MwCjhKf9y9iA7GFBewlLp1uZAexWQRUJXo//gazeYHi\r
51         syb9Z4E4Q1Gi+9kEsHpOAQeJw/OPsUEstpfounCTbQIj/wJGhlWMsim5Vbq5iZk5xanJusXJ\r
52         iXl5qUW6hnq5mSV6qSmlmxhBgcQpybOD8c1BpUOMAhyMSjy8H1ynBQqxJpYVV+YeYpTkYFIS\r
53         5TX5BxTiS8pPqcxILM6ILyrNSS0+xCjBwawkwvu8GCjHm5JYWZValA+TkuZgURLnvZxy019I\r
54         ID2xJDU7NbUgtQgmK8PBoSTBq8s8PVBIsCg1PbUiLTOnBCHNxMEJMpwHaLgVSA1vcUFibnFm\r
55         OkT+FKOilDivM0hCACSRUZoH1wuL9FeM4kCvCPNKg1TxAJMEXPcroMFMQINZr00FGVySiJCS\r
56         amBk7ggodC95N+dsXeJLvZcTbl0u7t0Vv7XbaLHQy7xnC6el2VpcMd5i+PO7sz2bwDK/B7vd\r
57         JfV+ZHz5e/9F6tcGudP2FlIaCSXfTlZcdljq3KPj3HFgLoddZkzBg34HwUTV+pen/y94p6T9\r
58         hPPzzlVblR+fc39mw7F5glnoSfGq8h3ZK60kr95RYinOSDTUYi4qTgQAepkY8M8CAAA=\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Sat, 18 May 2013 04:32:21 -0000\r
72 \r
73 Previously, search started the async notmuch process directly.  Now,\r
74 it uses `notmuch-start-notmuch'.  This simplifies the process sentinel\r
75 a bit and means that we no longer have to worry about errors\r
76 interleaved with the JSON output.\r
77 \r
78 We also update the tests of Emacs error handling, since the error\r
79 output is now separated from the search results buffer.\r
80 ---\r
81  emacs/notmuch.el |   19 +++++--------------\r
82  test/emacs       |   36 ++++++++++++++++++++++++++++++++----\r
83  2 files changed, 37 insertions(+), 18 deletions(-)\r
84 \r
85 diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
86 index 4c1a6ca..b8d9c44 100644\r
87 --- a/emacs/notmuch.el\r
88 +++ b/emacs/notmuch.el\r
89 @@ -653,15 +653,8 @@ of the result."\r
90                     ;; For version mismatch, there's no point in\r
91                     ;; showing the search buffer\r
92                     (when (or (= exit-status 20) (= exit-status 21))\r
93 -                     (kill-buffer))\r
94 -                   (condition-case err\r
95 -                       (notmuch-check-async-exit-status proc msg)\r
96 -                     ;; Suppress the error signal since strange\r
97 -                     ;; things happen if a sentinel signals.  Mimic\r
98 -                     ;; the top-level's handling of error messages.\r
99 -                     (error\r
100 -                      (message "%s" (error-message-string err))\r
101 -                      (throw 'return nil)))\r
102 +                     (kill-buffer)\r
103 +                     (throw 'return nil))\r
104                     (if (and atbob\r
105                              (not (string= notmuch-search-target-thread "found")))\r
106                         (set 'never-found-target-thread t)))))\r
107 @@ -938,10 +931,9 @@ Other optional parameters are used as follows:\r
108        (erase-buffer)\r
109        (goto-char (point-min))\r
110        (save-excursion\r
111 -       (let ((proc (start-process\r
112 -                    "notmuch-search" buffer\r
113 -                    notmuch-command "search"\r
114 -                    "--format=json" "--format-version=1"\r
115 +       (let ((proc (notmuch-start-notmuch\r
116 +                    "notmuch-search" buffer #'notmuch-search-process-sentinel\r
117 +                    "search" "--format=json" "--format-version=1"\r
118                      (if oldest-first\r
119                          "--sort=oldest-first"\r
120                        "--sort=newest-first")\r
121 @@ -951,7 +943,6 @@ Other optional parameters are used as follows:\r
122               ;; should be called no matter how the process dies.\r
123               (parse-buf (generate-new-buffer " *notmuch search parse*")))\r
124           (process-put proc 'parse-buf parse-buf)\r
125 -         (set-process-sentinel proc 'notmuch-search-process-sentinel)\r
126           (set-process-filter proc 'notmuch-search-process-filter)\r
127           (set-process-query-on-exit-flag proc nil))))\r
128      (run-hooks 'notmuch-search-hook)))\r
129 diff --git a/test/emacs b/test/emacs\r
130 index f033bdf..d38ae8c 100755\r
131 --- a/test/emacs\r
132 +++ b/test/emacs\r
133 @@ -853,11 +853,10 @@ test_expect_success "Rendering HTML mail with images" \\r
134      'cat OUTPUT && grep -q smiley OUTPUT'\r
135  \r
136  \r
137 -test_begin_subtest "Search handles subprocess errors"\r
138 +test_begin_subtest "Search handles subprocess error exit codes"\r
139  cat > notmuch_fail <<EOF\r
140  #!/bin/sh\r
141  echo This is output\r
142 -echo This is an error >&2\r
143  exit 1\r
144  EOF\r
145  chmod a+x notmuch_fail\r
146 @@ -874,8 +873,6 @@ sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
147  test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
148  Error: Unexpected output from notmuch search:\r
149  This is output\r
150 -Error: Unexpected output from notmuch search:\r
151 -This is an error\r
152  End of search results.\r
153  ---\r
154  $PWD/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)\r
155 @@ -885,4 +882,35 @@ $PWD/notmuch_fail exited with status 1\r
156  command: $PWD/notmuch_fail search --format\=json --format-version\=1 --sort\=newest-first tag\:inbox\r
157  exit status: 1"\r
158  \r
159 +test_begin_subtest "Search handles subprocess warnings"\r
160 +cat > notmuch_fail <<EOF\r
161 +#!/bin/sh\r
162 +echo This is output\r
163 +echo This is a warning >&2\r
164 +echo This is another warning >&2\r
165 +exit 0\r
166 +EOF\r
167 +chmod a+x notmuch_fail\r
168 +test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))\r
169 +              (with-current-buffer \"*Messages*\" (erase-buffer))\r
170 +              (with-current-buffer \"*Notmuch errors*\" (erase-buffer))\r
171 +              (notmuch-search \"tag:inbox\")\r
172 +              (notmuch-test-wait)\r
173 +              (with-current-buffer \"*Messages*\"\r
174 +                 (test-output \"MESSAGES\"))\r
175 +              (with-current-buffer \"*Notmuch errors*\"\r
176 +                 (test-output \"ERROR\"))\r
177 +              (test-output))"\r
178 +sed -i -e 's/^\[.*\]$/[XXX]/' ERROR\r
179 +test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\\r
180 +Error: Unexpected output from notmuch search:\r
181 +This is output\r
182 +End of search results.\r
183 +---\r
184 +This is a warning (see *Notmuch errors* for more details)\r
185 +---\r
186 +[XXX]\r
187 +This is a warning\r
188 +This is another warning"\r
189 +\r
190  test_done\r
191 -- \r
192 1.7.10.4\r
193 \r