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 88328429E25
\r
6 for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 19:09:47 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 vMtol-DKMxT4 for <notmuch@notmuchmail.org>;
\r
17 Sun, 27 Nov 2011 19:09:46 -0800 (PST)
\r
18 Received: from mail-bw0-f53.google.com (mail-bw0-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 91DD0431FB6
\r
22 for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 19:09:46 -0800 (PST)
\r
23 Received: by bkaq10 with SMTP id q10so8602745bka.26
\r
24 for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 19:09:42 -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=KeFMdFbGBvbKXIt8XpoO8gNi3KnfHnMkbdE3ARz4wXw=;
\r
29 b=KC4gjj73iz4ycBYGfmGryEKJrdrNPqtWz9FOcT1s0tYTqD8qYp5qynAeHbOuBvJWnt
\r
30 caiLslNsAG2R3KMApEzRK/+zJ47IZ9hnlit4mfwjNhL/Ut0azz/YNoUwsUh0wrKLCulw
\r
31 MC1wF767w5Mq8O7XzLE+XzIQXYonlLL03ph6k=
\r
32 Received: by 10.205.135.6 with SMTP id ie6mr15438198bkc.69.1322449780557;
\r
33 Sun, 27 Nov 2011 19:09:40 -0800 (PST)
\r
34 Received: from localhost ([91.144.186.21])
\r
35 by mx.google.com with ESMTPS id e18sm26645663bkr.15.2011.11.27.19.09.39
\r
36 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Sun, 27 Nov 2011 19:09:39 -0800 (PST)
\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
39 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org
\r
40 Subject: Re: [PATCH 1/3] test: add functions to count how much times notmuch
\r
42 In-Reply-To: <87ipm52cfs.fsf@awakening.csail.mit.edu>
\r
43 References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
44 <87ipm52cfs.fsf@awakening.csail.mit.edu>
\r
45 User-Agent: Notmuch/0.10+45~g5da8b3d (http://notmuchmail.org) Emacs/23.3.1
\r
46 (x86_64-pc-linux-gnu)
\r
47 Date: Mon, 28 Nov 2011 07:09:17 +0400
\r
48 Message-ID: <877h2leyea.fsf@gmail.com>
\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
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: Mon, 28 Nov 2011 03:09:47 -0000
\r
65 On Sun, 27 Nov 2011 21:44:23 -0500, Austin Clements <amdragon@MIT.EDU> wrote:
\r
66 > On Sat, 26 Nov 2011 05:44:36 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
\r
67 > > The patch adds two auxiliary functions and a variable:
\r
69 > > notmuch_counter_reset
\r
70 > > $notmuch_counter
\r
73 > > They allow to count how many times notmuch binary is called.
\r
74 > > notmuch_counter_reset() function generates a script that counts how
\r
75 > > many times it is called and resets the counter to zero. The function
\r
76 > > sets $notmuch_counter variable to the path to the generated script
\r
77 > > that should be called instead of notmuch to do the counting. The
\r
78 > > notmuch_counter() function returns the current counter value.
\r
83 > > test/README | 16 ++++++++++++++--
\r
84 > > test/test-lib.sh | 32 ++++++++++++++++++++++++++++++++
\r
85 > > 2 files changed, 46 insertions(+), 2 deletions(-)
\r
87 > > diff --git a/test/README b/test/README
\r
88 > > index 2481f16..1570f7c 100644
\r
89 > > --- a/test/README
\r
90 > > +++ b/test/README
\r
91 > > @@ -187,8 +187,8 @@ library for your script to use.
\r
92 > > is to summarize successes and failures in the test script and
\r
93 > > exit with an appropriate error code.
\r
95 > > -There are also a number of mail-specific functions which are useful in
\r
97 > > +There are also a number of notmuch-specific auxiliary functions and
\r
98 > > +variables which are useful in writing tests:
\r
100 > > generate_message
\r
102 > > @@ -212,3 +212,15 @@ writing tests:
\r
103 > > will initialize the mail database to a known state of 50 sample
\r
104 > > messages, (culled from the early history of the notmuch mailing
\r
107 > > + notmuch_counter_reset
\r
108 > > + $notmuch_counter
\r
109 > > + notmuch_counter
\r
111 > From the name, I would expect $notmuch_counter to be the counter value
\r
112 > (ignoring the difficulty of implementing that). Perhaps
\r
113 > $notmuch_counter_command, since it's meant to be bound to
\r
119 > notmuch_counter is okay, but maybe notmuch_counter_value?
\r
125 > > + These allow to count how many times notmuch binary is called.
\r
126 > > + notmuch_counter_reset() function generates a script that counts
\r
127 > > + how many times it is called and resets the counter to zero. The
\r
128 > > + function sets $notmuch_counter variable to the path to the
\r
129 > > + generated script that should be called instead of notmuch to do
\r
130 > > + the counting. The notmuch_counter() function returns the current
\r
131 > > + counter value.
\r
133 > It doesn't return the counter value, it prints it.
\r
138 > > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
139 > > index 93867b0..e3b85d0 100755
\r
140 > > --- a/test/test-lib.sh
\r
141 > > +++ b/test/test-lib.sh
\r
142 > > @@ -864,6 +864,38 @@ test_emacs () {
\r
143 > > emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
\r
146 > > +# Creates a script that counts how much time it is executed and calls
\r
147 > > +# notmuch. $notmuch_counter is set to the path to the generated
\r
148 > > +# script. Use notmuch_counter() function to get the current counter
\r
150 > > +notmuch_counter_reset () {
\r
151 > > + notmuch_counter="$TMP_DIRECTORY/notmuch_counter"
\r
152 > > + if [ ! -x "$notmuch_counter" ]; then
\r
153 > > + notmuch_counter_state_path="$TMP_DIRECTORY/notmuch_counter.state"
\r
154 > > + cat <<EOF >"$notmuch_counter"
\r
156 > This is totally a stylistic pet peeve, but consider
\r
157 > cat >"$notmuch_counter" <<EOF
\r
164 > > +count=\$(cat "$notmuch_counter_state_path")
\r
165 > > +echo -n \$(expr \$count + 1) > "$notmuch_counter_state_path"
\r
167 > > +exec notmuch "\$@"
\r
169 > > + chmod +x "$notmuch_counter" || return
\r
172 > > + echo -n 0 > "$notmuch_counter_state_path" || return
\r
174 > What are the || return's for?
\r
177 If echo failed by some reason, that is an error.
\r
179 Thank you for the reviews. I will send amended series soon.
\r
186 > > +# Returns the current notmuch counter value.
\r
187 > > +notmuch_counter () {
\r
188 > > + if [ -r "$notmuch_counter_state_path" ]; then
\r
189 > > + count=$(cat "$notmuch_counter_state_path")
\r
193 > > + echo -n $count
\r
197 > > find_notmuch_path ()
\r
202 > > _______________________________________________
\r
203 > > notmuch mailing list
\r
204 > > notmuch@notmuchmail.org
\r
205 > > http://notmuchmail.org/mailman/listinfo/notmuch
\r