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 886B241A549
\r
6 for <notmuch@notmuchmail.org>; Thu, 25 Nov 2010 03:03:27 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_NONE=-0.0001] 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 9asNrB98rMer for <notmuch@notmuchmail.org>;
\r
16 Thu, 25 Nov 2010 03:03:26 -0800 (PST)
\r
17 Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com
\r
19 by olra.theworths.org (Postfix) with ESMTP id 7DE71431FD0
\r
20 for <notmuch@notmuchmail.org>; Thu, 25 Nov 2010 03:03:25 -0800 (PST)
\r
21 Received: by mail-wy0-f181.google.com with SMTP id 22so827352wyf.26
\r
22 for <notmuch@notmuchmail.org>; Thu, 25 Nov 2010 03:03:25 -0800 (PST)
\r
23 Received: by 10.227.155.83 with SMTP id r19mr634010wbw.166.1290683004236;
\r
24 Thu, 25 Nov 2010 03:03:24 -0800 (PST)
\r
25 Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com
\r
27 by mx.google.com with ESMTPS id h29sm403035wbc.3.2010.11.25.03.03.18
\r
28 (version=TLSv1/SSLv3 cipher=RC4-MD5);
\r
29 Thu, 25 Nov 2010 03:03:19 -0800 (PST)
\r
30 Received: by ut.hh.sledj.net (Postfix, from userid 1000)
\r
31 id 985F359407A; Thu, 25 Nov 2010 10:59:20 +0000 (GMT)
\r
32 From: David Edmondson <dme@dme.org>
\r
33 To: notmuch@notmuchmail.org
\r
34 Subject: [PATCH 3/3] test: Add ERT tests for Fcc determination.
\r
35 Date: Thu, 25 Nov 2010 10:59:10 +0000
\r
36 Message-Id: <1290682750-30283-3-git-send-email-dme@dme.org>
\r
37 X-Mailer: git-send-email 1.7.2.3
\r
38 In-Reply-To: <1290632444-10046-1-git-send-email-cworth@cworth.org>
\r
39 References: <1290632444-10046-1-git-send-email-cworth@cworth.org>
\r
41 Content-Type: text/plain; charset=UTF-8
\r
42 Content-Transfer-Encoding: 8bit
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Thu, 25 Nov 2010 11:03:27 -0000
\r
57 Add ERT tests to cover various settings of `notmuch-fcc-dirs'.
\r
59 emacs/notmuch-test.el | 96 ++++++++++++++++++++++++++++++++++
\r
60 test/emacs-ert | 17 ++++++
\r
61 test/emacs.expected-output/emacs-ert | 9 +++
\r
62 3 files changed, 122 insertions(+), 0 deletions(-)
\r
63 create mode 100644 emacs/notmuch-test.el
\r
64 create mode 100755 test/emacs-ert
\r
65 create mode 100644 test/emacs.expected-output/emacs-ert
\r
67 diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el
\r
68 new file mode 100644
\r
69 index 0000000..ac6e5a7
\r
71 +++ b/emacs/notmuch-test.el
\r
73 +;; notmuch-test.el --- ERT based tests for notmuch.el.
\r
75 +;; Copyright © David Edmondson
\r
77 +;; This file is part of Notmuch.
\r
79 +;; Notmuch is free software: you can redistribute it and/or modify it
\r
80 +;; under the terms of the GNU General Public License as published by
\r
81 +;; the Free Software Foundation, either version 3 of the License, or
\r
82 +;; (at your option) any later version.
\r
84 +;; Notmuch is distributed in the hope that it will be useful, but
\r
85 +;; WITHOUT ANY WARRANTY; without even the implied warranty of
\r
86 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
87 +;; General Public License for more details.
\r
89 +;; You should have received a copy of the GNU General Public License
\r
90 +;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
\r
92 +;; Authors: David Edmondson <dme@dme.org>
\r
98 +(require 'notmuch-maildir-fcc)
\r
100 +(ert-deftest notmuch-fcc-trivial ()
\r
101 + "One Fcc folder."
\r
102 + (should (string= "sent"
\r
103 + (notmuch-fcc-determine-folder "sent" "foo@bar.baz"))))
\r
105 +(ert-deftest notmuch-fcc-simple ()
\r
106 + "Fcc folder matching single address."
\r
107 + (should (string= "sent"
\r
108 + (notmuch-fcc-determine-folder
\r
109 + '(("foo@bar.baz" . "sent"))
\r
110 + "foo@bar.baz"))))
\r
112 +(ert-deftest notmuch-fcc-none ()
\r
113 + "No matching Fcc folder."
\r
115 + (notmuch-fcc-determine-folder
\r
116 + '(("foo@bar.baz" . "sent"))
\r
117 + "not@bar.baz"))))
\r
119 +(ert-deftest notmuch-fcc-multiple ()
\r
120 + "Choose the correct folder from two options."
\r
121 + (let ((fcc-config '(("foo@bar.baz" . "foosent")
\r
122 + ("bar@bar.baz" . "barsent"))))
\r
124 + (should (string= "foosent"
\r
125 + (notmuch-fcc-determine-folder
\r
126 + fcc-config "foo@bar.baz")))
\r
128 + (should (string= "barsent"
\r
129 + (notmuch-fcc-determine-folder
\r
130 + fcc-config "bar@bar.baz")))))
\r
132 +(ert-deftest notmuch-fcc-regexp ()
\r
133 + "Allow a regexp in the `From' string."
\r
134 + (let ((fcc-config '(("foo@bar.baz" . "foosent")
\r
135 + (".*" . "barsent"))))
\r
137 + (should (string= "foosent"
\r
138 + (notmuch-fcc-determine-folder
\r
139 + fcc-config "foo@bar.baz")))
\r
141 + (should (string= "barsent"
\r
142 + (notmuch-fcc-determine-folder
\r
143 + fcc-config "bar@bar.baz")))))
\r
145 +(ert-deftest notmuch-fcc-oldstyle ()
\r
146 + "Raise an error for an old style configuration."
\r
149 + (should-error (notmuch-fcc-determine-folder
\r
150 + '("sent" ("not@bar.baz" . "foosent"))
\r
153 + (should-error (notmuch-fcc-determine-folder
\r
154 + '("sent" ("not@bar.baz" . "foosent"))
\r
160 +(defun notmuch-test ()
\r
161 + "Run the notmuch ERT tests."
\r
166 +(defun notmuch-test-batch ()
\r
167 + "Run the notmuch ERT tests in batch mode."
\r
168 + (ert-run-tests-batch-and-exit))
\r
169 diff --git a/test/emacs-ert b/test/emacs-ert
\r
170 new file mode 100755
\r
171 index 0000000..4a45a66
\r
173 +++ b/test/emacs-ert
\r
176 +test_description="emacs interface (ert)"
\r
179 +EXPECTED=../emacs.expected-output
\r
181 +test_begin_subtest "Emacs tests using ert"
\r
183 + --batch --no-init-file --no-site-file \
\r
184 + --directory ../../emacs --directory ../ert \
\r
185 + --load notmuch-test.el \
\r
186 + --eval "(notmuch-test-batch)" \
\r
187 + 2>&1 | sed -e 's/[0-9][0-9]*-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]*/today/g')
\r
188 +expected=$(cat $EXPECTED/emacs-ert)
\r
189 +test_expect_equal "$output" "$expected"
\r
192 diff --git a/test/emacs.expected-output/emacs-ert b/test/emacs.expected-output/emacs-ert
\r
193 new file mode 100644
\r
194 index 0000000..50f592b
\r
196 +++ b/test/emacs.expected-output/emacs-ert
\r
198 +Running 6 tests (today)
\r
199 + passed 1/6 notmuch-fcc-multiple
\r
200 + passed 2/6 notmuch-fcc-none
\r
201 + passed 3/6 notmuch-fcc-oldstyle
\r
202 + passed 4/6 notmuch-fcc-regexp
\r
203 + passed 5/6 notmuch-fcc-simple
\r
204 + passed 6/6 notmuch-fcc-trivial
\r
206 +Ran 6 tests, 6 results as expected (today)
\r