Re: [PATCH 2/3] test: Add `test_emacs_expect_t'.
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Tue, 17 Jan 2012 14:26:41 +0000 (18:26 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:26 +0000 (09:42 -0800)
b7/195b39afc05b5cc162bfc713acb8b452c7f218 [new file with mode: 0644]

diff --git a/b7/195b39afc05b5cc162bfc713acb8b452c7f218 b/b7/195b39afc05b5cc162bfc713acb8b452c7f218
new file mode 100644 (file)
index 0000000..9f10668
--- /dev/null
@@ -0,0 +1,191 @@
+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 753AE421189\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:27:44 -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 EeSAcwjiMD4H for <notmuch@notmuchmail.org>;\r
+       Tue, 17 Jan 2012 06:27:42 -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 6DB52429E5F\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:27:41 -0800 (PST)\r
+Received: by bkty12 with SMTP id y12so588519bkt.26\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 06:27:40 -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=hmOa0SPnWucth87fLb9RlbZRurMXcoLs75O8NJUC2Ck=;\r
+       b=VuONem7oe4btJuASsU4mgbPtYikcIj4AEmssrSdna/kJA4jIGVFc1Xmy8lHBCwMQil\r
+       tL3+eLkhznljlKnMcrdkcP/4TDKBUEFML8QV2UKjTetLuGUln8lgATBycG9IGNF3Ty0K\r
+       EkaZGYsv62oQs6zhhwxHRWMWLeUvvbLN7LjC8=\r
+Received: by 10.204.145.86 with SMTP id c22mr6635430bkv.61.1326810458229;\r
+       Tue, 17 Jan 2012 06:27:38 -0800 (PST)\r
+Received: from localhost ([91.144.186.21]) by mx.google.com with ESMTPS id\r
+       fg16sm47481673bkb.16.2012.01.17.06.27.36\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 17 Jan 2012 06:27:37 -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/3] test: Add `test_emacs_expect_t'.\r
+In-Reply-To: <1326809224-22673-2-git-send-email-dme@dme.org>\r
+References: <87pqei327k.fsf@gmail.com>\r
+       <1326809224-22673-1-git-send-email-dme@dme.org>\r
+       <1326809224-22673-2-git-send-email-dme@dme.org>\r
+User-Agent: Notmuch/0.11+73~g8a5402e (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Tue, 17 Jan 2012 18:26:41 +0400\r
+Message-ID: <877h0qxv4u.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, 17 Jan 2012 14:27:46 -0000\r
+\r
+On Tue, 17 Jan 2012 14:07:03 +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 list 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
+> Re-worked as Dmitry suggested.\r
+> \r
+>  test/README                  |    8 ++++++++\r
+>  test/emacs-test-functions.sh |    9 +++++++++\r
+>  test/notmuch-test            |    1 +\r
+>  test/test-lib.sh             |   33 +++++++++++++++++++++++++++++++++\r
+>  4 files changed, 51 insertions(+), 0 deletions(-)\r
+>  create mode 100755 test/emacs-test-functions.sh\r
+> \r
+> diff --git a/test/README b/test/README\r
+> index bde6db0..9dbe2ee 100644\r
+> --- a/test/README\r
+> +++ b/test/README\r
+> @@ -189,6 +189,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.sh b/test/test-lib.sh\r
+> index 7c9ce24..4b05760 100644\r
+> --- a/test/test-lib.sh\r
+> +++ b/test/test-lib.sh\r
+> @@ -503,6 +503,39 @@ test_expect_equal_file ()\r
+>      fi\r
+>  }\r
+>  \r
+> +test_emacs_expect_t () {\r
+> +    test "$#" = 1 || error "bug in the test script: not 1 parameter to test_emacs_expect_t"\r
+> +\r
+> +    # Run the test.\r
+> +    if ! test_skip "$test_subtest_name"\r
+> +    then\r
+> +            # We cannot call 'test_emacs' in a subshell, because\r
+> +            # the setting of EMACS_SERVER would not persist\r
+> +            # throughout a sequence of tests, so we use a\r
+> +            # temporary file.\r
+> +            tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi\r
+> +            output="$tmp/test_emacs_output.$$"\r
+> +            test_emacs "$1" > "${output}"\r
+> +            result=$(cat "${output}")\r
+> +            rm -f "${output}"\r
+> +    fi\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
+> +    if ! test_skip "$test_subtest_name"\r
+> +    then\r
+> +            if [ "$result" == t ]\r
+> +            then\r
+> +                    test_ok_ "$test_subtest_name"\r
+> +            else\r
+> +                    test_failure_ "$test_subtest_name" "$(eval printf ${result})"\r
+> +            fi\r
+> +    fi\r
+> +}\r
+> +\r
+\r
+Sorry, I still do not understand why we can not implement\r
+test_emacs_expect_t() like:\r
+\r
+  result=${test_emacs $@}\r
+  test_expect_equal $result t\r
+\r
+Can you please explain?\r
+\r
+Regards,\r
+  Dmitry\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.7.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r