From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH] test: Add some more emacs tests.
Date: Thu, 25 Nov 2010 14:09:06 +0000 [thread overview]
Message-ID: <1290694146-8990-1-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1290682750-30283-1-git-send-email-dme@dme.org>
Simple version of the `notmuch-hello' test, some tests of the matrix
reflection code and the 're:' stripping code.
---
emacs/notmuch-test.el | 62 +++++++++++++++++++++++++++++++--
test/emacs-ert | 3 ++
test/emacs.expected-output/emacs-ert | 20 ++++++----
3 files changed, 73 insertions(+), 12 deletions(-)
diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el
index ac6e5a7..7d76537 100644
--- a/emacs/notmuch-test.el
+++ b/emacs/notmuch-test.el
@@ -23,6 +23,23 @@
;;
+(defun notmuch-test-file-as-string (filename)
+ (with-temp-buffer
+ (insert-file-contents filename)
+ (buffer-string)))
+
+;; This tends not to work well except in batch mode.
+(defun notmuch-test-expected-result (name)
+ "Get the expected result of a test as a string."
+ (notmuch-test-file-as-string
+ (concat (getenv "EXPECTED") "/" name)))
+
+(defun notmuch-test-buffer-result (fn)
+ (funcall fn)
+ (buffer-substring-no-properties (point-min) (point-max)))
+
+;;
+
(require 'notmuch-maildir-fcc)
(ert-deftest notmuch-fcc-trivial ()
@@ -85,12 +102,49 @@
;;
-(defun notmuch-test ()
- "Run the notmuch ERT tests."
- (interactive)
+(require 'notmuch-hello)
+
+(ert-deftest notmuch-hello ()
+ "Check that `notmuch-hello' outputs correct data.
+
+Presumes that the email corpus is already present."
+
+ (should (string= (notmuch-test-buffer-result 'notmuch-hello)
+ (notmuch-test-expected-result "notmuch-hello"))))
+
+(ert-deftest notmuch-hello-reflect ()
+ (should (equal '(1 4 7 10 2 5 8 11 3 6 9 12)
+ (notmuch-hello-reflect '(1 2 3 4 5 6 7 8 9 10 11 12) 4)))
+
+ (should (equal '(1 4 7 10 2 5 8 nil 3 6 9 nil)
+ (notmuch-hello-reflect '(1 2 3 4 5 6 7 8 9 10) 4))))
+
+;;
+
+(require 'notmuch-show)
+
+(ert-deftest notmuch-show-strip-re ()
+ (mapc '(lambda (test)
+ (should (string= "fish"
+ (notmuch-show-strip-re test))))
+ '("fish" "re: fish" "Re: fish" "RE: fish"))
- (ert t))
+ (mapc '(lambda (test)
+ (should (string= "some fish"
+ (notmuch-show-strip-re test))))
+ '("some fish" "re: some fish" "some re: fish"))
+
+ (mapc '(lambda (test)
+ (should-not (string= "some fish"
+ (notmuch-show-strip-re test))))
+ '(" some fish" "re: some fish " "somere: fish" "some fish re:")))
+
+;;
(defun notmuch-test-batch ()
"Run the notmuch ERT tests in batch mode."
+
+ ;; Avoid the 10 column default of `emacs --batch'.
+ (set-frame-width (window-frame (get-buffer-window)) 80)
+
(ert-run-tests-batch-and-exit))
diff --git a/test/emacs-ert b/test/emacs-ert
index 4a45a66..60da9b6 100755
--- a/test/emacs-ert
+++ b/test/emacs-ert
@@ -3,6 +3,9 @@ test_description="emacs interface (ert)"
. test-lib.sh
EXPECTED=../emacs.expected-output
+export EXPECTED
+
+add_email_corpus
test_begin_subtest "Emacs tests using ert"
output=$(emacs \
diff --git a/test/emacs.expected-output/emacs-ert b/test/emacs.expected-output/emacs-ert
index 50f592b..3cdf524 100644
--- a/test/emacs.expected-output/emacs-ert
+++ b/test/emacs.expected-output/emacs-ert
@@ -1,9 +1,13 @@
-Running 6 tests (today)
- passed 1/6 notmuch-fcc-multiple
- passed 2/6 notmuch-fcc-none
- passed 3/6 notmuch-fcc-oldstyle
- passed 4/6 notmuch-fcc-regexp
- passed 5/6 notmuch-fcc-simple
- passed 6/6 notmuch-fcc-trivial
+Source file `/one/home/dme/s/notmuch/emacs/notmuch-show.el' newer than byte-compiled file
+Running 9 tests (today)
+ passed 1/9 notmuch-fcc-multiple
+ passed 2/9 notmuch-fcc-none
+ passed 3/9 notmuch-fcc-oldstyle
+ passed 4/9 notmuch-fcc-regexp
+ passed 5/9 notmuch-fcc-simple
+ passed 6/9 notmuch-fcc-trivial
+ passed 7/9 notmuch-hello
+ passed 8/9 notmuch-hello-reflect
+ passed 9/9 notmuch-show-strip-re
-Ran 6 tests, 6 results as expected (today)
+Ran 9 tests, 9 results as expected (today)
--
1.7.2.3
next prev parent reply other threads:[~2010-11-25 14:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-24 21:00 [PATCH] Workaround broken check for old-style notmuch-fcc-dirs Carl Worth
2010-11-25 10:59 ` [PATCH 1/3] test: Add ERT for emacs testing David Edmondson
2010-11-25 12:02 ` David Edmondson
2010-11-25 14:09 ` David Edmondson [this message]
2010-11-25 10:59 ` [PATCH 2/3] emacs: Fix Fcc generation David Edmondson
2010-11-25 10:59 ` [PATCH 3/3] test: Add ERT tests for Fcc determination David Edmondson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290694146-8990-1-git-send-email-dme@dme.org \
--to=dme@dme.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).