Re: (emacs) Parsing problems replying to encrypted html
[notmuch-archives.git] / f5 / d6a60fcecfc2fbdfffdda9bdd885bbe98eb068
1 Return-Path: <dme@dme.org>\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 8EA4C421192\r
6         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:07:14 -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.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 suQ2ib5OpIrE for <notmuch@notmuchmail.org>;\r
16         Tue, 17 Jan 2012 06:07:12 -0800 (PST)\r
17 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
18         [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
19         (No client certificate requested)\r
20         by olra.theworths.org (Postfix) with ESMTPS id 44BA7429E2F\r
21         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:07:12 -0800 (PST)\r
22 Received: by wibhr12 with SMTP id hr12so3471746wib.26\r
23         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:07:11 -0800 (PST)\r
24 Received: by 10.180.73.72 with SMTP id j8mr17867301wiv.2.1326809230987;\r
25         Tue, 17 Jan 2012 06:07:10 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id dr7sm13867947wib.3.2012.01.17.06.07.06\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Tue, 17 Jan 2012 06:07:09 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id A15DDA0501; Tue, 17 Jan 2012 14:07:05 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH 3/3] test: Add address cleaning tests.\r
36 Date: Tue, 17 Jan 2012 14:07:04 +0000\r
37 Message-Id: <1326809224-22673-3-git-send-email-dme@dme.org>\r
38 X-Mailer: git-send-email 1.7.7.3\r
39 In-Reply-To: <1326809224-22673-1-git-send-email-dme@dme.org>\r
40 References: <87pqei327k.fsf@gmail.com>\r
41         <1326809224-22673-1-git-send-email-dme@dme.org>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=UTF-8\r
44 Content-Transfer-Encoding: 8bit\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: Tue, 17 Jan 2012 14:07:15 -0000\r
58 \r
59 Including some more test framework in test-lib.el.\r
60 ---\r
61 \r
62 notmuch-test-address-cleaning-3 currently fails, in order that you can\r
63 see the output format in that case.\r
64 \r
65  test/emacs-address-cleaning.el |   29 +++++++++++++++++++++++++++++\r
66  test/emacs-address-cleaning.sh |   12 ++++++++++++\r
67  test/notmuch-test              |    1 +\r
68  test/test-lib.el               |   29 +++++++++++++++++++++++++++++\r
69  4 files changed, 71 insertions(+), 0 deletions(-)\r
70  create mode 100644 test/emacs-address-cleaning.el\r
71  create mode 100755 test/emacs-address-cleaning.sh\r
72 \r
73 diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el\r
74 new file mode 100644\r
75 index 0000000..59e8d92\r
76 --- /dev/null\r
77 +++ b/test/emacs-address-cleaning.el\r
78 @@ -0,0 +1,29 @@\r
79 +(defun notmuch-test-address-cleaning-1 ()\r
80 +  (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")\r
81 +                       "dme@dme.org"))\r
82 +\r
83 +(defun notmuch-test-address-cleaning-2 ()\r
84 +  (let* ((input '("foo@bar.com"\r
85 +                 "<foo@bar.com>"\r
86 +                 "Foo Bar <foo@bar.com>"\r
87 +                 "foo@bar.com <foo@bar.com>"\r
88 +                 "\"Foo Bar\" <foo@bar.com>"))\r
89 +        (expected '("foo@bar.com"\r
90 +                    "foo@bar.com"\r
91 +                    "Foo Bar <foo@bar.com>"\r
92 +                    "foo@bar.com"\r
93 +                    "Foo Bar <foo@bar.com>"))\r
94 +        (output (mapcar #'notmuch-show-clean-address input)))\r
95 +    (notmuch-test-compare output expected)))\r
96 +\r
97 +(defun notmuch-test-address-cleaning-3 ()\r
98 +  (let* ((input '("ДБ <db-uknot@stop.me.uk>"\r
99 +                 "foo (at home) <foo@bar.com>"\r
100 +                 "foo [at home] <foo@bar.com>"\r
101 +                 "Foo Bar"))\r
102 +        (expected '("ДБ <db-uknot@stop.me.uk>"\r
103 +                    "foo (at home) <foo@bar.com>"\r
104 +                    "foo [at home] <foo@bar.com>"\r
105 +                    "Foo Bar"))\r
106 +        (output (mapcar #'notmuch-show-clean-address input)))\r
107 +    (notmuch-test-compare output expected)))\r
108 diff --git a/test/emacs-address-cleaning.sh b/test/emacs-address-cleaning.sh\r
109 new file mode 100755\r
110 index 0000000..1a6eff5\r
111 --- /dev/null\r
112 +++ b/test/emacs-address-cleaning.sh\r
113 @@ -0,0 +1,12 @@\r
114 +#!/usr/bin/env bash\r
115 +\r
116 +test_description="emacs address cleaning"\r
117 +. test-lib.sh\r
118 +\r
119 +for i in 1 2 3; do\r
120 +    test_begin_subtest "notmuch-test-address-clean-$i"\r
121 +    test_emacs_expect_t \\r
122 +       '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-'$i')'\r
123 +done\r
124 +\r
125 +test_done\r
126 diff --git a/test/notmuch-test b/test/notmuch-test\r
127 index d034f99..3f1740c 100755\r
128 --- a/test/notmuch-test\r
129 +++ b/test/notmuch-test\r
130 @@ -53,6 +53,7 @@ TESTS="\r
131    hooks\r
132    argument-parsing\r
133    emacs-test-functions.sh\r
134 +  emacs-address-cleaning.sh\r
135  "\r
136  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
137  \r
138 diff --git a/test/test-lib.el b/test/test-lib.el\r
139 index 3b817c3..cf8a46d 100644\r
140 --- a/test/test-lib.el\r
141 +++ b/test/test-lib.el\r
142 @@ -20,6 +20,8 @@\r
143  ;;\r
144  ;; Authors: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
145  \r
146 +(require 'cl)  ;; This code is generally used uncompiled.\r
147 +\r
148  ;; `read-file-name' by default uses `completing-read' function to read\r
149  ;; user input.  It does not respect `standard-input' variable which we\r
150  ;; use in tests to provide user input.  So replace it with a plain\r
151 @@ -76,3 +78,30 @@ nothing."\r
152  \r
153  (add-hook-counter 'notmuch-hello-mode-hook)\r
154  (add-hook-counter 'notmuch-hello-refresh-hook)\r
155 +\r
156 +;; Functions to help when writing tests:\r
157 +\r
158 +(defun notmuch-test-reporter (output expected)\r
159 +  "Report that the `output' does not match the `expected' result."\r
160 +  (concat "Expect:\t" (prin1-to-string expected) "\n"\r
161 +         "Output:\t" (prin1-to-string output) "\n"))\r
162 +\r
163 +(defun notmuch-test-unsimilar (output expected)\r
164 +  "`output' and `expected' are dissimilar. Show a summary of\r
165 +the differences, ignoring similarities."\r
166 +  (cond ((and (listp output)\r
167 +             (listp expected))\r
168 +        (apply #'concat (loop for o in output\r
169 +                              for e in expected\r
170 +                              if (not (equal o e))\r
171 +                              collect (notmuch-test-reporter o e))))\r
172 +\r
173 +       (t\r
174 +        ;; Catch all case.\r
175 +        (notmuch-test-reporter output expected))))\r
176 +\r
177 +(defun notmuch-test-compare (output expected)\r
178 +  "Compare `output' with `expected'. Report any discrepencies."\r
179 +  (if (equal output expected)\r
180 +      t\r
181 +    (notmuch-test-unsimilar output expected)))\r
182 -- \r
183 1.7.7.3\r
184 \r