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 9A732429E21
\r
6 for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 13:27:05 -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 AVNz-szc1JT5 for <notmuch@notmuchmail.org>;
\r
17 Mon, 28 Nov 2011 13:27:05 -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 AB29B431FB6
\r
22 for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 13:27:04 -0800 (PST)
\r
23 Received: by bkaq10 with SMTP id q10so9895992bka.26
\r
24 for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 13:27:03 -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=2yaUzdeNCA540rFFVgy0gE9WE1AjXXJRbSCoEDjx8Rc=;
\r
29 b=o+2vGCcqej1lI7Yi5UXS/oV+BC8wVxzmoDv/1x401rifJ5hD8QzEbcFzzDtRjEkbs+
\r
30 gpAWM20XZCunZ3zz4jnbXnKGGyfnSRR0i1p4YDMlVzNWI602kg5P1yEHrbB7TtMLWTYU
\r
31 iU2sLihJBB2xBPwGzXE4GyRF1J+T8kBpo47no=
\r
32 Received: by 10.204.141.2 with SMTP id k2mr44756041bku.81.1322515623220;
\r
33 Mon, 28 Nov 2011 13:27:03 -0800 (PST)
\r
34 Received: from localhost ([91.144.186.21])
\r
35 by mx.google.com with ESMTPS id c4sm32384414bkk.13.2011.11.28.13.27.02
\r
36 (version=TLSv1/SSLv3 cipher=OTHER);
\r
37 Mon, 28 Nov 2011 13:27:02 -0800 (PST)
\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
39 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org
\r
40 Subject: Re: [PATCH 1/3] test: add functions to count how much times notmuch
\r
42 In-Reply-To: <yf6aa7gj7w5.fsf@taco2.nixu.fi>
\r
43 References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
44 <1322450895-32523-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
45 <1322450895-32523-2-git-send-email-dmitry.kurochkin@gmail.com>
\r
46 <yf6aa7gj7w5.fsf@taco2.nixu.fi>
\r
47 User-Agent: Notmuch/0.10+44~g067c44f (http://notmuchmail.org) Emacs/23.3.1
\r
48 (x86_64-pc-linux-gnu)
\r
49 Date: Tue, 29 Nov 2011 01:26:39 +0400
\r
50 Message-ID: <87hb1ovsz4.fsf@gmail.com>
\r
52 Content-Type: text/plain; charset=us-ascii
\r
53 X-BeenThere: notmuch@notmuchmail.org
\r
54 X-Mailman-Version: 2.1.13
\r
56 List-Id: "Use and development of the notmuch mail system."
\r
57 <notmuch.notmuchmail.org>
\r
58 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
59 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
60 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
61 List-Post: <mailto:notmuch@notmuchmail.org>
\r
62 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
63 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
64 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
65 X-List-Received-Date: Mon, 28 Nov 2011 21:27:05 -0000
\r
69 On Mon, 28 Nov 2011 22:42:50 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:
\r
70 > On Mon, 28 Nov 2011 07:28:13 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
\r
74 > > + These allow to count how many times notmuch binary is called.
\r
75 > > + notmuch_counter_reset() function generates a script that counts
\r
76 > > + how many times it is called and resets the counter to zero. The
\r
77 > > + function sets $notmuch_counter_command variable to the path to the
\r
78 > > + generated script that should be called instead of notmuch to do
\r
79 > > + the counting. The notmuch_counter_value() function prints the
\r
80 > > + current counter value.
\r
81 > > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
82 > > index 076f929..880bed9 100644
\r
83 > > --- a/test/test-lib.sh
\r
84 > > +++ b/test/test-lib.sh
\r
85 > > @@ -868,6 +868,38 @@ test_emacs () {
\r
86 > > emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
\r
89 > > +# Creates a script that counts how much time it is executed and calls
\r
90 > > +# notmuch. $notmuch_counter_command is set to the path to the
\r
91 > > +# generated script. Use notmuch_counter_value() function to get the
\r
92 > > +# current counter value.
\r
93 > > +notmuch_counter_reset () {
\r
94 > > + notmuch_counter_command="$TMP_DIRECTORY/notmuch_counter"
\r
95 > > + if [ ! -x "$notmuch_counter_command" ]; then
\r
96 > > + notmuch_counter_state_path="$TMP_DIRECTORY/notmuch_counter.state"
\r
97 > > + cat >"$notmuch_counter_command" <<EOF || return
\r
100 > > +count=\$(cat "$notmuch_counter_state_path")
\r
101 > > +echo -n \$(expr \$count + 1) > "$notmuch_counter_state_path"
\r
103 > > +exec notmuch "\$@"
\r
105 > > + chmod +x "$notmuch_counter_command" || return
\r
108 > > + echo -n 0 > "$notmuch_counter_state_path"
\r
111 > > +# Returns the current notmuch counter value.
\r
112 > > +notmuch_counter_value () {
\r
113 > > + if [ -r "$notmuch_counter_state_path" ]; then
\r
114 > > + count=$(cat "$notmuch_counter_state_path")
\r
118 > > + echo -n $count
\r
122 > Good work! It would be nice if the state file contained newline after
\r
125 I wonder why it is actually nice :) I do not have strong preference
\r
126 here. So a newline is added in v3. Also a newline is added to
\r
127 notmuch_counter_value() output for consistency.
\r
129 > Also some optimizations could be done:
\r
132 (Would be nice if you send a diff, or a human-friendly description of
\r
135 > cat >"$notmuch_counter_command" <<EOF || return
\r
138 > read count < "$notmuch_counter_state_path"
\r
140 Nice. Fixed in the new patch version.
\r
142 > echo \$((count + 1)) > "$notmuch_counter_state_path"
\r
145 I do not think this is really an optimization. And I find expr more
\r
146 clear than using $(()). I always have troubles remembering "random
\r
147 special char syntax" (yeah, not a Perl fan :)), prefer human friendly
\r
150 > exec notmuch "\$@"
\r
152 > chmod +x "$notmuch_counter_command" || return
\r
155 > echo 0 > "$notmuch_counter_state_path"
\r
158 > # Returns the current notmuch counter value.
\r
159 > notmuch_counter_value () {
\r
160 > if [ -r "$notmuch_counter_state_path" ]; then
\r
161 > read count < "$notmuch_counter_state_path"
\r
163 Also changes in v3.
\r