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 F0D67429E25
\r
6 for <notmuch@notmuchmail.org>; Wed, 30 Nov 2011 03:58:02 -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 hLKlxv3HRFdN for <notmuch@notmuchmail.org>;
\r
16 Wed, 30 Nov 2011 03:58:02 -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 07D30431FB6
\r
21 for <notmuch@notmuchmail.org>; Wed, 30 Nov 2011 03:58:01 -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 pAUBvxUd025246; Wed, 30 Nov 2011 13:57:59 +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 v4 1/3] test: add functions to count how much times
\r
29 In-Reply-To: <1322601595-20537-2-git-send-email-dmitry.kurochkin@gmail.com>
\r
30 References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
31 <1322601595-20537-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
32 <1322601595-20537-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: Wed, 30 Nov 2011 13:57:59 +0200
\r
39 Message-ID: <yf639d5n7p4.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: Wed, 30 Nov 2011 11:58:03 -0000
\r
56 On Wed, 30 Nov 2011 01:19:52 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
\r
57 > The patch adds two auxiliary functions and a variable:
\r
59 > notmuch_counter_reset
\r
60 > $notmuch_counter_command
\r
61 > notmuch_counter_value
\r
63 > They allow to count how many times notmuch binary is called.
\r
64 > notmuch_counter_reset() function generates a script that counts how
\r
65 > many times it is called and resets the counter to zero. The function
\r
66 > sets $notmuch_counter_command variable to the path to the generated
\r
67 > script that should be called instead of notmuch to do the counting.
\r
68 > The notmuch_counter_value() function returns the current counter
\r
76 > test/README | 16 ++++++++++++++--
\r
77 > test/test-lib.sh | 32 ++++++++++++++++++++++++++++++++
\r
78 > 2 files changed, 46 insertions(+), 2 deletions(-)
\r
80 > diff --git a/test/README b/test/README
\r
81 > index 2481f16..5dc0638 100644
\r
84 > @@ -187,8 +187,8 @@ library for your script to use.
\r
85 > is to summarize successes and failures in the test script and
\r
86 > exit with an appropriate error code.
\r
88 > -There are also a number of mail-specific functions which are useful in
\r
90 > +There are also a number of notmuch-specific auxiliary functions and
\r
91 > +variables which are useful in writing tests:
\r
95 > @@ -212,3 +212,15 @@ writing tests:
\r
96 > will initialize the mail database to a known state of 50 sample
\r
97 > messages, (culled from the early history of the notmuch mailing
\r
100 > + notmuch_counter_reset
\r
101 > + $notmuch_counter_command
\r
102 > + notmuch_counter_value
\r
104 > + These allow to count how many times notmuch binary is called.
\r
105 > + notmuch_counter_reset() function generates a script that counts
\r
106 > + how many times it is called and resets the counter to zero. The
\r
107 > + function sets $notmuch_counter_command variable to the path to the
\r
108 > + generated script that should be called instead of notmuch to do
\r
109 > + the counting. The notmuch_counter_value() function prints the
\r
110 > + current counter value.
\r
111 > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
112 > index 11e6646..5f5e67e 100644
\r
113 > --- a/test/test-lib.sh
\r
114 > +++ b/test/test-lib.sh
\r
115 > @@ -919,6 +919,38 @@ test_emacs () {
\r
116 > emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
\r
119 > +# Creates a script that counts how much time it is executed and calls
\r
120 > +# notmuch. $notmuch_counter_command is set to the path to the
\r
121 > +# generated script. Use notmuch_counter_value() function to get the
\r
122 > +# current counter value.
\r
123 > +notmuch_counter_reset () {
\r
124 > + notmuch_counter_command="$TMP_DIRECTORY/notmuch_counter"
\r
125 > + if [ ! -x "$notmuch_counter_command" ]; then
\r
126 > + notmuch_counter_state_path="$TMP_DIRECTORY/notmuch_counter.state"
\r
127 > + cat >"$notmuch_counter_command" <<EOF || return
\r
130 > +read count < "$notmuch_counter_state_path"
\r
131 > +echo \$((count + 1)) > "$notmuch_counter_state_path"
\r
133 > +exec notmuch "\$@"
\r
135 > + chmod +x "$notmuch_counter_command" || return
\r
138 > + echo 0 > "$notmuch_counter_state_path"
\r
141 > +# Returns the current notmuch counter value.
\r
142 > +notmuch_counter_value () {
\r
143 > + if [ -r "$notmuch_counter_state_path" ]; then
\r
144 > + read count < "$notmuch_counter_state_path"
\r
151 > test_reset_state_ () {
\r
152 > test -z "$test_init_done_" && test_init_
\r