Re: [PATCH 1/2] cli: S/MIME verification/decryption support
[notmuch-archives.git] / 45 / eabdfea11dff484fe1e9a13ef660090f452ca9
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
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 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
24 MIME-Version: 1.0\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
43 X-Gm-Message-State:\r
44  ALoCoQkgu7xo+HrN3LqP//Lx45tFxniUxC1/fiPQbR5Ewi4XvFQYn0z84IYqLsF1UWid8C3yP1Pp\r
45 X-BeenThere: notmuch@notmuchmail.org\r
46 X-Mailman-Version: 2.1.13\r
47 Precedence: list\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
58 \r
59 Add a new test function to allow simpler testing of emacs\r
60 functionality.\r
61 \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
65 ---\r
66 \r
67 As per Dmitry:\r
68  - don't call `test_skip' twice,\r
69  - allow for a prereq.\r
70 \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
78 \r
79 diff --git a/test/README b/test/README\r
80 index 44ff653..43656a3 100644\r
81 --- a/test/README\r
82 +++ b/test/README\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
86  \r
87 + test_emacs_expect_t <emacs-lisp-expressions>\r
88 +\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
94 +\r
95   test_done\r
96  \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
101 --- /dev/null\r
102 +++ b/test/emacs-test-functions.sh\r
103 @@ -0,0 +1,9 @@\r
104 +#!/usr/bin/env bash\r
105 +\r
106 +test_description="emacs test function sanity"\r
107 +. test-lib.sh\r
108 +\r
109 +test_begin_subtest "emacs test function sanity"\r
110 +test_emacs_expect_t 't'\r
111 +\r
112 +test_done\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
118    python\r
119    hooks\r
120    argument-parsing\r
121 +  emacs-test-functions.sh\r
122  "\r
123  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
124  \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
130  \r
131  (add-hook-counter 'notmuch-hello-mode-hook)\r
132  (add-hook-counter 'notmuch-hello-refresh-hook)\r
133 +\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
139 +                  result\r
140 +                (prin1-to-string result)))\r
141 +       (test-output))))\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
147      fi\r
148  }\r
149  \r
150 +test_emacs_expect_t () {\r
151 +       test "$#" = 2 && { prereq=$1; shift; } || prereq=\r
152 +       test "$#" = 1 ||\r
153 +       error "bug in the test script: not 1 or 2 parameters to test_emacs_expect_t"\r
154 +\r
155 +       # Run the test.\r
156 +       if ! test_skip "$test_subtest_name"\r
157 +       then\r
158 +               test_emacs "(notmuch-test-run $1)" >/dev/null\r
159 +\r
160 +               # Restore state after the test.\r
161 +               exec 1>&6 2>&7          # Restore stdout and stderr\r
162 +               inside_subtest=\r
163 +\r
164 +               # Report success/failure.\r
165 +               result=$(cat OUTPUT)\r
166 +               if [ "$result" = t ]\r
167 +               then\r
168 +                       test_ok_ "$test_subtest_name"\r
169 +               else\r
170 +                       test_failure_ "$test_subtest_name" "${result}"\r
171 +               fi\r
172 +       else\r
173 +               # Restore state after the (non) test.\r
174 +               exec 1>&6 2>&7          # Restore stdout and stderr\r
175 +               inside_subtest=\r
176 +       fi\r
177 +}\r
178 +\r
179  NOTMUCH_NEW ()\r
180  {\r
181      notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
182 -- \r
183 1.7.8.3\r
184 \r