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 DF191429E21
\r
6 for <notmuch@notmuchmail.org>; Fri, 25 Nov 2011 17:45:01 -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 9DWYagYyDM4Y for <notmuch@notmuchmail.org>;
\r
17 Fri, 25 Nov 2011 17:45:01 -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 0AFF8431FB6
\r
22 for <notmuch@notmuchmail.org>; Fri, 25 Nov 2011 17:45:00 -0800 (PST)
\r
23 Received: by bkaq10 with SMTP id q10so5540957bka.26
\r
24 for <notmuch@notmuchmail.org>; Fri, 25 Nov 2011 17:44:58 -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:date:message-id:x-mailer;
\r
27 bh=fO8Z3i9jnbHvHPgiOPM2ghNqPRVbPqkJpdPMeh5GZ2g=;
\r
28 b=oHhRUAbiB/J2KMQQgjAOO5q90yBj0n9g0qxSbtcUZiGx5GgQdpzCbMbV14DDJealKo
\r
29 4otsIEhRAS0dBHGkCs0vXaw66/hRJwAPXQgFl3LJNgTmoOjN0sAZsVIQr7L7Ps33VPAP
\r
30 s4eMiVaWLBWoF37L23XXsk/PxcC6a0TAeEEIM=
\r
31 Received: by 10.204.13.78 with SMTP id b14mr22179064bka.23.1322271898095;
\r
32 Fri, 25 Nov 2011 17:44:58 -0800 (PST)
\r
33 Received: from localhost ([91.144.186.21])
\r
34 by mx.google.com with ESMTPS id q6sm20398601bka.6.2011.11.25.17.44.57
\r
35 (version=TLSv1/SSLv3 cipher=OTHER);
\r
36 Fri, 25 Nov 2011 17:44:57 -0800 (PST)
\r
37 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
\r
38 To: notmuch@notmuchmail.org
\r
39 Subject: [PATCH 1/3] test: add functions to count how much times notmuch was
\r
41 Date: Sat, 26 Nov 2011 05:44:36 +0400
\r
42 Message-Id: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>
\r
43 X-Mailer: git-send-email 1.7.7.3
\r
44 X-BeenThere: notmuch@notmuchmail.org
\r
45 X-Mailman-Version: 2.1.13
\r
47 List-Id: "Use and development of the notmuch mail system."
\r
48 <notmuch.notmuchmail.org>
\r
49 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
51 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
52 List-Post: <mailto:notmuch@notmuchmail.org>
\r
53 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
54 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
56 X-List-Received-Date: Sat, 26 Nov 2011 01:45:02 -0000
\r
58 The patch adds two auxiliary functions and a variable:
\r
60 notmuch_counter_reset
\r
64 They allow to count how many times notmuch binary is called.
\r
65 notmuch_counter_reset() function generates a script that counts how
\r
66 many times it is called and resets the counter to zero. The function
\r
67 sets $notmuch_counter variable to the path to the generated script
\r
68 that should be called instead of notmuch to do the counting. The
\r
69 notmuch_counter() function returns the current counter value.
\r
71 test/README | 16 ++++++++++++++--
\r
72 test/test-lib.sh | 32 ++++++++++++++++++++++++++++++++
\r
73 2 files changed, 46 insertions(+), 2 deletions(-)
\r
75 diff --git a/test/README b/test/README
\r
76 index 2481f16..1570f7c 100644
\r
79 @@ -187,8 +187,8 @@ library for your script to use.
\r
80 is to summarize successes and failures in the test script and
\r
81 exit with an appropriate error code.
\r
83 -There are also a number of mail-specific functions which are useful in
\r
85 +There are also a number of notmuch-specific auxiliary functions and
\r
86 +variables which are useful in writing tests:
\r
90 @@ -212,3 +212,15 @@ writing tests:
\r
91 will initialize the mail database to a known state of 50 sample
\r
92 messages, (culled from the early history of the notmuch mailing
\r
95 + notmuch_counter_reset
\r
99 + These allow to count how many times notmuch binary is called.
\r
100 + notmuch_counter_reset() function generates a script that counts
\r
101 + how many times it is called and resets the counter to zero. The
\r
102 + function sets $notmuch_counter variable to the path to the
\r
103 + generated script that should be called instead of notmuch to do
\r
104 + the counting. The notmuch_counter() function returns the current
\r
106 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
107 index 93867b0..e3b85d0 100755
\r
108 --- a/test/test-lib.sh
\r
109 +++ b/test/test-lib.sh
\r
110 @@ -864,6 +864,38 @@ test_emacs () {
\r
111 emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"
\r
114 +# Creates a script that counts how much time it is executed and calls
\r
115 +# notmuch. $notmuch_counter is set to the path to the generated
\r
116 +# script. Use notmuch_counter() function to get the current counter
\r
118 +notmuch_counter_reset () {
\r
119 + notmuch_counter="$TMP_DIRECTORY/notmuch_counter"
\r
120 + if [ ! -x "$notmuch_counter" ]; then
\r
121 + notmuch_counter_state_path="$TMP_DIRECTORY/notmuch_counter.state"
\r
122 + cat <<EOF >"$notmuch_counter"
\r
125 +count=\$(cat "$notmuch_counter_state_path")
\r
126 +echo -n \$(expr \$count + 1) > "$notmuch_counter_state_path"
\r
128 +exec notmuch "\$@"
\r
130 + chmod +x "$notmuch_counter" || return
\r
133 + echo -n 0 > "$notmuch_counter_state_path" || return
\r
136 +# Returns the current notmuch counter value.
\r
137 +notmuch_counter () {
\r
138 + if [ -r "$notmuch_counter_state_path" ]; then
\r
139 + count=$(cat "$notmuch_counter_state_path")
\r
147 find_notmuch_path ()
\r