1 Return-Path: <tomi.ollila@nixu.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 A9885429E21
\r
6 for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 12:42:56 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 OnhbzEugVe5F for <notmuch@notmuchmail.org>;
\r
16 Mon, 28 Nov 2011 12:42:55 -0800 (PST)
\r
17 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
18 (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 60D44431FB6
\r
21 for <notmuch@notmuchmail.org>; Mon, 28 Nov 2011 12:42:55 -0800 (PST)
\r
22 Received: from taco2.nixu.fi (taco2.nixu.fi [194.197.118.31])
\r
23 by taco2.nixu.fi (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id
\r
24 pASKgp8a018102; Mon, 28 Nov 2011 22:42:52 +0200
\r
25 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
26 To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>, notmuch@notmuchmail.org
\r
27 Subject: Re: [PATCH 1/3] test: add functions to count how much times notmuch
\r
29 In-Reply-To: <1322450895-32523-2-git-send-email-dmitry.kurochkin@gmail.com>
\r
30 References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
31 <1322450895-32523-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
32 <1322450895-32523-2-git-send-email-dmitry.kurochkin@gmail.com>
\r
33 User-Agent: Notmuch/0.10+15~gb5803e9 (http://notmuchmail.org) Emacs/23.3.1
\r
35 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
36 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
37 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
38 Date: Mon, 28 Nov 2011 22:42:50 +0200
\r
39 Message-ID: <yf6aa7gj7w5.fsf@taco2.nixu.fi>
\r
41 Content-Type: text/plain; charset=us-ascii
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Mon, 28 Nov 2011 20:42:56 -0000
\r
56 On Mon, 28 Nov 2011 07:28:13 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
\r
60 > + These allow to count how many times notmuch binary is called.
\r
61 > + notmuch_counter_reset() function generates a script that counts
\r
62 > + how many times it is called and resets the counter to zero. The
\r
63 > + function sets $notmuch_counter_command variable to the path to the
\r
64 > + generated script that should be called instead of notmuch to do
\r
65 > + the counting. The notmuch_counter_value() function prints the
\r
66 > + current counter value.
\r
67 > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
68 > index 076f929..880bed9 100644
\r
69 > --- a/test/test-lib.sh
\r
70 > +++ b/test/test-lib.sh
\r
71 > @@ -868,6 +868,38 @@ test_emacs () {
\r
72 > emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
\r
75 > +# Creates a script that counts how much time it is executed and calls
\r
76 > +# notmuch. $notmuch_counter_command is set to the path to the
\r
77 > +# generated script. Use notmuch_counter_value() function to get the
\r
78 > +# current counter value.
\r
79 > +notmuch_counter_reset () {
\r
80 > + notmuch_counter_command="$TMP_DIRECTORY/notmuch_counter"
\r
81 > + if [ ! -x "$notmuch_counter_command" ]; then
\r
82 > + notmuch_counter_state_path="$TMP_DIRECTORY/notmuch_counter.state"
\r
83 > + cat >"$notmuch_counter_command" <<EOF || return
\r
86 > +count=\$(cat "$notmuch_counter_state_path")
\r
87 > +echo -n \$(expr \$count + 1) > "$notmuch_counter_state_path"
\r
89 > +exec notmuch "\$@"
\r
91 > + chmod +x "$notmuch_counter_command" || return
\r
94 > + echo -n 0 > "$notmuch_counter_state_path"
\r
97 > +# Returns the current notmuch counter value.
\r
98 > +notmuch_counter_value () {
\r
99 > + if [ -r "$notmuch_counter_state_path" ]; then
\r
100 > + count=$(cat "$notmuch_counter_state_path")
\r
108 Good work! It would be nice if the state file contained newline after
\r
109 count number. Also some optimizations could be done:
\r
111 cat >"$notmuch_counter_command" <<EOF || return
\r
114 read count < "$notmuch_counter_state_path"
\r
115 echo \$((count + 1)) > "$notmuch_counter_state_path"
\r
119 chmod +x "$notmuch_counter_command" || return
\r
122 echo 0 > "$notmuch_counter_state_path"
\r
125 # Returns the current notmuch counter value.
\r
126 notmuch_counter_value () {
\r
127 if [ -r "$notmuch_counter_state_path" ]; then
\r
128 read count < "$notmuch_counter_state_path"
\r