[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Writing ERT tests for asynchronous events
From: |
Michael Albinus |
Subject: |
Re: Writing ERT tests for asynchronous events |
Date: |
Thu, 02 Jan 2014 12:41:36 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
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.