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 EA5CB429E35
\r
6 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:12:55 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 2US1H-xAwF4F for <notmuch@notmuchmail.org>;
\r
17 Tue, 17 Jan 2012 05:12:55 -0800 (PST)
\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-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 120DA429E2F
\r
22 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:12:54 -0800 (PST)
\r
23 Received: by bkty12 with SMTP id y12so517886bkt.26
\r
24 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:12:53 -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:in-reply-to:references:user-agent:date:message-id
\r
27 :mime-version:content-type:content-transfer-encoding;
\r
28 bh=QVmeDejrn907aMVyvcLo8AvIBWjpT3KpdVoyDwkdNhw=;
\r
29 b=ZAcuF1LfH7ebvZfwaqycWox/oTp2E38zhvBVwRAacHMhsBsDPvNOTjr1uECH0bblTE
\r
30 jkTflgKhHS1K4nbseX+GKLTlCFaoRAQouQmLQoUklnVc7Ehe504CMDrpSS9WUOc2iF4A
\r
31 wZ4T9nV9jBKPey0w2V/ef7GRTiTSrrbF8MtcE=
\r
32 Received: by 10.204.151.195 with SMTP id d3mr6550908bkw.73.1326805973640;
\r
33 Tue, 17 Jan 2012 05:12:53 -0800 (PST)
\r
34 Received: from localhost ([91.144.186.21])
\r
35 by mx.google.com with ESMTPS id jt2sm47139358bkb.1.2012.01.17.05.12.52
\r
36 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Tue, 17 Jan 2012 05:12:53 -0800 (PST)
\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
39 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
\r
40 Subject: Re: [PATCH 2/4] test: Add address cleaning tests.
\r
41 In-Reply-To: <1326804748-8989-3-git-send-email-dme@dme.org>
\r
42 References: <1326804748-8989-1-git-send-email-dme@dme.org>
\r
43 <1326804748-8989-3-git-send-email-dme@dme.org>
\r
44 User-Agent: Notmuch/0.11+73~g8a5402e (http://notmuchmail.org) Emacs/23.3.1
\r
45 (x86_64-pc-linux-gnu)
\r
46 Date: Tue, 17 Jan 2012 17:11:58 +0400
\r
47 Message-ID: <87mx9m323l.fsf@gmail.com>
\r
49 Content-Type: text/plain; charset=utf-8
\r
50 Content-Transfer-Encoding: quoted-printable
\r
51 X-BeenThere: notmuch@notmuchmail.org
\r
52 X-Mailman-Version: 2.1.13
\r
54 List-Id: "Use and development of the notmuch mail system."
\r
55 <notmuch.notmuchmail.org>
\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
59 List-Post: <mailto:notmuch@notmuchmail.org>
\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
62 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
63 X-List-Received-Date: Tue, 17 Jan 2012 13:12:56 -0000
\r
65 On Tue, 17 Jan 2012 12:52:26 +0000, David Edmondson <dme@dme.org> wrote:
\r
66 > Including some more test framework in test-lib.el.
\r
68 > test/address-cleaning.el | 29 +++++++++++++++++++++++++++++
\r
69 > test/address-cleaning.sh | 11 +++++++++++
\r
70 > test/notmuch-test | 1 +
\r
71 > test/test-lib.el | 29 +++++++++++++++++++++++++++++
\r
72 > 4 files changed, 70 insertions(+), 0 deletions(-)
\r
73 > create mode 100644 test/address-cleaning.el
\r
74 > create mode 100755 test/address-cleaning.sh
\r
77 Since test/ directory is used for all kind of tests not just Emacs
\r
78 UI-specific, so I think address-cleaning.* files should be
\r
79 emacs-address-cleaning.
\r
84 > diff --git a/test/address-cleaning.el b/test/address-cleaning.el
\r
85 > new file mode 100644
\r
86 > index 0000000..59e8d92
\r
88 > +++ b/test/address-cleaning.el
\r
90 > +(defun notmuch-test-address-cleaning-1 ()
\r
91 > + (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")
\r
94 > +(defun notmuch-test-address-cleaning-2 ()
\r
95 > + (let* ((input '("foo@bar.com"
\r
97 > + "Foo Bar <foo@bar.com>"
\r
98 > + "foo@bar.com <foo@bar.com>"
\r
99 > + "\"Foo Bar\" <foo@bar.com>"))
\r
100 > + (expected '("foo@bar.com"
\r
102 > + "Foo Bar <foo@bar.com>"
\r
104 > + "Foo Bar <foo@bar.com>"))
\r
105 > + (output (mapcar #'notmuch-show-clean-address input)))
\r
106 > + (notmuch-test-compare output expected)))
\r
108 > +(defun notmuch-test-address-cleaning-3 ()
\r
109 > + (let* ((input '("=D0=94=D0=91 <db-uknot@stop.me.uk>"
\r
110 > + "foo (at home) <foo@bar.com>"
\r
111 > + "foo [at home] <foo@bar.com>"
\r
113 > + (expected '("=D0=94=D0=91 <db-uknot@stop.me.uk>"
\r
114 > + "foo (at home) <foo@bar.com>"
\r
115 > + "foo [at home] <foo@bar.com>"
\r
117 > + (output (mapcar #'notmuch-show-clean-address input)))
\r
118 > + (notmuch-test-compare output expected)))
\r
119 > diff --git a/test/address-cleaning.sh b/test/address-cleaning.sh
\r
120 > new file mode 100755
\r
121 > index 0000000..7ec011a
\r
123 > +++ b/test/address-cleaning.sh
\r
125 > +#!/usr/bin/env bash
\r
127 > +test_description=3D"emacs address cleaning"
\r
130 > +for i in 1 2 3; do
\r
131 > + test_emacs_expect_t "notmuch-test-address-clean-$i" \
\r
132 > + '(load "address-cleaning.el") (notmuch-test-address-cleaning-'$i')'
\r
136 > diff --git a/test/notmuch-test b/test/notmuch-test
\r
137 > index d034f99..7768c32 100755
\r
138 > --- a/test/notmuch-test
\r
139 > +++ b/test/notmuch-test
\r
140 > @@ -53,6 +53,7 @@ TESTS=3D"
\r
143 > emacs-test-functions.sh
\r
144 > + address-cleaning.sh
\r
146 > TESTS=3D${NOTMUCH_TESTS:=3D$TESTS}
\r
148 > diff --git a/test/test-lib.el b/test/test-lib.el
\r
149 > index 3b817c3..cf8a46d 100644
\r
150 > --- a/test/test-lib.el
\r
151 > +++ b/test/test-lib.el
\r
152 > @@ -20,6 +20,8 @@
\r
154 > ;; Authors: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
156 > +(require 'cl) ;; This code is generally used uncompiled.
\r
158 > ;; `read-file-name' by default uses `completing-read' function to read
\r
159 > ;; user input. It does not respect `standard-input' variable which we
\r
160 > ;; use in tests to provide user input. So replace it with a plain
\r
161 > @@ -76,3 +78,30 @@ nothing."
\r
163 > (add-hook-counter 'notmuch-hello-mode-hook)
\r
164 > (add-hook-counter 'notmuch-hello-refresh-hook)
\r
166 > +;; Functions to help when writing tests:
\r
168 > +(defun notmuch-test-reporter (output expected)
\r
169 > + "Report that the `output' does not match the `expected' result."
\r
170 > + (concat "Expect:\t" (prin1-to-string expected) "\n"
\r
171 > + "Output:\t" (prin1-to-string output) "\n"))
\r
173 > +(defun notmuch-test-unsimilar (output expected)
\r
174 > + "`output' and `expected' are dissimilar. Show a summary of
\r
175 > +the differences, ignoring similarities."
\r
176 > + (cond ((and (listp output)
\r
177 > + (listp expected))
\r
178 > + (apply #'concat (loop for o in output
\r
179 > + for e in expected
\r
180 > + if (not (equal o e))
\r
181 > + collect (notmuch-test-reporter o e))))
\r
184 > + ;; Catch all case.
\r
185 > + (notmuch-test-reporter output expected))))
\r
187 > +(defun notmuch-test-compare (output expected)
\r
188 > + "Compare `output' with `expected'. Report any discrepencies."
\r
189 > + (if (equal output expected)
\r
191 > + (notmuch-test-unsimilar output expected)))
\r
195 > _______________________________________________
\r
196 > notmuch mailing list
\r
197 > notmuch@notmuchmail.org
\r
198 > http://notmuchmail.org/mailman/listinfo/notmuch
\r