Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view
[notmuch-archives.git] / b7 / 195b39afc05b5cc162bfc713acb8b452c7f218
1 Return-Path: <dmitry.kurochkin@gmail.com>\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 753AE421189\r
6         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:27:44 -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.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id EeSAcwjiMD4H for <notmuch@notmuchmail.org>;\r
17         Tue, 17 Jan 2012 06:27:42 -0800 (PST)\r
18 Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
19         [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 6DB52429E5F\r
22         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:27:41 -0800 (PST)\r
23 Received: by bkty12 with SMTP id y12so588519bkt.26\r
24         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:27:40 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
27         :mime-version:content-type;\r
28         bh=hmOa0SPnWucth87fLb9RlbZRurMXcoLs75O8NJUC2Ck=;\r
29         b=VuONem7oe4btJuASsU4mgbPtYikcIj4AEmssrSdna/kJA4jIGVFc1Xmy8lHBCwMQil\r
30         tL3+eLkhznljlKnMcrdkcP/4TDKBUEFML8QV2UKjTetLuGUln8lgATBycG9IGNF3Ty0K\r
31         EkaZGYsv62oQs6zhhwxHRWMWLeUvvbLN7LjC8=\r
32 Received: by 10.204.145.86 with SMTP id c22mr6635430bkv.61.1326810458229;\r
33         Tue, 17 Jan 2012 06:27:38 -0800 (PST)\r
34 Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id\r
35         fg16sm47481673bkb.16.2012.01.17.06.27.36\r
36         (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Tue, 17 Jan 2012 06:27:37 -0800 (PST)\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
39 To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
40 Subject: Re: [PATCH 2/3] test: Add `test_emacs_expect_t'.\r
41 In-Reply-To: <1326809224-22673-2-git-send-email-dme@dme.org>\r
42 References: <87pqei327k.fsf@gmail.com>\r
43         <1326809224-22673-1-git-send-email-dme@dme.org>\r
44         <1326809224-22673-2-git-send-email-dme@dme.org>\r
45 User-Agent: Notmuch/0.11+73~g8a5402e (http://notmuchmail.org) Emacs/23.3.1\r
46         (x86_64-pc-linux-gnu)\r
47 Date: Tue, 17 Jan 2012 18:26:41 +0400\r
48 Message-ID: <877h0qxv4u.fsf@gmail.com>\r
49 MIME-Version: 1.0\r
50 Content-Type: text/plain; charset=us-ascii\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Tue, 17 Jan 2012 14:27:46 -0000\r
64 \r
65 On Tue, 17 Jan 2012 14:07:03 +0000, David Edmondson <dme@dme.org> wrote:\r
66 > Add a new test function to allow simpler testing of emacs\r
67 > functionality.\r
68\r
69 > `test_emacs_expect_t' takes one argument - a list expression to\r
70 > evaluate. The test passes if the expression returns `t', otherwise it\r
71 > fails and the output is reported to the tester.\r
72 > ---\r
73\r
74 > Re-worked as Dmitry suggested.\r
75\r
76 >  test/README                  |    8 ++++++++\r
77 >  test/emacs-test-functions.sh |    9 +++++++++\r
78 >  test/notmuch-test            |    1 +\r
79 >  test/test-lib.sh             |   33 +++++++++++++++++++++++++++++++++\r
80 >  4 files changed, 51 insertions(+), 0 deletions(-)\r
81 >  create mode 100755 test/emacs-test-functions.sh\r
82\r
83 > diff --git a/test/README b/test/README\r
84 > index bde6db0..9dbe2ee 100644\r
85 > --- a/test/README\r
86 > +++ b/test/README\r
87 > @@ -189,6 +189,14 @@ library for your script to use.\r
88 >     tests that may run in the same Emacs instance.  Use `let' instead\r
89 >     so the scope of the changed variables is limited to a single test.\r
90 >  \r
91 > + test_emacs_expect_t <emacs-lisp-expressions>\r
92 > +\r
93 > +  This function executes the provided emacs lisp script within\r
94 > +  emacs in a manner similar to 'test_emacs'. The expressions should\r
95 > +  return the value `t' to indicate that the test has passed. If the\r
96 > +  test does not return `t' then it is considered failed and all data\r
97 > +  returned by the test is reported to the tester.\r
98 > +\r
99 >   test_done\r
100 >  \r
101 >     Your test script must have test_done at the end.  Its purpose\r
102 > diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh\r
103 > new file mode 100755\r
104 > index 0000000..0e1f9fc\r
105 > --- /dev/null\r
106 > +++ b/test/emacs-test-functions.sh\r
107 > @@ -0,0 +1,9 @@\r
108 > +#!/usr/bin/env bash\r
109 > +\r
110 > +test_description="emacs test function sanity"\r
111 > +. test-lib.sh\r
112 > +\r
113 > +test_begin_subtest "emacs test function sanity"\r
114 > +test_emacs_expect_t 't'\r
115 > +\r
116 > +test_done\r
117 > diff --git a/test/notmuch-test b/test/notmuch-test\r
118 > index 6a99ae3..d034f99 100755\r
119 > --- a/test/notmuch-test\r
120 > +++ b/test/notmuch-test\r
121 > @@ -52,6 +52,7 @@ TESTS="\r
122 >    python\r
123 >    hooks\r
124 >    argument-parsing\r
125 > +  emacs-test-functions.sh\r
126 >  "\r
127 >  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
128 >  \r
129 > diff --git a/test/test-lib.sh b/test/test-lib.sh\r
130 > index 7c9ce24..4b05760 100644\r
131 > --- a/test/test-lib.sh\r
132 > +++ b/test/test-lib.sh\r
133 > @@ -503,6 +503,39 @@ test_expect_equal_file ()\r
134 >      fi\r
135 >  }\r
136 >  \r
137 > +test_emacs_expect_t () {\r
138 > +     test "$#" = 1 || error "bug in the test script: not 1 parameter to test_emacs_expect_t"\r
139 > +\r
140 > +     # Run the test.\r
141 > +     if ! test_skip "$test_subtest_name"\r
142 > +     then\r
143 > +             # We cannot call 'test_emacs' in a subshell, because\r
144 > +             # the setting of EMACS_SERVER would not persist\r
145 > +             # throughout a sequence of tests, so we use a\r
146 > +             # temporary file.\r
147 > +             tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi\r
148 > +             output="$tmp/test_emacs_output.$$"\r
149 > +             test_emacs "$1" > "${output}"\r
150 > +             result=$(cat "${output}")\r
151 > +             rm -f "${output}"\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 > +             if [ "$result" == t ]\r
162 > +             then\r
163 > +                     test_ok_ "$test_subtest_name"\r
164 > +             else\r
165 > +                     test_failure_ "$test_subtest_name" "$(eval printf ${result})"\r
166 > +             fi\r
167 > +     fi\r
168 > +}\r
169 > +\r
170 \r
171 Sorry, I still do not understand why we can not implement\r
172 test_emacs_expect_t() like:\r
173 \r
174   result=${test_emacs $@}\r
175   test_expect_equal $result t\r
176 \r
177 Can you please explain?\r
178 \r
179 Regards,\r
180   Dmitry\r
181 \r
182 >  NOTMUCH_NEW ()\r
183 >  {\r
184 >      notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
185 > -- \r
186 > 1.7.7.3\r
187\r
188 > _______________________________________________\r
189 > notmuch mailing list\r
190 > notmuch@notmuchmail.org\r
191 > http://notmuchmail.org/mailman/listinfo/notmuch\r