Re: A big thank you for the major tagging speedup
[notmuch-archives.git] / 20 / cb23d79c30d34861ad27eb6d1dd07c94158cba
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 ACDD6429E35\r
6         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:10:35 -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 KjF75Akvrg+l for <notmuch@notmuchmail.org>;\r
17         Tue, 17 Jan 2012 05:10:35 -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 C523C429E2F\r
22         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:10:34 -0800 (PST)\r
23 Received: by bkty12 with SMTP id y12so515617bkt.26\r
24         for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:10:32 -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=Tot9QtECF1bmSmDHWRD2z51wUbh1ugWxwDf+l0beIGY=;\r
29         b=N4JI1NQprAxTjbg1FzU0u+XZa9YViMbl893MMqoB/kUMMijC31qcwCENEBlXI1YYX+\r
30         OVz3XSaMNBDSkX9zGt3w4CLdv/0k26Xi5kESa1X8KyD5k8xbZKzJTimD/0L4P6jkWK3s\r
31         DjsUIWajAOg4vBg4dHPkWD7Zg/+uO6Y5yTu8A=\r
32 Received: by 10.205.120.17 with SMTP id fw17mr2696569bkc.74.1326805832003;\r
33         Tue, 17 Jan 2012 05:10:32 -0800 (PST)\r
34 Received: from localhost ([91.144.186.21])\r
35         by mx.google.com with ESMTPS id ig13sm14880148bkc.9.2012.01.17.05.10.30\r
36         (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Tue, 17 Jan 2012 05:10:31 -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 1/4] test: Add `test_emacs_expect_t'.\r
41 In-Reply-To: <1326804748-8989-2-git-send-email-dme@dme.org>\r
42 References: <1326804748-8989-1-git-send-email-dme@dme.org>\r
43         <1326804748-8989-2-git-send-email-dme@dme.org>\r
44 User-Agent: Notmuch/0.11+73~g8a5402e (http://notmuchmail.org) Emacs/23.3.1\r
45         (x86_64-pc-linux-gnu)\r
46 Date: Tue, 17 Jan 2012 17:09:35 +0400\r
47 Message-ID: <87pqei327k.fsf@gmail.com>\r
48 MIME-Version: 1.0\r
49 Content-Type: text/plain; charset=us-ascii\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Tue, 17 Jan 2012 13:10:35 -0000\r
63 \r
64 On Tue, 17 Jan 2012 12:52:25 +0000, David Edmondson <dme@dme.org> wrote:\r
65 > Add a new test function to allow simpler testing of emacs\r
66 > functionality.\r
67\r
68 > `test_emacs_expect_t' takes two arguments:\r
69 >   - the name of the test,\r
70 >   - some lisp to evaluate.\r
71\r
72 > The test passes if the lisp returns `t', otherwise it fails and the\r
73 > output is reported to the tester.\r
74 \r
75 -1\r
76 \r
77 This is not what I suggested.  I do not like the approach when a single\r
78 function is used to both declare a subtest and test for result (as\r
79 opposed to test_begin_subtest).  The fact that it is possible to write\r
80 tests in two different ways makes it hard to maintain and improve the\r
81 test framework (one example would be known broken test support).  I\r
82 consider the proper way to write tests to be using the\r
83 test_begin_subtest function.  Other functions are not currently\r
84 deprecated, but I am against adding new code that make the situation\r
85 worse.\r
86 \r
87 Also, please consider documenting new functions in README.\r
88 \r
89 Regards,\r
90   Dmitry\r
91 \r
92 > ---\r
93 >  test/emacs-test-functions.sh |    8 ++++++++\r
94 >  test/notmuch-test            |    1 +\r
95 >  test/test-lib.sh             |   24 ++++++++++++++++++++++++\r
96 >  3 files changed, 33 insertions(+), 0 deletions(-)\r
97 >  create mode 100755 test/emacs-test-functions.sh\r
98\r
99 > diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh\r
100 > new file mode 100755\r
101 > index 0000000..969cc78\r
102 > --- /dev/null\r
103 > +++ b/test/emacs-test-functions.sh\r
104 > @@ -0,0 +1,8 @@\r
105 > +#!/usr/bin/env bash\r
106 > +\r
107 > +test_description="emacs test function sanity"\r
108 > +. test-lib.sh\r
109 > +\r
110 > +test_emacs_expect_t "emacs test function sanity" '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.sh b/test/test-lib.sh\r
126 > index 7c9ce24..15da973 100644\r
127 > --- a/test/test-lib.sh\r
128 > +++ b/test/test-lib.sh\r
129 > @@ -503,6 +503,30 @@ test_expect_equal_file ()\r
130 >      fi\r
131 >  }\r
132 >  \r
133 > +test_emacs_expect_t () {\r
134 > +     test "$#" = 2 || error "bug in the test script: not 2 parameters to test_emacs_expect_t"\r
135 > +     test_reset_state_\r
136 > +     if ! test_skip "$1"\r
137 > +     then\r
138 > +             # We cannot call 'test_emacs' in a subshell, because\r
139 > +             # the setting of EMACS_SERVER would not persist\r
140 > +             # throughout a sequence of tests, so we use a\r
141 > +             # temporary file.\r
142 > +             tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi\r
143 > +             output="$tmp/test_emacs_output.$$"\r
144 > +             test_emacs "$2" >"${output}"\r
145 > +             result=$(cat "${output}")\r
146 > +             rm -f "${output}"\r
147 > +\r
148 > +             if [ "$result" == t ]\r
149 > +             then\r
150 > +                     test_ok_ "$1"\r
151 > +             else\r
152 > +                     test_failure_ "$1" "$(eval printf ${result})"\r
153 > +             fi\r
154 > +     fi\r
155 > +}\r
156 > +\r
157 >  NOTMUCH_NEW ()\r
158 >  {\r
159 >      notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
160 > -- \r
161 > 1.7.7.3\r
162\r
163 > _______________________________________________\r
164 > notmuch mailing list\r
165 > notmuch@notmuchmail.org\r
166 > http://notmuchmail.org/mailman/listinfo/notmuch\r