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 7F39C431E64
\r
6 for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 08:14:32 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 U8pich8D2uTd for <notmuch@notmuchmail.org>;
\r
16 Tue, 24 Jan 2012 08:14:31 -0800 (PST)
\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com
\r
18 [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 64B27431FD2 for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 08:14:31 -0800
\r
22 Received: by wgbdt12 with SMTP id dt12so3859246wgb.2
\r
23 for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 08:14:30 -0800 (PST)
\r
25 Received: by 10.180.83.72 with SMTP id o8mr4660525wiy.22.1327421670245;
\r
26 Tue, 24 Jan 2012 08:14:30 -0800 (PST)
\r
27 Received: from hotblack-desiato.hh.sledj.net
\r
28 (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])
\r
29 by mx.google.com with ESMTPS id l6sm8174133wiv.11.2012.01.24.08.14.28
\r
30 (version=TLSv1/SSLv3 cipher=OTHER);
\r
31 Tue, 24 Jan 2012 08:14:28 -0800 (PST)
\r
32 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
33 id 0AEA89FD44; Tue, 24 Jan 2012 16:14:27 +0000 (GMT)
\r
34 From: David Edmondson <dme@dme.org>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [PATCH 2/4 v43] test: Add `test_emacs_expect_t'.
\r
37 Date: Tue, 24 Jan 2012 16:14:05 +0000
\r
38 Message-Id: <1327421647-30405-3-git-send-email-dme@dme.org>
\r
39 X-Mailer: git-send-email 1.7.8.3
\r
40 In-Reply-To: <1327421647-30405-1-git-send-email-dme@dme.org>
\r
41 References: <1326804748-8989-2-git-send-email-dme@dme.org>
\r
42 <1327421647-30405-1-git-send-email-dme@dme.org>
\r
44 ALoCoQmonQMt1k3tB2YesMlycxLKOFG64Bl4mZJH8tnED6q1Op/X8n8mo4ZDYadioFC2257jMeB5
\r
45 X-BeenThere: notmuch@notmuchmail.org
\r
46 X-Mailman-Version: 2.1.13
\r
48 List-Id: "Use and development of the notmuch mail system."
\r
49 <notmuch.notmuchmail.org>
\r
50 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
52 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
53 List-Post: <mailto:notmuch@notmuchmail.org>
\r
54 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
55 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
56 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
57 X-List-Received-Date: Tue, 24 Jan 2012 16:14:32 -0000
\r
59 Add a new test function to allow simpler testing of emacs
\r
62 `test_emacs_expect_t' takes one argument - a lisp expression to
\r
63 evaluate. The test passes if the expression returns `t', otherwise it
\r
64 fails and the output is reported to the tester.
\r
66 test/README | 8 ++++++++
\r
67 test/emacs-test-functions.sh | 9 +++++++++
\r
68 test/notmuch-test | 1 +
\r
69 test/test-lib.el | 9 +++++++++
\r
70 test/test-lib.sh | 29 +++++++++++++++++++++++++++++
\r
71 5 files changed, 56 insertions(+), 0 deletions(-)
\r
72 create mode 100755 test/emacs-test-functions.sh
\r
74 diff --git a/test/README b/test/README
\r
75 index 44ff653..43656a3 100644
\r
78 @@ -202,6 +202,14 @@ library for your script to use.
\r
79 tests that may run in the same Emacs instance. Use `let' instead
\r
80 so the scope of the changed variables is limited to a single test.
\r
82 + test_emacs_expect_t <emacs-lisp-expressions>
\r
84 + This function executes the provided emacs lisp script within
\r
85 + emacs in a manner similar to 'test_emacs'. The expressions should
\r
86 + return the value `t' to indicate that the test has passed. If the
\r
87 + test does not return `t' then it is considered failed and all data
\r
88 + returned by the test is reported to the tester.
\r
92 Your test script must have test_done at the end. Its purpose
\r
93 diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh
\r
94 new file mode 100755
\r
95 index 0000000..0e1f9fc
\r
97 +++ b/test/emacs-test-functions.sh
\r
99 +#!/usr/bin/env bash
\r
101 +test_description="emacs test function sanity"
\r
104 +test_begin_subtest "emacs test function sanity"
\r
105 +test_emacs_expect_t 't'
\r
108 diff --git a/test/notmuch-test b/test/notmuch-test
\r
109 index 6a99ae3..d034f99 100755
\r
110 --- a/test/notmuch-test
\r
111 +++ b/test/notmuch-test
\r
112 @@ -52,6 +52,7 @@ TESTS="
\r
116 + emacs-test-functions.sh
\r
118 TESTS=${NOTMUCH_TESTS:=$TESTS}
\r
120 diff --git a/test/test-lib.el b/test/test-lib.el
\r
121 index 59c5868..96752f0 100644
\r
122 --- a/test/test-lib.el
\r
123 +++ b/test/test-lib.el
\r
124 @@ -83,3 +83,12 @@ nothing."
\r
126 (add-hook-counter 'notmuch-hello-mode-hook)
\r
127 (add-hook-counter 'notmuch-hello-refresh-hook)
\r
129 +(defmacro notmuch-test-run (&rest body)
\r
130 + "Evaluate a BODY of test expressions and output the result."
\r
131 + `(with-temp-buffer
\r
132 + (let ((result (progn ,@body)))
\r
133 + (insert (if (stringp result)
\r
135 + (prin1-to-string result)))
\r
137 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
138 index 82c686c..8158328 100644
\r
139 --- a/test/test-lib.sh
\r
140 +++ b/test/test-lib.sh
\r
141 @@ -503,6 +503,35 @@ test_expect_equal_file ()
\r
145 +test_emacs_expect_t () {
\r
146 + test "$#" = 2 && { prereq=$1; shift; } || prereq=
\r
148 + error "bug in the test script: not 1 or 2 parameters to test_emacs_expect_t"
\r
151 + if ! test_skip "$test_subtest_name"
\r
153 + test_emacs "(notmuch-test-run $1)" >/dev/null
\r
155 + # Restore state after the test.
\r
156 + exec 1>&6 2>&7 # Restore stdout and stderr
\r
159 + # Report success/failure.
\r
160 + result=$(cat OUTPUT)
\r
161 + if [ "$result" = t ]
\r
163 + test_ok_ "$test_subtest_name"
\r
165 + test_failure_ "$test_subtest_name" "${result}"
\r
168 + # Restore state after the (non) test.
\r
169 + exec 1>&6 2>&7 # Restore stdout and stderr
\r
176 notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
\r