Re: [PATCH 1/3] test: add functions to count how much times notmuch was called
authorAustin Clements <amdragon@MIT.EDU>
Mon, 28 Nov 2011 02:44:23 +0000 (21:44 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:40:27 +0000 (09:40 -0800)
61/4423a379c209998504e3fcee3a2493dd248d2e [new file with mode: 0644]

diff --git a/61/4423a379c209998504e3fcee3a2493dd248d2e b/61/4423a379c209998504e3fcee3a2493dd248d2e
new file mode 100644 (file)
index 0000000..ed90c00
--- /dev/null
@@ -0,0 +1,197 @@
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 97FC3429E25\r
+       for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 18:42:20 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id gRplxTeb3adG for <notmuch@notmuchmail.org>;\r
+       Sun, 27 Nov 2011 18:42:19 -0800 (PST)\r
+Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
+       [18.9.25.14])\r
+       by olra.theworths.org (Postfix) with ESMTP id C088B431FB6\r
+       for <notmuch@notmuchmail.org>; Sun, 27 Nov 2011 18:42:19 -0800 (PST)\r
+X-AuditID: 1209190e-b7f4a6d0000008e5-ef-4ed2f50bc965\r
+Received: from mailhub-auth-2.mit.edu ( [18.7.62.36])\r
+       by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
+       id 9B.87.02277.B05F2DE4; Sun, 27 Nov 2011 21:42:19 -0500 (EST)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+       by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id pAS2gIs7007692; \r
+       Sun, 27 Nov 2011 21:42:19 -0500\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+       (authenticated bits=0)\r
+       (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+       by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id pAS2gHKv023245\r
+       (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+       Sun, 27 Nov 2011 21:42:18 -0500 (EST)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+       (envelope-from <amdragon@mit.edu>)\r
+       id 1RUrCh-0000RK-Lj; Sun, 27 Nov 2011 21:44:23 -0500\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/3] test: add functions to count how much times notmuch\r
+       was called\r
+In-Reply-To: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+References: <1322271878-32614-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+User-Agent: Notmuch/0.9+77~gfdb7dac (http://notmuchmail.org) Emacs/23.3.1\r
+       (i486-pc-linux-gnu)\r
+Date: Sun, 27 Nov 2011 21:44:23 -0500\r
+Message-ID: <87ipm52cfs.fsf@awakening.csail.mit.edu>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFrrLIsWRmVeSWpSXmKPExsUixG6nosv99ZKfwcH/EhZXt/azW1y/OZPZ\r
+       gclj56y77B7PVt1iDmCK4rJJSc3JLEst0rdL4Mp49m4TS8Fa+YrN/V/YGhjfSXQxcnJICJhI\r
+       fNiwkRHCFpO4cG89G4gtJLCPUWLOUr4uRi4gewOjxI9b81khnJNMEg/OvGeBqFrCKNF4ORrE\r
+       ZhPQkNi2fznYJBEBL4lP1zuYQWxhgXCJXfdXAzVzcHAKeEv8/80CYgoBlUxZzgpSISoQK/F2\r
+       9kRmkDCLgKrEozP2IGFeoNM2fD7AAmELSpyc+QTMZhbQkrjx7yXTBEaBWUhSs5CkFjAyrWKU\r
+       Tcmt0s1NzMwpTk3WLU5OzMtLLdI11svNLNFLTSndxAgKRU5Jvh2MXw8qHWIU4GBU4uHluHbJ\r
+       T4g1say4MvcQoyQHk5Io7+XPQCG+pPyUyozE4oz4otKc1OJDjBIczEoivD1HgXK8KYmVValF\r
+       +TApaQ4WJXHe1Tsc/IQE0hNLUrNTUwtSi2CyMhwcShK8fl+AGgWLUtNTK9Iyc0oQ0kwcnCDD\r
+       eYCGd4Es5i0uSMwtzkyHyJ9iVJQS5w0HaRYASWSU5sH1wlLFK0ZxoFeEeZ1BqniAaQau+xXQ\r
+       YCagwRwzL4AMLklESEk1MIafXG0e/zpAw6pFrKZk0V8xqU29DyX+VfesKSjxM/939aud06N1\r
+       jZ3z1+d09Oyb+Gzn5Aneb5Z++f/OKmeHj3mPoURjWYHNk2qHrc/v3T2etsbWoCA1MGfitcJ5\r
+       MdcOS/f/WPVyZpzJUSODCwI/nrZ9bX60u/zkGRdhn/qLUusN5/wNYzk+97wSS3FGoqEWc1Fx\r
+       IgDEzyk08AIAAA==\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 28 Nov 2011 02:42:20 -0000\r
+\r
+On Sat, 26 Nov 2011 05:44:36 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:\r
+> The patch adds two auxiliary functions and a variable:\r
+> \r
+>   notmuch_counter_reset\r
+>   $notmuch_counter\r
+>   notmuch_counter\r
+> \r
+> They allow to count how many times notmuch binary is called.\r
+> notmuch_counter_reset() function generates a script that counts how\r
+> many times it is called and resets the counter to zero.  The function\r
+> sets $notmuch_counter variable to the path to the generated script\r
+> that should be called instead of notmuch to do the counting.  The\r
+> notmuch_counter() function returns the current counter value.\r
+\r
+Great idea!\r
+\r
+> ---\r
+>  test/README      |   16 ++++++++++++++--\r
+>  test/test-lib.sh |   32 ++++++++++++++++++++++++++++++++\r
+>  2 files changed, 46 insertions(+), 2 deletions(-)\r
+> \r
+> diff --git a/test/README b/test/README\r
+> index 2481f16..1570f7c 100644\r
+> --- a/test/README\r
+> +++ b/test/README\r
+> @@ -187,8 +187,8 @@ library for your script to use.\r
+>     is to summarize successes and failures in the test script and\r
+>     exit with an appropriate error code.\r
+>  \r
+> -There are also a number of mail-specific functions which are useful in\r
+> -writing tests:\r
+> +There are also a number of notmuch-specific auxiliary functions and\r
+> +variables which are useful in writing tests:\r
+>  \r
+>    generate_message\r
+>  \r
+> @@ -212,3 +212,15 @@ writing tests:\r
+>      will initialize the mail database to a known state of 50 sample\r
+>      messages, (culled from the early history of the notmuch mailing\r
+>      list).\r
+> +\r
+> +  notmuch_counter_reset\r
+> +  $notmuch_counter\r
+> +  notmuch_counter\r
+\r
+>From the name, I would expect $notmuch_counter to be the counter value\r
+(ignoring the difficulty of implementing that).  Perhaps\r
+$notmuch_counter_command, since it's meant to be bound to\r
+notmuch-command?\r
+\r
+notmuch_counter is okay, but maybe notmuch_counter_value?\r
+\r
+> +\r
+> +    These allow to count how many times notmuch binary is called.\r
+> +    notmuch_counter_reset() function generates a script that counts\r
+> +    how many times it is called and resets the counter to zero.  The\r
+> +    function sets $notmuch_counter variable to the path to the\r
+> +    generated script that should be called instead of notmuch to do\r
+> +    the counting.  The notmuch_counter() function returns the current\r
+> +    counter value.\r
+\r
+It doesn't return the counter value, it prints it.\r
+\r
+> diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+> index 93867b0..e3b85d0 100755\r
+> --- a/test/test-lib.sh\r
+> +++ b/test/test-lib.sh\r
+> @@ -864,6 +864,38 @@ test_emacs () {\r
+>      emacsclient --socket-name="$EMACS_SERVER" --eval "(progn $@)"\r
+>  }\r
+>  \r
+> +# Creates a script that counts how much time it is executed and calls\r
+> +# notmuch.  $notmuch_counter is set to the path to the generated\r
+> +# script.  Use notmuch_counter() function to get the current counter\r
+> +# value.\r
+> +notmuch_counter_reset () {\r
+> +    notmuch_counter="$TMP_DIRECTORY/notmuch_counter"\r
+> +    if [ ! -x "$notmuch_counter" ]; then\r
+> +            notmuch_counter_state_path="$TMP_DIRECTORY/notmuch_counter.state"\r
+> +            cat <<EOF >"$notmuch_counter"\r
+\r
+This is totally a stylistic pet peeve, but consider\r
+  cat >"$notmuch_counter" <<EOF\r
+\r
+> +#!/bin/sh\r
+> +\r
+> +count=\$(cat "$notmuch_counter_state_path")\r
+> +echo -n \$(expr \$count + 1) > "$notmuch_counter_state_path"\r
+> +\r
+> +exec notmuch "\$@"\r
+> +EOF\r
+> +            chmod +x "$notmuch_counter" || return\r
+> +    fi\r
+> +\r
+> +    echo -n 0 > "$notmuch_counter_state_path" || return\r
+\r
+What are the || return's for?\r
+\r
+> +}\r
+> +\r
+> +# Returns the current notmuch counter value.\r
+> +notmuch_counter () {\r
+> +    if [ -r "$notmuch_counter_state_path" ]; then\r
+> +            count=$(cat "$notmuch_counter_state_path")\r
+> +    else\r
+> +            count=0\r
+> +    fi\r
+> +    echo -n $count\r
+> +}\r
+> +\r
+>  \r
+>  find_notmuch_path ()\r
+>  {\r
+> -- \r
+> 1.7.7.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r
+> \r