Re: [RFC PATCH v2 0/3] notmuch-pick: an emacs threaded message view with split-pane
[notmuch-archives.git] / 84 / f9d1814dace1eec31a0ab77023488bb9a0c65c
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 76E13431FBD\r
6         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 04:54:13 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 ZIQtAwPZd4wu for <notmuch@notmuchmail.org>;\r
16         Thu, 19 Jan 2012 04:54:11 -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 76791431FAF\r
21         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 04:54:11 -0800 (PST)\r
22 Received: by werp13 with SMTP id p13so2507794wer.26\r
23         for <notmuch@notmuchmail.org>; Thu, 19 Jan 2012 04:54:10 -0800 (PST)\r
24 Received: by 10.216.135.162 with SMTP id u34mr11183470wei.1.1326977650230;\r
25         Thu, 19 Jan 2012 04:54:10 -0800 (PST)\r
26 Received: from hotblack-desiato.hh.sledj.net\r
27         (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])\r
28         by mx.google.com with ESMTPS id hv1sm27888745wib.1.2012.01.19.04.54.07\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Thu, 19 Jan 2012 04:54:08 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id A253D9FE61; Thu, 19 Jan 2012 12:54:05 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [PATCH 2/3] test: Add `test_emacs_expect_t'.\r
36 Date: Thu, 19 Jan 2012 12:54:02 +0000\r
37 Message-Id: <1326977643-19792-2-git-send-email-dme@dme.org>\r
38 X-Mailer: git-send-email 1.7.8.3\r
39 In-Reply-To: <1326977643-19792-1-git-send-email-dme@dme.org>\r
40 References: <yf639bcarcs.fsf@taco2.nixu.fi>\r
41         <1326977643-19792-1-git-send-email-dme@dme.org>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\r
45 List-Id: "Use and development of the notmuch mail system."\r
46         <notmuch.notmuchmail.org>\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
50 List-Post: <mailto:notmuch@notmuchmail.org>\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
53         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
54 X-List-Received-Date: Thu, 19 Jan 2012 12:54:14 -0000\r
55 \r
56 Add a new test function to allow simpler testing of emacs\r
57 functionality.\r
58 \r
59 `test_emacs_expect_t' takes one argument - a list expression to\r
60 evaluate. The test passes if the expression returns `t', otherwise it\r
61 fails and the output is reported to the tester.\r
62 ---\r
63 \r
64 In the interest of moving forward, don't use eval.\r
65 \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             |   26 ++++++++++++++++++++++++++\r
71  5 files changed, 53 insertions(+), 0 deletions(-)\r
72  create mode 100755 test/emacs-test-functions.sh\r
73 \r
74 diff --git a/test/README b/test/README\r
75 index bde6db0..9dbe2ee 100644\r
76 --- a/test/README\r
77 +++ b/test/README\r
78 @@ -189,6 +189,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
81  \r
82 + test_emacs_expect_t <emacs-lisp-expressions>\r
83 +\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
89 +\r
90   test_done\r
91  \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
96 --- /dev/null\r
97 +++ b/test/emacs-test-functions.sh\r
98 @@ -0,0 +1,9 @@\r
99 +#!/usr/bin/env bash\r
100 +\r
101 +test_description="emacs test function sanity"\r
102 +. test-lib.sh\r
103 +\r
104 +test_begin_subtest "emacs test function sanity"\r
105 +test_emacs_expect_t 't'\r
106 +\r
107 +test_done\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
113    python\r
114    hooks\r
115    argument-parsing\r
116 +  emacs-test-functions.sh\r
117  "\r
118  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
119  \r
120 diff --git a/test/test-lib.el b/test/test-lib.el\r
121 index 3b817c3..1d51b8d 100644\r
122 --- a/test/test-lib.el\r
123 +++ b/test/test-lib.el\r
124 @@ -76,3 +76,12 @@ nothing."\r
125  \r
126  (add-hook-counter 'notmuch-hello-mode-hook)\r
127  (add-hook-counter 'notmuch-hello-refresh-hook)\r
128 +\r
129 +(defmacro notmuch-test-run-test (&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
134 +                  result\r
135 +                (prin1-to-string result)))\r
136 +       (test-output))))\r
137 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
138 index 7c9ce24..9cf1b92 100644\r
139 --- a/test/test-lib.sh\r
140 +++ b/test/test-lib.sh\r
141 @@ -503,6 +503,32 @@ test_expect_equal_file ()\r
142      fi\r
143  }\r
144  \r
145 +test_emacs_expect_t () {\r
146 +       test "$#" = 1 || error "bug in the test script: not 1 parameter to test_emacs_expect_t"\r
147 +\r
148 +       # Run the test.\r
149 +       if ! test_skip "$test_subtest_name"\r
150 +       then\r
151 +               test_emacs "(notmuch-test-run-test $1)" >/dev/null\r
152 +       fi\r
153 +\r
154 +       # Restore state after the test.\r
155 +       exec 1>&6 2>&7          # Restore stdout and stderr\r
156 +       inside_subtest=\r
157 +\r
158 +       # Report success/failure.\r
159 +       if ! test_skip "$test_subtest_name"\r
160 +       then\r
161 +               result=$(cat OUTPUT)\r
162 +               if [ "$result" = t ]\r
163 +               then\r
164 +                       test_ok_ "$test_subtest_name"\r
165 +               else\r
166 +                       test_failure_ "$test_subtest_name" "${result}"\r
167 +               fi\r
168 +       fi\r
169 +}\r
170 +\r
171  NOTMUCH_NEW ()\r
172  {\r
173      notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
174 -- \r
175 1.7.8.3\r
176 \r