--- These tests pass when run interactively (via dtach/run_emacs and in a normal session) with both emacs23 and emacs24. They pass when run via the test suite with emacs24, but emacs23 behaves differently (the result of scrolling is different). I've yet to figure out why.
emacs/notmuch-test.el | 128 +++++++++++++++++++++++++++++++++++++++++++++++++ test/emacs | 13 +++++ 2 files changed, 141 insertions(+), 0 deletions(-) create mode 100644 emacs/notmuch-test.el diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el new file mode 100644 index 0000000..307adfa --- /dev/null +++ b/emacs/notmuch-test.el @@ -0,0 +1,128 @@ +;; notmuch-test.el --- testing the emacs interface +;; +;; Copyright © David Edmondson +;; +;; This file is part of Notmuch. +;; +;; Notmuch is free software: you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; Notmuch is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>. +;; +;; Authors: David Edmondson <d...@dme.org> + +(defvar notmuch-test-tests '(notmuch-test-show-advance-simple + notmuch-test-show-advance-twice + notmuch-test-show-advance-rewind + notmuch-test-show-advance-twice-rewind + notmuch-test-show-advance-not-eobp + notmuch-test-show-advance-eobp) + "A list of tests.") + +(defun notmuch-test-all () + "Wrapper for ease of test development." + (let ((result (get-buffer-create "*notmuch-test*"))) + (set-buffer result) + (erase-buffer) + (dolist (test notmuch-test-tests) + (insert (format "%40S: %S\n" + test + (save-excursion + (funcall test))))) + (switch-to-buffer result))) + +;; + +(defun notmuch-test-show-advance-simple () + ;; Find a particular thread. + (notmuch-show "id:20091117190054.gu3...@dottiness.seas.harvard.edu") + ;; Ensure that all messages are open. + (notmuch-show-open-or-close-all) + (redisplay t) + ;; Advance. + (notmuch-show-advance) + (redisplay t) + ;; The first message in the thread is longer than a screen, so we + ;; should just have scrolled normally. + (if (= (line-number-at-pos) 19) + t + (cons (line-number-at-pos) 19))) + +(defun notmuch-test-show-advance-twice () + ;; Find a particular thread. + (notmuch-show "id:20091117190054.gu3...@dottiness.seas.harvard.edu") + ;; Ensure that all messages are open. + (notmuch-show-open-or-close-all) + (redisplay t) + ;; Advance twice. + (notmuch-show-advance) + (redisplay t) + (notmuch-show-advance) + (redisplay t) + ;; The first message in the thread is shorter than two screens, so + ;; we should be at the start of the second message. + (if (= (line-number-at-pos) 41) + t + (cons (line-number-at-pos) 41))) + +(defun notmuch-test-show-advance-rewind () + ;; Find a particular thread. + (notmuch-show "id:20091117190054.gu3...@dottiness.seas.harvard.edu") + ;; Ensure that all messages are open. + (notmuch-show-open-or-close-all) + (redisplay t) + ;; Advance. + (notmuch-show-advance) + (redisplay t) + ;; Rewind. + (notmuch-show-rewind) + (redisplay t) + ;; Should be back at the start. + (if (= (line-number-at-pos) 1) + t + (cons (line-number-at-pos) 1))) + +(defun notmuch-test-show-advance-twice-rewind () + ;; Find a particular thread. + (notmuch-show "id:20091117190054.gu3...@dottiness.seas.harvard.edu") + ;; Ensure that all messages are open. + (notmuch-show-open-or-close-all) + (redisplay t) + ;; Advance twice. + (notmuch-show-advance) + (redisplay t) + (notmuch-show-advance) + (redisplay t) + ;; Rewind. + (notmuch-show-rewind) + (redisplay t) + ;; The first message in the thread is shorter than two screens, so + ;; we should be in the middle of it. + (if (= (line-number-at-pos) 17) + t + (cons (line-number-at-pos) 17))) + +(defun notmuch-test-show-advance-not-eobp () + ;; Find a particular thread. + (notmuch-show "id:20091117190054.gu3...@dottiness.seas.harvard.edu") + ;; From here `advance' should never cause us to leave the buffer. + (not (notmuch-show-advance))) + +(defun notmuch-test-show-advance-eobp () + ;; Find a particular thread. + (notmuch-show "id:20091117190054.gu3...@dottiness.seas.harvard.edu") + (goto-char (point-max)) + ;; From here `advance' should always cause us to leave the buffer. + (notmuch-show-advance)) + +;; + +(provide 'notmuch-test) diff --git a/test/emacs b/test/emacs index ca82445..a1f1abc 100755 --- a/test/emacs +++ b/test/emacs @@ -514,4 +514,17 @@ counter=$(test_emacs \ ) test_expect_equal "$counter" 2 +for i in \ + show-advance-simple \ + show-advance-twice \ + show-advance-rewind \ + show-advance-twice-rewind \ + show-advance-not-eobp \ + show-advance-eobp +do + test_begin_subtest "notmuch $i" + result=$(test_emacs '(require (quote notmuch-test)) (notmuch-test-'$i')') + test_expect_equal "$result" t +done + test_done -- 1.7.7.3 _______________________________________________ notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch