From 64010f1793287089ff8d0b703170a594c8b6ed4b Mon Sep 17 00:00:00 2001 From: Dmitry Kurochkin Date: Tue, 17 Jan 2012 17:09:35 +0400 Subject: [PATCH] Re: [PATCH 1/4] test: Add `test_emacs_expect_t'. --- 20/cb23d79c30d34861ad27eb6d1dd07c94158cba | 166 ++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 20/cb23d79c30d34861ad27eb6d1dd07c94158cba diff --git a/20/cb23d79c30d34861ad27eb6d1dd07c94158cba b/20/cb23d79c30d34861ad27eb6d1dd07c94158cba new file mode 100644 index 000000000..c367c9bb5 --- /dev/null +++ b/20/cb23d79c30d34861ad27eb6d1dd07c94158cba @@ -0,0 +1,166 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id ACDD6429E35 + for ; Tue, 17 Jan 2012 05:10:35 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.799 +X-Spam-Level: +X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id KjF75Akvrg+l for ; + Tue, 17 Jan 2012 05:10:35 -0800 (PST) +Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com + [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id C523C429E2F + for ; Tue, 17 Jan 2012 05:10:34 -0800 (PST) +Received: by bkty12 with SMTP id y12so515617bkt.26 + for ; Tue, 17 Jan 2012 05:10:32 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=Tot9QtECF1bmSmDHWRD2z51wUbh1ugWxwDf+l0beIGY=; + b=N4JI1NQprAxTjbg1FzU0u+XZa9YViMbl893MMqoB/kUMMijC31qcwCENEBlXI1YYX+ + OVz3XSaMNBDSkX9zGt3w4CLdv/0k26Xi5kESa1X8KyD5k8xbZKzJTimD/0L4P6jkWK3s + DjsUIWajAOg4vBg4dHPkWD7Zg/+uO6Y5yTu8A= +Received: by 10.205.120.17 with SMTP id fw17mr2696569bkc.74.1326805832003; + Tue, 17 Jan 2012 05:10:32 -0800 (PST) +Received: from localhost ([91.144.186.21]) + by mx.google.com with ESMTPS id ig13sm14880148bkc.9.2012.01.17.05.10.30 + (version=TLSv1/SSLv3 cipher=OTHER); + Tue, 17 Jan 2012 05:10:31 -0800 (PST) +From: Dmitry Kurochkin +To: David Edmondson , notmuch@notmuchmail.org +Subject: Re: [PATCH 1/4] test: Add `test_emacs_expect_t'. +In-Reply-To: <1326804748-8989-2-git-send-email-dme@dme.org> +References: <1326804748-8989-1-git-send-email-dme@dme.org> + <1326804748-8989-2-git-send-email-dme@dme.org> +User-Agent: Notmuch/0.11+73~g8a5402e (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Tue, 17 Jan 2012 17:09:35 +0400 +Message-ID: <87pqei327k.fsf@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 17 Jan 2012 13:10:35 -0000 + +On Tue, 17 Jan 2012 12:52:25 +0000, David Edmondson wrote: +> Add a new test function to allow simpler testing of emacs +> functionality. +> +> `test_emacs_expect_t' takes two arguments: +> - the name of the test, +> - some lisp to evaluate. +> +> The test passes if the lisp returns `t', otherwise it fails and the +> output is reported to the tester. + +-1 + +This is not what I suggested. I do not like the approach when a single +function is used to both declare a subtest and test for result (as +opposed to test_begin_subtest). The fact that it is possible to write +tests in two different ways makes it hard to maintain and improve the +test framework (one example would be known broken test support). I +consider the proper way to write tests to be using the +test_begin_subtest function. Other functions are not currently +deprecated, but I am against adding new code that make the situation +worse. + +Also, please consider documenting new functions in README. + +Regards, + Dmitry + +> --- +> test/emacs-test-functions.sh | 8 ++++++++ +> test/notmuch-test | 1 + +> test/test-lib.sh | 24 ++++++++++++++++++++++++ +> 3 files changed, 33 insertions(+), 0 deletions(-) +> create mode 100755 test/emacs-test-functions.sh +> +> diff --git a/test/emacs-test-functions.sh b/test/emacs-test-functions.sh +> new file mode 100755 +> index 0000000..969cc78 +> --- /dev/null +> +++ b/test/emacs-test-functions.sh +> @@ -0,0 +1,8 @@ +> +#!/usr/bin/env bash +> + +> +test_description="emacs test function sanity" +> +. test-lib.sh +> + +> +test_emacs_expect_t "emacs test function sanity" 't' +> + +> +test_done +> diff --git a/test/notmuch-test b/test/notmuch-test +> index 6a99ae3..d034f99 100755 +> --- a/test/notmuch-test +> +++ b/test/notmuch-test +> @@ -52,6 +52,7 @@ TESTS=" +> python +> hooks +> argument-parsing +> + emacs-test-functions.sh +> " +> TESTS=${NOTMUCH_TESTS:=$TESTS} +> +> diff --git a/test/test-lib.sh b/test/test-lib.sh +> index 7c9ce24..15da973 100644 +> --- a/test/test-lib.sh +> +++ b/test/test-lib.sh +> @@ -503,6 +503,30 @@ test_expect_equal_file () +> fi +> } +> +> +test_emacs_expect_t () { +> + test "$#" = 2 || error "bug in the test script: not 2 parameters to test_emacs_expect_t" +> + test_reset_state_ +> + if ! test_skip "$1" +> + then +> + # We cannot call 'test_emacs' in a subshell, because +> + # the setting of EMACS_SERVER would not persist +> + # throughout a sequence of tests, so we use a +> + # temporary file. +> + tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi +> + output="$tmp/test_emacs_output.$$" +> + test_emacs "$2" >"${output}" +> + result=$(cat "${output}") +> + rm -f "${output}" +> + +> + if [ "$result" == t ] +> + then +> + test_ok_ "$1" +> + else +> + test_failure_ "$1" "$(eval printf ${result})" +> + fi +> + fi +> +} +> + +> NOTMUCH_NEW () +> { +> notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file' +> -- +> 1.7.7.3 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2