all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Writing ERT tests for asynchronous events
@ 2014-01-02 10:43 Alex Bennée
  2014-01-02 11:41 ` Michael Albinus
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Bennée @ 2014-01-02 10:43 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Hi,

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

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 I can't do this is might be simpler to hook in bellow the network
processing bits but in that case I need create a mock process buffer to
represent the network connection process. What's the best way to do that?


Cheers,

--
Alex Bennée
http://www.bennee.com/~alex




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Writing ERT tests for asynchronous events
  2014-01-02 10:43 Writing ERT tests for asynchronous events Alex Bennée
@ 2014-01-02 11:41 ` Michael Albinus
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Albinus @ 2014-01-02 11:41 UTC (permalink / raw)
  To: Alex Bennée; +Cc: help-gnu-emacs@gnu.org

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.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-01-02 11:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-02 10:43 Writing ERT tests for asynchronous events Alex Bennée
2014-01-02 11:41 ` Michael Albinus

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.