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 4D50B421192
\r
6 for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 10:05:59 -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 08tlkwUr2p58 for <notmuch@notmuchmail.org>;
\r
16 Mon, 23 Jan 2012 10:05:58 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 0B9B0421198
\r
21 for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 10:05:53 -0800 (PST)
\r
22 Received: by werb10 with SMTP id b10so2714161wer.26
\r
23 for <notmuch@notmuchmail.org>; Mon, 23 Jan 2012 10:05:52 -0800 (PST)
\r
25 Received: by 10.216.135.15 with SMTP id t15mr2407245wei.3.1327341952669;
\r
26 Mon, 23 Jan 2012 10:05:52 -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 d9sm14358926wiy.2.2012.01.23.10.05.50
\r
30 (version=TLSv1/SSLv3 cipher=OTHER);
\r
31 Mon, 23 Jan 2012 10:05:51 -0800 (PST)
\r
32 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
33 id EDBCDA0AEF; Mon, 23 Jan 2012 18:05:48 +0000 (GMT)
\r
34 From: David Edmondson <dme@dme.org>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [PATCH 2/4 v42] test: Add `test_emacs_expect_t'.
\r
37 Date: Mon, 23 Jan 2012 18:05:45 +0000
\r
38 Message-Id: <1327341947-29206-2-git-send-email-dme@dme.org>
\r
39 X-Mailer: git-send-email 1.7.8.3
\r
40 In-Reply-To: <1327341947-29206-1-git-send-email-dme@dme.org>
\r
41 References: <1326804748-8989-2-git-send-email-dme@dme.org>
\r
42 <1327341947-29206-1-git-send-email-dme@dme.org>
\r
44 ALoCoQkgu7xo+HrN3LqP//Lx45tFxniUxC1/fiPQbR5Ewi4XvFQYn0z84IYqLsF1UWid8C3yP1Pp
\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: Mon, 23 Jan 2012 18:05:59 -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
68 - don't call `test_skip' twice,
\r
69 - allow for a prereq.
\r
71 test/README | 8 ++++++++
\r
72 test/emacs-test-functions.sh | 9 +++++++++
\r
73 test/notmuch-test | 1 +
\r
74 test/test-lib.el | 9 +++++++++
\r
75 test/test-lib.sh | 29 +++++++++++++++++++++++++++++
\r
76 5 files changed, 56 insertions(+), 0 deletions(-)
\r
77 create mode 100755 test/emacs-test-functions.sh
\r
79 diff --git a/test/README b/test/README
\r
80 index 44ff653..43656a3 100644
\r
83 @@ -202,6 +202,14 @@ library for your script to use.
\r
84 tests that may run in the same Emacs instance. Use `let' instead
\r
85 so the scope of the changed variables is limited to a single test.
\r
87 + test_emacs_expect_t <emacs-lisp-expressions>
\r
89 + This function executes the provided emacs lisp script within
\r
90 + emacs in a manner similar to 'test_emacs'. The expressions should
\r
91 + return the value `t' to indicate that the test has passed. If the
\r
92 + test does not return `t' then it is considered failed and all data
\r
93 + returned by the test is reported to the tester.
\r
97 Your test script must have test_done at the end. Its purpose
\r
98 diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh
\r
99 new file mode 100755
\r
100 index 0000000..0e1f9fc
\r
102 +++ b/test/emacs-test-functions.sh
\r
104 +#!/usr/bin/env bash
\r
106 +test_description="emacs test function sanity"
\r
109 +test_begin_subtest "emacs test function sanity"
\r
110 +test_emacs_expect_t 't'
\r
113 diff --git a/test/notmuch-test b/test/notmuch-test
\r
114 index 6a99ae3..d034f99 100755
\r
115 --- a/test/notmuch-test
\r
116 +++ b/test/notmuch-test
\r
117 @@ -52,6 +52,7 @@ TESTS="
\r
121 + emacs-test-functions.sh
\r
123 TESTS=${NOTMUCH_TESTS:=$TESTS}
\r
125 diff --git a/test/test-lib.el b/test/test-lib.el
\r
126 index 59c5868..96752f0 100644
\r
127 --- a/test/test-lib.el
\r
128 +++ b/test/test-lib.el
\r
129 @@ -83,3 +83,12 @@ nothing."
\r
131 (add-hook-counter 'notmuch-hello-mode-hook)
\r
132 (add-hook-counter 'notmuch-hello-refresh-hook)
\r
134 +(defmacro notmuch-test-run (&rest body)
\r
135 + "Evaluate a BODY of test expressions and output the result."
\r
136 + `(with-temp-buffer
\r
137 + (let ((result (progn ,@body)))
\r
138 + (insert (if (stringp result)
\r
140 + (prin1-to-string result)))
\r
142 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
143 index 82c686c..8158328 100644
\r
144 --- a/test/test-lib.sh
\r
145 +++ b/test/test-lib.sh
\r
146 @@ -503,6 +503,35 @@ test_expect_equal_file ()
\r
150 +test_emacs_expect_t () {
\r
151 + test "$#" = 2 && { prereq=$1; shift; } || prereq=
\r
153 + error "bug in the test script: not 1 or 2 parameters to test_emacs_expect_t"
\r
156 + if ! test_skip "$test_subtest_name"
\r
158 + test_emacs "(notmuch-test-run $1)" >/dev/null
\r
160 + # Restore state after the test.
\r
161 + exec 1>&6 2>&7 # Restore stdout and stderr
\r
164 + # Report success/failure.
\r
165 + result=$(cat OUTPUT)
\r
166 + if [ "$result" = t ]
\r
168 + test_ok_ "$test_subtest_name"
\r
170 + test_failure_ "$test_subtest_name" "${result}"
\r
173 + # Restore state after the (non) test.
\r
174 + exec 1>&6 2>&7 # Restore stdout and stderr
\r
181 notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
\r