From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>
To: David Edmondson <dme@dme.org>, notmuch@notmuchmail.org
Subject: Re: [PATCH 2/3] test: Add `test_emacs_expect_t'.
Date: Tue, 17 Jan 2012 18:26:41 +0400 [thread overview]
Message-ID: <877h0qxv4u.fsf@gmail.com> (raw)
In-Reply-To: <1326809224-22673-2-git-send-email-dme@dme.org>
On Tue, 17 Jan 2012 14:07:03 +0000, David Edmondson <dme@dme.org> wrote:
> Add a new test function to allow simpler testing of emacs
> functionality.
>
> `test_emacs_expect_t' takes one argument - a list expression to
> evaluate. The test passes if the expression returns `t', otherwise it
> fails and the output is reported to the tester.
> ---
>
> Re-worked as Dmitry suggested.
>
> test/README | 8 ++++++++
> test/emacs-test-functions.sh | 9 +++++++++
> test/notmuch-test | 1 +
> test/test-lib.sh | 33 +++++++++++++++++++++++++++++++++
> 4 files changed, 51 insertions(+), 0 deletions(-)
> create mode 100755 test/emacs-test-functions.sh
>
> diff --git a/test/README b/test/README
> index bde6db0..9dbe2ee 100644
> --- a/test/README
> +++ b/test/README
> @@ -189,6 +189,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 <emacs-lisp-expressions>
> +
> + 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.sh b/test/test-lib.sh
> index 7c9ce24..4b05760 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -503,6 +503,39 @@ test_expect_equal_file ()
> fi
> }
>
> +test_emacs_expect_t () {
> + test "$#" = 1 || error "bug in the test script: not 1 parameter to test_emacs_expect_t"
> +
> + # Run the test.
> + if ! test_skip "$test_subtest_name"
> + 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 "$1" > "${output}"
> + result=$(cat "${output}")
> + rm -f "${output}"
> + fi
> +
> + # Restore state after the test.
> + exec 1>&6 2>&7 # Restore stdout and stderr
> + inside_subtest=
> +
> + # Report success/failure.
> + if ! test_skip "$test_subtest_name"
> + then
> + if [ "$result" == t ]
> + then
> + test_ok_ "$test_subtest_name"
> + else
> + test_failure_ "$test_subtest_name" "$(eval printf ${result})"
> + fi
> + fi
> +}
> +
Sorry, I still do not understand why we can not implement
test_emacs_expect_t() like:
result=${test_emacs $@}
test_expect_equal $result t
Can you please explain?
Regards,
Dmitry
> 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
next prev parent reply other threads:[~2012-01-17 14:27 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-17 12:52 emacs based tests, version 3 David Edmondson
2012-01-17 12:52 ` [PATCH 1/4] test: Add `test_emacs_expect_t' David Edmondson
2012-01-17 13:09 ` Dmitry Kurochkin
2012-01-17 13:24 ` David Edmondson
2012-01-17 14:07 ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester David Edmondson
2012-01-17 14:07 ` [PATCH 2/3] test: Add `test_emacs_expect_t' David Edmondson
2012-01-17 14:26 ` Dmitry Kurochkin [this message]
2012-01-17 14:35 ` David Edmondson
2012-01-17 14:43 ` Dmitry Kurochkin
[not found] ` <87zkdmwfi7.fsf@gmail.com>
2012-01-17 15:09 ` David Edmondson
2012-01-18 9:09 ` Tomi Ollila
2012-01-18 14:55 ` Tomi Ollila
2012-01-19 9:59 ` David Edmondson
2012-01-19 10:32 ` Tomi Ollila
2012-01-19 10:42 ` David Edmondson
2012-01-19 11:01 ` Tomi Ollila
2012-01-19 12:54 ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester David Edmondson
2012-01-19 12:54 ` [PATCH 2/3] test: Add `test_emacs_expect_t' David Edmondson
2012-01-23 11:47 ` David Edmondson
2012-01-23 16:45 ` Dmitry Kurochkin
2012-01-19 12:54 ` [PATCH 3/3] test: Add address cleaning tests David Edmondson
2012-01-23 17:26 ` Dmitry Kurochkin
2012-01-23 16:32 ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester Dmitry Kurochkin
2012-01-17 14:07 ` [PATCH 3/3] test: Add address cleaning tests David Edmondson
2012-01-17 14:20 ` [PATCH 1/3] test: Don't return the result of checking for running emacs to the tester Dmitry Kurochkin
2012-01-17 14:37 ` David Edmondson
2012-01-17 14:51 ` Dmitry Kurochkin
2012-01-23 18:05 ` [PATCH 1/4 v42] " David Edmondson
2012-01-23 18:05 ` [PATCH 2/4 v42] test: Add `test_emacs_expect_t' David Edmondson
2012-01-24 15:24 ` Dmitry Kurochkin
2012-01-23 18:05 ` [PATCH 3/4 v42] test: Add more helpers for emacs tests David Edmondson
2012-01-24 15:45 ` Dmitry Kurochkin
2012-01-24 15:54 ` David Edmondson
2012-01-23 18:05 ` [PATCH 4/4 v42] test: Add address cleaning tests David Edmondson
2012-01-24 15:35 ` Dmitry Kurochkin
2012-01-24 15:20 ` [PATCH 1/4 v42] test: Don't return the result of checking for running emacs to the tester Dmitry Kurochkin
2012-01-24 16:14 ` [PATCH 0/4 v43] emacs test helpers David Edmondson
2012-01-24 16:14 ` [PATCH 1/4 v43] test: Don't return the result of checking for running emacs to the tester David Edmondson
2012-01-24 16:14 ` [PATCH 2/4 v43] test: Add `test_emacs_expect_t' David Edmondson
2012-01-24 16:14 ` [PATCH 3/4 v43] test: Add more helpers for emacs tests David Edmondson
2012-01-24 16:14 ` [PATCH 4/4 v43] test: Add address cleaning tests David Edmondson
2012-01-24 16:19 ` [PATCH 0/4 v43] emacs test helpers Dmitry Kurochkin
2012-01-24 20:13 ` Tomi Ollila
2012-01-25 11:33 ` David Bremner
2012-01-17 12:52 ` [PATCH 2/4] test: Add address cleaning tests David Edmondson
2012-01-17 13:11 ` Dmitry Kurochkin
2012-01-17 13:23 ` David Edmondson
2012-01-17 12:52 ` [PATCH 3/4] emacs: Avoid `mail-header-parse-address' in `notmuch-show-clean-address' David Edmondson
2012-01-17 12:52 ` [PATCH 4/4] emacs: Another special case for `notmuch-show-clean-address' David Edmondson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877h0qxv4u.fsf@gmail.com \
--to=dmitry.kurochkin@gmail.com \
--cc=dme@dme.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).