[PATCH 2/2] test: Add tests for advance/rewind.
authorDavid Edmondson <dme@dme.org>
Thu, 29 Dec 2011 12:08:10 +0000 (12:08 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:24 +0000 (09:41 -0800)
42/a0958b7e89ac11bb4b5e315867661d17b584ee [new file with mode: 0644]

diff --git a/42/a0958b7e89ac11bb4b5e315867661d17b584ee b/42/a0958b7e89ac11bb4b5e315867661d17b584ee
new file mode 100644 (file)
index 0000000..3d1319e
--- /dev/null
@@ -0,0 +1,229 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 79B4E429E25\r
+       for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 04:08:19 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id NUt1L9W1wKse for <notmuch@notmuchmail.org>;\r
+       Thu, 29 Dec 2011 04:08:18 -0800 (PST)\r
+Received: from mail-qw0-f46.google.com (mail-qw0-f46.google.com\r
+       [209.85.216.46]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 42064431FD0\r
+       for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 04:08:18 -0800 (PST)\r
+Received: by qadc12 with SMTP id c12so9026835qad.5\r
+       for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 04:08:16 -0800 (PST)\r
+Received: by 10.224.175.2 with SMTP id v2mr42145296qaz.69.1325160496585;\r
+       Thu, 29 Dec 2011 04:08:16 -0800 (PST)\r
+Received: from hotblack-desiato.hh.sledj.net\r
+       (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
+       by mx.google.com with ESMTPS id q14sm64844229qap.4.2011.12.29.04.08.14\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 29 Dec 2011 04:08:15 -0800 (PST)\r
+Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
+       id 26834A0B3C; Thu, 29 Dec 2011 12:08:13 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/2] test: Add tests for advance/rewind.\r
+Date: Thu, 29 Dec 2011 12:08:10 +0000\r
+Message-Id: <1325160490-23472-2-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.7.3\r
+In-Reply-To: <1325160490-23472-1-git-send-email-dme@dme.org>\r
+References: <1324665712-2419-1-git-send-email-dme@dme.org>\r
+       <1325160490-23472-1-git-send-email-dme@dme.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 29 Dec 2011 12:08:19 -0000\r
+\r
+---\r
+\r
+These tests pass when run interactively (via dtach/run_emacs and in a\r
+normal session) with both emacs23 and emacs24. They pass when run via\r
+the test suite with emacs24, but emacs23 behaves differently (the\r
+result of scrolling is different). I've yet to figure out why.\r
+\r
+ emacs/notmuch-test.el |  128 +++++++++++++++++++++++++++++++++++++++++++++++++\r
+ test/emacs            |   13 +++++\r
+ 2 files changed, 141 insertions(+), 0 deletions(-)\r
+ create mode 100644 emacs/notmuch-test.el\r
+\r
+diff --git a/emacs/notmuch-test.el b/emacs/notmuch-test.el\r
+new file mode 100644\r
+index 0000000..307adfa\r
+--- /dev/null\r
++++ b/emacs/notmuch-test.el\r
+@@ -0,0 +1,128 @@\r
++;; notmuch-test.el --- testing the emacs interface\r
++;;\r
++;; Copyright © David Edmondson\r
++;;\r
++;; This file is part of Notmuch.\r
++;;\r
++;; Notmuch is free software: you can redistribute it and/or modify it\r
++;; under the terms of the GNU General Public License as published by\r
++;; the Free Software Foundation, either version 3 of the License, or\r
++;; (at your option) any later version.\r
++;;\r
++;; Notmuch is distributed in the hope that it will be useful, but\r
++;; WITHOUT ANY WARRANTY; without even the implied warranty of\r
++;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\r
++;; General Public License for more details.\r
++;;\r
++;; You should have received a copy of the GNU General Public License\r
++;; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.\r
++;;\r
++;; Authors: David Edmondson <dme@dme.org>\r
++\r
++(defvar notmuch-test-tests '(notmuch-test-show-advance-simple\r
++                           notmuch-test-show-advance-twice\r
++                           notmuch-test-show-advance-rewind\r
++                           notmuch-test-show-advance-twice-rewind\r
++                           notmuch-test-show-advance-not-eobp\r
++                           notmuch-test-show-advance-eobp)\r
++  "A list of tests.")\r
++\r
++(defun notmuch-test-all ()\r
++  "Wrapper for ease of test development."\r
++  (let ((result (get-buffer-create "*notmuch-test*")))\r
++    (set-buffer result)\r
++    (erase-buffer)\r
++    (dolist (test notmuch-test-tests)\r
++      (insert (format "%40S: %S\n"\r
++                    test\r
++                    (save-excursion\r
++                      (funcall test)))))\r
++    (switch-to-buffer result)))\r
++\r
++;;\r
++\r
++(defun notmuch-test-show-advance-simple ()\r
++  ;; Find a particular thread.\r
++  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")\r
++  ;; Ensure that all messages are open.\r
++  (notmuch-show-open-or-close-all)\r
++  (redisplay t)\r
++  ;; Advance.\r
++  (notmuch-show-advance)\r
++  (redisplay t)\r
++  ;; The first message in the thread is longer than a screen, so we\r
++  ;; should just have scrolled normally.\r
++  (if (= (line-number-at-pos) 19)\r
++      t\r
++    (cons (line-number-at-pos) 19)))\r
++\r
++(defun notmuch-test-show-advance-twice ()\r
++  ;; Find a particular thread.\r
++  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")\r
++  ;; Ensure that all messages are open.\r
++  (notmuch-show-open-or-close-all)\r
++  (redisplay t)\r
++  ;; Advance twice.\r
++  (notmuch-show-advance)\r
++  (redisplay t)\r
++  (notmuch-show-advance)\r
++  (redisplay t)\r
++  ;; The first message in the thread is shorter than two screens, so\r
++  ;; we should be at the start of the second message.\r
++  (if (= (line-number-at-pos) 41)\r
++      t\r
++    (cons (line-number-at-pos) 41)))\r
++\r
++(defun notmuch-test-show-advance-rewind ()\r
++  ;; Find a particular thread.\r
++  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")\r
++  ;; Ensure that all messages are open.\r
++  (notmuch-show-open-or-close-all)\r
++  (redisplay t)\r
++  ;; Advance.\r
++  (notmuch-show-advance)\r
++  (redisplay t)\r
++  ;; Rewind.\r
++  (notmuch-show-rewind)\r
++  (redisplay t)\r
++  ;; Should be back at the start.\r
++  (if (= (line-number-at-pos) 1)\r
++      t\r
++    (cons (line-number-at-pos) 1)))\r
++\r
++(defun notmuch-test-show-advance-twice-rewind ()\r
++  ;; Find a particular thread.\r
++  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")\r
++  ;; Ensure that all messages are open.\r
++  (notmuch-show-open-or-close-all)\r
++  (redisplay t)\r
++  ;; Advance twice.\r
++  (notmuch-show-advance)\r
++  (redisplay t)\r
++  (notmuch-show-advance)\r
++  (redisplay t)\r
++  ;; Rewind.\r
++  (notmuch-show-rewind)\r
++  (redisplay t)\r
++  ;; The first message in the thread is shorter than two screens, so\r
++  ;; we should be in the middle of it.\r
++  (if (= (line-number-at-pos) 17)\r
++      t\r
++    (cons (line-number-at-pos) 17)))\r
++\r
++(defun notmuch-test-show-advance-not-eobp ()\r
++  ;; Find a particular thread.\r
++  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")\r
++  ;; From here `advance' should never cause us to leave the buffer.\r
++  (not (notmuch-show-advance)))\r
++\r
++(defun notmuch-test-show-advance-eobp ()\r
++  ;; Find a particular thread.\r
++  (notmuch-show "id:20091117190054.GU3165@dottiness.seas.harvard.edu")\r
++  (goto-char (point-max))\r
++  ;; From here `advance' should always cause us to leave the buffer.\r
++  (notmuch-show-advance))\r
++\r
++;;\r
++\r
++(provide 'notmuch-test)\r
+diff --git a/test/emacs b/test/emacs\r
+index ca82445..a1f1abc 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -514,4 +514,17 @@ counter=$(test_emacs \\r
+ )\r
+ test_expect_equal "$counter" 2\r
\r
++for i in \\r
++    show-advance-simple \\r
++    show-advance-twice \\r
++    show-advance-rewind \\r
++    show-advance-twice-rewind \\r
++    show-advance-not-eobp \\r
++    show-advance-eobp\r
++do\r
++    test_begin_subtest "notmuch $i"\r
++    result=$(test_emacs '(require (quote notmuch-test)) (notmuch-test-'$i')')\r
++    test_expect_equal "$result" t\r
++done\r
++\r
+ test_done\r
+-- \r
+1.7.7.3\r
+\r