Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id E4D2F431FD0 for ; Thu, 25 Nov 2010 06:13:12 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w4nVARcWn5yB for ; Thu, 25 Nov 2010 06:13:12 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) by olra.theworths.org (Postfix) with ESMTP id 1DD13431FB5 for ; Thu, 25 Nov 2010 06:13:11 -0800 (PST) Received: by wwi18 with SMTP id 18so937253wwi.2 for ; Thu, 25 Nov 2010 06:13:09 -0800 (PST) Received: by 10.227.157.148 with SMTP id b20mr933637wbx.14.1290694389117; Thu, 25 Nov 2010 06:13:09 -0800 (PST) Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com [81.149.164.25]) by mx.google.com with ESMTPS id x65sm356739weq.1.2010.11.25.06.13.07 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 25 Nov 2010 06:13:08 -0800 (PST) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id D0886594058; Thu, 25 Nov 2010 14:09:07 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] test: Add some more emacs tests. Date: Thu, 25 Nov 2010 14:09:06 +0000 Message-Id: <1290694146-8990-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1290682750-30283-1-git-send-email-dme@dme.org> References: <1290682750-30283-1-git-send-email-dme@dme.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Nov 2010 14:13:13 -0000 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