--- /dev/null
+Return-Path: <dmitry.kurochkin@gmail.com>\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 DA7A3431FC3\r
+ for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 07:25:41 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 D47bbXbuxxOk for <notmuch@notmuchmail.org>;\r
+ Tue, 24 Jan 2012 07:25:41 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+ [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id F2A94431FB6\r
+ for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 07:25:40 -0800 (PST)\r
+Received: by bkbzt19 with SMTP id zt19so2471534bkb.26\r
+ for <notmuch@notmuchmail.org>; Tue, 24 Jan 2012 07:25:39 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+ h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+ :mime-version:content-type;\r
+ bh=KmKOwMtsjWgH2tTOkXtFfSmbaZv/AuIGur5ti23SZOk=;\r
+ b=iUVIVLuxaU876m+xrQH/RqXNCVE9kJuHFfo47MZ4O9okFq5n4+HeGU/MxIpB/DaQRz\r
+ VUsqOqPnJ0pkWpFx1Gy8NUYlMlJQxT+5SDD2EbLUY1IbQNoIMG1qHIA42+s2ei3kzoCo\r
+ aL5iselKbwdtTvQtSqL8qaPHCYXHF9YdXDHsQ=\r
+Received: by 10.205.131.13 with SMTP id ho13mr3502284bkc.58.1327418739661;\r
+ Tue, 24 Jan 2012 07:25:39 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+ by mx.google.com with ESMTPS id d2sm36997318bky.11.2012.01.24.07.25.38\r
+ (version=TLSv1/SSLv3 cipher=OTHER);\r
+ Tue, 24 Jan 2012 07:25:39 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 2/4 v42] test: Add `test_emacs_expect_t'.\r
+In-Reply-To: <1327341947-29206-2-git-send-email-dme@dme.org>\r
+References: <1326804748-8989-2-git-send-email-dme@dme.org>\r
+ <1327341947-29206-1-git-send-email-dme@dme.org>\r
+ <1327341947-29206-2-git-send-email-dme@dme.org>\r
+User-Agent: Notmuch/0.11+100~gd650abf (http://notmuchmail.org) Emacs/23.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Tue, 24 Jan 2012 19:24:33 +0400\r
+Message-ID: <87ehupm8cu.fsf@gmail.com>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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: Tue, 24 Jan 2012 15:25:42 -0000\r
+\r
+On Mon, 23 Jan 2012 18:05:45 +0000, David Edmondson <dme@dme.org> wrote:\r
+> Add a new test function to allow simpler testing of emacs\r
+> functionality.\r
+> \r
+> `test_emacs_expect_t' takes one argument - a lisp expression to\r
+> evaluate. The test passes if the expression returns `t', otherwise it\r
+> fails and the output is reported to the tester.\r
+> ---\r
+> \r
+> As per Dmitry:\r
+> - don't call `test_skip' twice,\r
+> - allow for a prereq.\r
+> \r
+\r
+LGTM\r
+\r
+Regards,\r
+ Dmitry\r
+\r
+> test/README | 8 ++++++++\r
+> test/emacs-test-functions.sh | 9 +++++++++\r
+> test/notmuch-test | 1 +\r
+> test/test-lib.el | 9 +++++++++\r
+> test/test-lib.sh | 29 +++++++++++++++++++++++++++++\r
+> 5 files changed, 56 insertions(+), 0 deletions(-)\r
+> create mode 100755 test/emacs-test-functions.sh\r
+> \r
+> diff --git a/test/README b/test/README\r
+> index 44ff653..43656a3 100644\r
+> --- a/test/README\r
+> +++ b/test/README\r
+> @@ -202,6 +202,14 @@ library for your script to use.\r
+> tests that may run in the same Emacs instance. Use `let' instead\r
+> so the scope of the changed variables is limited to a single test.\r
+> \r
+> + test_emacs_expect_t <emacs-lisp-expressions>\r
+> +\r
+> + This function executes the provided emacs lisp script within\r
+> + emacs in a manner similar to 'test_emacs'. The expressions should\r
+> + return the value `t' to indicate that the test has passed. If the\r
+> + test does not return `t' then it is considered failed and all data\r
+> + returned by the test is reported to the tester.\r
+> +\r
+> test_done\r
+> \r
+> Your test script must have test_done at the end. Its purpose\r
+> diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh\r
+> new file mode 100755\r
+> index 0000000..0e1f9fc\r
+> --- /dev/null\r
+> +++ b/test/emacs-test-functions.sh\r
+> @@ -0,0 +1,9 @@\r
+> +#!/usr/bin/env bash\r
+> +\r
+> +test_description="emacs test function sanity"\r
+> +. test-lib.sh\r
+> +\r
+> +test_begin_subtest "emacs test function sanity"\r
+> +test_emacs_expect_t 't'\r
+> +\r
+> +test_done\r
+> diff --git a/test/notmuch-test b/test/notmuch-test\r
+> index 6a99ae3..d034f99 100755\r
+> --- a/test/notmuch-test\r
+> +++ b/test/notmuch-test\r
+> @@ -52,6 +52,7 @@ TESTS="\r
+> python\r
+> hooks\r
+> argument-parsing\r
+> + emacs-test-functions.sh\r
+> "\r
+> TESTS=${NOTMUCH_TESTS:=$TESTS}\r
+> \r
+> diff --git a/test/test-lib.el b/test/test-lib.el\r
+> index 59c5868..96752f0 100644\r
+> --- a/test/test-lib.el\r
+> +++ b/test/test-lib.el\r
+> @@ -83,3 +83,12 @@ nothing."\r
+> \r
+> (add-hook-counter 'notmuch-hello-mode-hook)\r
+> (add-hook-counter 'notmuch-hello-refresh-hook)\r
+> +\r
+> +(defmacro notmuch-test-run (&rest body)\r
+> + "Evaluate a BODY of test expressions and output the result."\r
+> + `(with-temp-buffer\r
+> + (let ((result (progn ,@body)))\r
+> + (insert (if (stringp result)\r
+> + result\r
+> + (prin1-to-string result)))\r
+> + (test-output))))\r
+> diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+> index 82c686c..8158328 100644\r
+> --- a/test/test-lib.sh\r
+> +++ b/test/test-lib.sh\r
+> @@ -503,6 +503,35 @@ test_expect_equal_file ()\r
+> fi\r
+> }\r
+> \r
+> +test_emacs_expect_t () {\r
+> + test "$#" = 2 && { prereq=$1; shift; } || prereq=\r
+> + test "$#" = 1 ||\r
+> + error "bug in the test script: not 1 or 2 parameters to test_emacs_expect_t"\r
+> +\r
+> + # Run the test.\r
+> + if ! test_skip "$test_subtest_name"\r
+> + then\r
+> + test_emacs "(notmuch-test-run $1)" >/dev/null\r
+> +\r
+> + # Restore state after the test.\r
+> + exec 1>&6 2>&7 # Restore stdout and stderr\r
+> + inside_subtest=\r
+> +\r
+> + # Report success/failure.\r
+> + result=$(cat OUTPUT)\r
+> + if [ "$result" = t ]\r
+> + then\r
+> + test_ok_ "$test_subtest_name"\r
+> + else\r
+> + test_failure_ "$test_subtest_name" "${result}"\r
+> + fi\r
+> + else\r
+> + # Restore state after the (non) test.\r
+> + exec 1>&6 2>&7 # Restore stdout and stderr\r
+> + inside_subtest=\r
+> + fi\r
+> +}\r
+> +\r
+> NOTMUCH_NEW ()\r
+> {\r
+> notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'\r
+> -- \r
+> 1.7.8.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r