Re: [PATCH 1/4] test: Add `test_emacs_expect_t'.
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Tue, 17 Jan 2012 13:09:35 +0000 (17:09 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:42:25 +0000 (09:42 -0800)
20/cb23d79c30d34861ad27eb6d1dd07c94158cba [new file with mode: 0644]

diff --git a/20/cb23d79c30d34861ad27eb6d1dd07c94158cba b/20/cb23d79c30d34861ad27eb6d1dd07c94158cba
new file mode 100644 (file)
index 0000000..c367c9b
--- /dev/null
@@ -0,0 +1,166 @@
+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 ACDD6429E35\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:10:35 -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 KjF75Akvrg+l for <notmuch@notmuchmail.org>;\r
+       Tue, 17 Jan 2012 05:10:35 -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 C523C429E2F\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:10:34 -0800 (PST)\r
+Received: by bkty12 with SMTP id y12so515617bkt.26\r
+       for <notmuch@notmuchmail.org>; Tue, 17 Jan 2012 05:10:32 -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=Tot9QtECF1bmSmDHWRD2z51wUbh1ugWxwDf+l0beIGY=;\r
+       b=N4JI1NQprAxTjbg1FzU0u+XZa9YViMbl893MMqoB/kUMMijC31qcwCENEBlXI1YYX+\r
+       OVz3XSaMNBDSkX9zGt3w4CLdv/0k26Xi5kESa1X8KyD5k8xbZKzJTimD/0L4P6jkWK3s\r
+       DjsUIWajAOg4vBg4dHPkWD7Zg/+uO6Y5yTu8A=\r
+Received: by 10.205.120.17 with SMTP id fw17mr2696569bkc.74.1326805832003;\r
+       Tue, 17 Jan 2012 05:10:32 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id ig13sm14880148bkc.9.2012.01.17.05.10.30\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 17 Jan 2012 05:10:31 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/4] test: Add `test_emacs_expect_t'.\r
+In-Reply-To: <1326804748-8989-2-git-send-email-dme@dme.org>\r
+References: <1326804748-8989-1-git-send-email-dme@dme.org>\r
+       <1326804748-8989-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 17:09:35 +0400\r
+Message-ID: <87pqei327k.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 13:10:35 -0000\r
+\r
+On Tue, 17 Jan 2012 12:52:25 +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 two arguments:\r
+>   - the name of the test,\r
+>   - some lisp to evaluate.\r
+> \r
+> The test passes if the lisp returns `t', otherwise it fails and the\r
+> output is reported to the tester.\r
+\r
+-1\r
+\r
+This is not what I suggested.  I do not like the approach when a single\r
+function is used to both declare a subtest and test for result (as\r
+opposed to test_begin_subtest).  The fact that it is possible to write\r
+tests in two different ways makes it hard to maintain and improve the\r
+test framework (one example would be known broken test support).  I\r
+consider the proper way to write tests to be using the\r
+test_begin_subtest function.  Other functions are not currently\r
+deprecated, but I am against adding new code that make the situation\r
+worse.\r
+\r
+Also, please consider documenting new functions in README.\r
+\r
+Regards,\r
+  Dmitry\r
+\r
+> ---\r
+>  test/emacs-test-functions.sh |    8 ++++++++\r
+>  test/notmuch-test            |    1 +\r
+>  test/test-lib.sh             |   24 ++++++++++++++++++++++++\r
+>  3 files changed, 33 insertions(+), 0 deletions(-)\r
+>  create mode 100755 test/emacs-test-functions.sh\r
+> \r
+> diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh\r
+> new file mode 100755\r
+> index 0000000..969cc78\r
+> --- /dev/null\r
+> +++ b/test/emacs-test-functions.sh\r
+> @@ -0,0 +1,8 @@\r
+> +#!/usr/bin/env bash\r
+> +\r
+> +test_description="emacs test function sanity"\r
+> +. test-lib.sh\r
+> +\r
+> +test_emacs_expect_t "emacs test function sanity" '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..15da973 100644\r
+> --- a/test/test-lib.sh\r
+> +++ b/test/test-lib.sh\r
+> @@ -503,6 +503,30 @@ test_expect_equal_file ()\r
+>      fi\r
+>  }\r
+>  \r
+> +test_emacs_expect_t () {\r
+> +    test "$#" = 2 || error "bug in the test script: not 2 parameters to test_emacs_expect_t"\r
+> +    test_reset_state_\r
+> +    if ! test_skip "$1"\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 "$2" >"${output}"\r
+> +            result=$(cat "${output}")\r
+> +            rm -f "${output}"\r
+> +\r
+> +            if [ "$result" == t ]\r
+> +            then\r
+> +                    test_ok_ "$1"\r
+> +            else\r
+> +                    test_failure_ "$1" "$(eval printf ${result})"\r
+> +            fi\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.7.3\r
+> \r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r