all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Albinus <michael.albinus@gmx.de>
To: "Alex Bennée" <kernel-hacker@bennee.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: Writing ERT tests for asynchronous events
Date: Thu, 02 Jan 2014 12:41:36 +0100	[thread overview]
Message-ID: <87wqiiobkf.fsf@gmx.de> (raw)
In-Reply-To: <87ppoaoe8o.fsf@linaro.org> ("Alex \=\?utf-8\?Q\?Benn\=C3\=A9e\=22's\?\= message of "Thu, 02 Jan 2014 10:43:51 +0000")

Alex Bennée <kernel-hacker@bennee.com> writes:

> Hi,

Hi Alex,

> Is there any support in ERT for things that have asynchronous behaviour?

I don't believe so.

> For example I want my test to kick off something using a url fetch
> (against a server running in the same emacs) and then once the
> transaction has completed test things have worked as expected
> using the ert operators.

If you are doing something asynchronously, certainly there is a hook you
can register your own function which is called when the asynchronous
action has been finished or a related event has happened. Add your own
function to this hook, which sets a bit or so.

In your ert test case, after invoking the asynchronous action, run a
timer. If the proper bit hasn't been set in time, let the test fail.

For example, see the Emacs repo, file test/automated/file-notify-tests.el,
function file-notify-test02-events, where I have implemented something
similar. file-notify--test-event-handler is my function to check
something and to set the result bits in the variable
file-notify--test-results. After waiting for 5 seconds, that variable is
checked for unsuccesful test results.

> Cheers,
>
> Alex Bennée

Best regards, Michael.



      reply	other threads:[~2014-01-02 11:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-02 10:43 Writing ERT tests for asynchronous events Alex Bennée
2014-01-02 11:41 ` Michael Albinus [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wqiiobkf.fsf@gmx.de \
    --to=michael.albinus@gmx.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=kernel-hacker@bennee.com \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.