From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.help Subject: Re: Writing ERT tests for asynchronous events Date: Thu, 02 Jan 2014 12:41:36 +0100 Message-ID: <87wqiiobkf.fsf@gmx.de> References: <87ppoaoe8o.fsf@linaro.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1388662923 19894 80.91.229.3 (2 Jan 2014 11:42:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 2 Jan 2014 11:42:03 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: Alex =?utf-8?Q?Benn=C3=A9e?= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jan 02 12:42:08 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Vygf8-0004Ur-MD for geh-help-gnu-emacs@m.gmane.org; Thu, 02 Jan 2014 12:42:06 +0100 Original-Received: from localhost ([::1]:44433 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vygf7-0002W8-Q0 for geh-help-gnu-emacs@m.gmane.org; Thu, 02 Jan 2014 06:42:05 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vygeq-0002Vz-R5 for help-gnu-emacs@gnu.org; Thu, 02 Jan 2014 06:41:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vygek-0001xj-PV for help-gnu-emacs@gnu.org; Thu, 02 Jan 2014 06:41:48 -0500 Original-Received: from mout.gmx.net ([212.227.17.21]:63871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vygek-0001xb-G2 for help-gnu-emacs@gnu.org; Thu, 02 Jan 2014 06:41:42 -0500 Original-Received: from detlef.gmx.de ([93.209.88.250]) by mail.gmx.com (mrgmx101) with ESMTPS (Nemesis) id 0LdLw5-1VYBes3mCH-00iROy for ; Thu, 02 Jan 2014 12:41:40 +0100 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") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) X-Provags-ID: V03:K0:HYfpyz8AIIgHkGI7NvWHcrGKJdJm+sL+Vnsqq/LKka2za70aX6m DToVhQdb9zUIny9lj/fj3Cr1UY99uwHjNcmedPb01rt6QtICIDTqQrwbIARoUqFyQb8qdEi hXl3PeyUOl0dL5oOlieNsz4zwA9buDgauRslityirrJrg4Q0ysCYhfiHG538AaktwhOUjhK 3krEavbDdtrdxxUJbhVTw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 212.227.17.21 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:95230 Archived-At: Alex Benn=C3=A9e 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=C3=A9e Best regards, Michael.