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 83B40429E5A for ; Tue, 17 Jan 2012 04:52:47 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[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 Exa-XGbmLHQA for ; Tue, 17 Jan 2012 04:52:47 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id BE485429E2F for ; Tue, 17 Jan 2012 04:52:46 -0800 (PST) Received: by wgbdr13 with SMTP id dr13so1204929wgb.2 for ; Tue, 17 Jan 2012 04:52:45 -0800 (PST) Received: by 10.180.81.66 with SMTP id y2mr9399704wix.20.1326804765343; Tue, 17 Jan 2012 04:52:45 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id l2sm31292557wie.11.2012.01.17.04.52.43 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 17 Jan 2012 04:52:43 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 036369FCDD; Tue, 17 Jan 2012 12:52:42 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH 1/4] test: Add `test_emacs_expect_t'. Date: Tue, 17 Jan 2012 12:52:25 +0000 Message-Id: <1326804748-8989-2-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1326804748-8989-1-git-send-email-dme@dme.org> References: <1326804748-8989-1-git-send-email-dme@dme.org> 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 12:52:47 -0000 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. --- 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