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 873A742119D
\r
6 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 04:53:01 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 YAfnGIaQRHs8 for <notmuch@notmuchmail.org>;
\r
16 Tue, 17 Jan 2012 04:52:59 -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 4EAD4421195
\r
21 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 04:52:51 -0800 (PST)
\r
22 Received: by werp13 with SMTP id p13so322385wer.26
\r
23 for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 04:52:50 -0800 (PST)
\r
24 Received: by 10.216.133.29 with SMTP id p29mr6905304wei.49.1326804768133;
\r
25 Tue, 17 Jan 2012 04:52:48 -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 em13sm16621693wid.7.2012.01.17.04.52.43
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Tue, 17 Jan 2012 04:52:43 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id 04BAAA0501; Tue, 17 Jan 2012 12:52:42 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: [PATCH 2/4] test: Add address cleaning tests.
\r
36 Date: Tue, 17 Jan 2012 12:52:26 +0000
\r
37 Message-Id: <1326804748-8989-3-git-send-email-dme@dme.org>
\r
38 X-Mailer: git-send-email 1.7.7.3
\r
39 In-Reply-To: <1326804748-8989-1-git-send-email-dme@dme.org>
\r
40 References: <1326804748-8989-1-git-send-email-dme@dme.org>
\r
42 Content-Type: text/plain; charset=UTF-8
\r
43 Content-Transfer-Encoding: 8bit
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Tue, 17 Jan 2012 12:53:02 -0000
\r
58 Including some more test framework in test-lib.el.
\r
60 test/address-cleaning.el | 29 +++++++++++++++++++++++++++++
\r
61 test/address-cleaning.sh | 11 +++++++++++
\r
62 test/notmuch-test | 1 +
\r
63 test/test-lib.el | 29 +++++++++++++++++++++++++++++
\r
64 4 files changed, 70 insertions(+), 0 deletions(-)
\r
65 create mode 100644 test/address-cleaning.el
\r
66 create mode 100755 test/address-cleaning.sh
\r
68 diff --git a/test/address-cleaning.el b/test/address-cleaning.el
\r
69 new file mode 100644
\r
70 index 0000000..59e8d92
\r
72 +++ b/test/address-cleaning.el
\r
74 +(defun notmuch-test-address-cleaning-1 ()
\r
75 + (notmuch-test-compare (notmuch-show-clean-address "dme@dme.org")
\r
78 +(defun notmuch-test-address-cleaning-2 ()
\r
79 + (let* ((input '("foo@bar.com"
\r
81 + "Foo Bar <foo@bar.com>"
\r
82 + "foo@bar.com <foo@bar.com>"
\r
83 + "\"Foo Bar\" <foo@bar.com>"))
\r
84 + (expected '("foo@bar.com"
\r
86 + "Foo Bar <foo@bar.com>"
\r
88 + "Foo Bar <foo@bar.com>"))
\r
89 + (output (mapcar #'notmuch-show-clean-address input)))
\r
90 + (notmuch-test-compare output expected)))
\r
92 +(defun notmuch-test-address-cleaning-3 ()
\r
93 + (let* ((input '("ДБ <db-uknot@stop.me.uk>"
\r
94 + "foo (at home) <foo@bar.com>"
\r
95 + "foo [at home] <foo@bar.com>"
\r
97 + (expected '("ДБ <db-uknot@stop.me.uk>"
\r
98 + "foo (at home) <foo@bar.com>"
\r
99 + "foo [at home] <foo@bar.com>"
\r
101 + (output (mapcar #'notmuch-show-clean-address input)))
\r
102 + (notmuch-test-compare output expected)))
\r
103 diff --git a/test/address-cleaning.sh b/test/address-cleaning.sh
\r
104 new file mode 100755
\r
105 index 0000000..7ec011a
\r
107 +++ b/test/address-cleaning.sh
\r
109 +#!/usr/bin/env bash
\r
111 +test_description="emacs address cleaning"
\r
114 +for i in 1 2 3; do
\r
115 + test_emacs_expect_t "notmuch-test-address-clean-$i" \
\r
116 + '(load "address-cleaning.el") (notmuch-test-address-cleaning-'$i')'
\r
120 diff --git a/test/notmuch-test b/test/notmuch-test
\r
121 index d034f99..7768c32 100755
\r
122 --- a/test/notmuch-test
\r
123 +++ b/test/notmuch-test
\r
124 @@ -53,6 +53,7 @@ TESTS="
\r
127 emacs-test-functions.sh
\r
128 + address-cleaning.sh
\r
130 TESTS=${NOTMUCH_TESTS:=$TESTS}
\r
132 diff --git a/test/test-lib.el b/test/test-lib.el
\r
133 index 3b817c3..cf8a46d 100644
\r
134 --- a/test/test-lib.el
\r
135 +++ b/test/test-lib.el
\r
138 ;; Authors: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
140 +(require 'cl) ;; This code is generally used uncompiled.
\r
142 ;; `read-file-name' by default uses `completing-read' function to read
\r
143 ;; user input. It does not respect `standard-input' variable which we
\r
144 ;; use in tests to provide user input. So replace it with a plain
\r
145 @@ -76,3 +78,30 @@ nothing."
\r
147 (add-hook-counter 'notmuch-hello-mode-hook)
\r
148 (add-hook-counter 'notmuch-hello-refresh-hook)
\r
150 +;; Functions to help when writing tests:
\r
152 +(defun notmuch-test-reporter (output expected)
\r
153 + "Report that the `output' does not match the `expected' result."
\r
154 + (concat "Expect:\t" (prin1-to-string expected) "\n"
\r
155 + "Output:\t" (prin1-to-string output) "\n"))
\r
157 +(defun notmuch-test-unsimilar (output expected)
\r
158 + "`output' and `expected' are dissimilar. Show a summary of
\r
159 +the differences, ignoring similarities."
\r
160 + (cond ((and (listp output)
\r
161 + (listp expected))
\r
162 + (apply #'concat (loop for o in output
\r
163 + for e in expected
\r
164 + if (not (equal o e))
\r
165 + collect (notmuch-test-reporter o e))))
\r
168 + ;; Catch all case.
\r
169 + (notmuch-test-reporter output expected))))
\r
171 +(defun notmuch-test-compare (output expected)
\r
172 + "Compare `output' with `expected'. Report any discrepencies."
\r
173 + (if (equal output expected)
\r
175 + (notmuch-test-unsimilar output expected)))
\r