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