Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / 61 / d561859473cb0bb990ede7f243f61349cd010c
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 0BFAC431FBD\r
6         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 04:54:12 -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 CA0zrFlwPsFe for <notmuch@notmuchmail.org>;\r
16         Thu, 19 Jan 2012 04:54:11 -0800 (PST)\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
18         [74.125.82.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 D5A1C431FAE\r
21         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 04:54:10 -0800 (PST)\r
22 Received: by mail-we0-f181.google.com with SMTP id p13so2507773wer.26\r
23         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 04:54:10 -0800 (PST)\r
24 Received: by 10.216.136.152 with SMTP id w24mr5289114wei.50.1326977650539;\r
25         Thu, 19 Jan 2012 04:54: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 ex2sm65943483wib.1.2012.01.19.04.54.07\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Thu, 19 Jan 2012 04:54:08 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id 15CBF9FEC4; Thu, 19 Jan 2012 12:54:06 +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: Thu, 19 Jan 2012 12:54:03 +0000\r
37 Message-Id: <1326977643-19792-3-git-send-email-dme@dme.org>\r
38 X-Mailer: git-send-email 1.7.8.3\r
39 In-Reply-To: <1326977643-19792-1-git-send-email-dme@dme.org>\r
40 References: <yf639bcarcs.fsf@taco2.nixu.fi>\r
41         <1326977643-19792-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: Thu, 19 Jan 2012 12:54:12 -0000\r
58 \r
59 Including some more test framework in test-lib.el.\r
60 ---\r
61  test/emacs-address-cleaning.el |   29 +++++++++++++++++++++++++++++\r
62  test/emacs-address-cleaning.sh |   12 ++++++++++++\r
63  test/notmuch-test              |    1 +\r
64  test/test-lib.el               |   30 ++++++++++++++++++++++++++++++\r
65  4 files changed, 72 insertions(+), 0 deletions(-)\r
66  create mode 100644 test/emacs-address-cleaning.el\r
67  create mode 100755 test/emacs-address-cleaning.sh\r
68 \r
69 diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el\r
70 new file mode 100644\r
71 index 0000000..59e8d92\r
72 --- /dev/null\r
73 +++ b/test/emacs-address-cleaning.el\r
74 @@ -0,0 +1,29 @@\r
75 +(defun notmuch-test-address-cleaning-1 ()\r
76 +  (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")\r
77 +                       "dme@dme.org"))\r
78 +\r
79 +(defun notmuch-test-address-cleaning-2 ()\r
80 +  (let* ((input '("foo@bar.com"\r
81 +                 "<foo@bar.com>"\r
82 +                 "Foo Bar <foo@bar.com>"\r
83 +                 "foo@bar.com <foo@bar.com>"\r
84 +                 "\"Foo Bar\" <foo@bar.com>"))\r
85 +        (expected '("foo@bar.com"\r
86 +                    "foo@bar.com"\r
87 +                    "Foo Bar <foo@bar.com>"\r
88 +                    "foo@bar.com"\r
89 +                    "Foo Bar <foo@bar.com>"))\r
90 +        (output (mapcar #'notmuch-show-clean-address input)))\r
91 +    (notmuch-test-compare output expected)))\r
92 +\r
93 +(defun notmuch-test-address-cleaning-3 ()\r
94 +  (let* ((input '("ДБ <db-uknot@stop.me.uk>"\r
95 +                 "foo (at home) <foo@bar.com>"\r
96 +                 "foo [at home] <foo@bar.com>"\r
97 +                 "Foo Bar"))\r
98 +        (expected '("ДБ <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 +        (output (mapcar #'notmuch-show-clean-address input)))\r
103 +    (notmuch-test-compare output expected)))\r
104 diff --git a/test/emacs-address-cleaning.sh b/test/emacs-address-cleaning.sh\r
105 new file mode 100755\r
106 index 0000000..1a6eff5\r
107 --- /dev/null\r
108 +++ b/test/emacs-address-cleaning.sh\r
109 @@ -0,0 +1,12 @@\r
110 +#!/usr/bin/env bash\r
111 +\r
112 +test_description="emacs address cleaning"\r
113 +. test-lib.sh\r
114 +\r
115 +for i in 1 2 3; do\r
116 +    test_begin_subtest "notmuch-test-address-clean-$i"\r
117 +    test_emacs_expect_t \\r
118 +       '(load "emacs-address-cleaning.el") (notmuch-test-address-cleaning-'$i')'\r
119 +done\r
120 +\r
121 +test_done\r
122 diff --git a/test/notmuch-test b/test/notmuch-test\r
123 index d034f99..3f1740c 100755\r
124 --- a/test/notmuch-test\r
125 +++ b/test/notmuch-test\r
126 @@ -53,6 +53,7 @@ TESTS="\r
127    hooks\r
128    argument-parsing\r
129    emacs-test-functions.sh\r
130 +  emacs-address-cleaning.sh\r
131  "\r
132  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
133  \r
134 diff --git a/test/test-lib.el b/test/test-lib.el\r
135 index 1d51b8d..033270d 100644\r
136 --- a/test/test-lib.el\r
137 +++ b/test/test-lib.el\r
138 @@ -20,6 +20,8 @@\r
139  ;;\r
140  ;; Authors: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
141  \r
142 +(require 'cl)  ;; This code is generally used uncompiled.\r
143 +\r
144  ;; `read-file-name' by default uses `completing-read' function to read\r
145  ;; user input.  It does not respect `standard-input' variable which we\r
146  ;; use in tests to provide user input.  So replace it with a plain\r
147 @@ -77,6 +79,7 @@ nothing."\r
148  (add-hook-counter 'notmuch-hello-mode-hook)\r
149  (add-hook-counter 'notmuch-hello-refresh-hook)\r
150  \r
151 +\r
152  (defmacro notmuch-test-run-test (&rest body)\r
153    "Evaluate a BODY of test expressions and output the result."\r
154    `(with-temp-buffer\r
155 @@ -85,3 +88,30 @@ nothing."\r
156                    result\r
157                  (prin1-to-string result)))\r
158         (test-output))))\r
159 +\r
160 +;; Functions to help when writing tests:\r
161 +\r
162 +(defun notmuch-test-reporter (output expected)\r
163 +  "Report that the `output' does not match the `expected' result."\r
164 +  (concat "Expect:\t" (prin1-to-string expected) "\n"\r
165 +         "Output:\t" (prin1-to-string output) "\n"))\r
166 +\r
167 +(defun notmuch-test-unsimilar (output expected)\r
168 +  "`output' and `expected' are dissimilar. Show a summary of\r
169 +the differences, ignoring similarities."\r
170 +  (cond ((and (listp output)\r
171 +             (listp expected))\r
172 +        (apply #'concat (loop for o in output\r
173 +                              for e in expected\r
174 +                              if (not (equal o e))\r
175 +                              collect (notmuch-test-reporter o e))))\r
176 +\r
177 +       (t\r
178 +        ;; Catch all case.\r
179 +        (notmuch-test-reporter output expected))))\r
180 +\r
181 +(defun notmuch-test-compare (output expected)\r
182 +  "Compare `output' with `expected'. Report any discrepencies."\r
183 +  (if (equal output expected)\r
184 +      t\r
185 +    (notmuch-test-unsimilar output expected)))\r
186 -- \r
187 1.7.8.3\r
188 \r