From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Lennart Borgman (gmail)" Newsgroups: gmane.emacs.devel Subject: Testing a command Date: Sat, 16 Aug 2008 03:18:07 +0200 Message-ID: <48A62ACF.3080700@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1218849511 27237 80.91.229.12 (16 Aug 2008 01:18:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Aug 2008 01:18:31 +0000 (UTC) To: Emacs Devel , Phil Hagelberg , Christian Ohler Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 16 03:19:23 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KUARq-0006Tr-4G for ged-emacs-devel@m.gmane.org; Sat, 16 Aug 2008 03:19:18 +0200 Original-Received: from localhost ([127.0.0.1]:57757 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KUAQt-0003Dd-GA for ged-emacs-devel@m.gmane.org; Fri, 15 Aug 2008 21:18:19 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KUAQq-0003DY-LD for emacs-devel@gnu.org; Fri, 15 Aug 2008 21:18:16 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KUAQp-0003DL-9F for emacs-devel@gnu.org; Fri, 15 Aug 2008 21:18:15 -0400 Original-Received: from [199.232.76.173] (port=41617 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KUAQp-0003DI-3Y for emacs-devel@gnu.org; Fri, 15 Aug 2008 21:18:15 -0400 Original-Received: from ch-smtp01.sth.basefarm.net ([80.76.149.212]:52469) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KUAQo-0001sW-PK for emacs-devel@gnu.org; Fri, 15 Aug 2008 21:18:15 -0400 Original-Received: from c83-254-151-176.bredband.comhem.se ([83.254.151.176]:61893 helo=[127.0.0.1]) by ch-smtp01.sth.basefarm.net with esmtp (Exim 4.68) (envelope-from ) id 1KUAQn-0002k0-3k; Sat, 16 Aug 2008 03:18:13 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071031 Thunderbird/2.0.0.9 Mnenhy/0.7.5.666 X-Antivirus: avast! (VPS 080815-0, 2008-08-15), Outbound message X-Antivirus-Status: Clean X-Originating-IP: 83.254.151.176 X-Scan-Result: No virus found in message 1KUAQn-0002k0-3k. X-Scan-Signature: ch-smtp01.sth.basefarm.net 1KUAQn-0002k0-3k 2100143cf96e63c1d0dfbd30bfe1eb03 X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:102508 Archived-At: As I have mentioned I am (with due help of Christian and Phil) trying to write some test scripts for nXhtml and MuMaMo. This scripts uses ert.el. One thing that come to my mind is that I do not actually really know how to test an Emacs command function. And in the case of MuMaMo where I want to test the fontification it is a little bit more complicated. However I would like some suggestions for a general pattern for testing a command. There is not much to say about the command itself, but I might miss things about hooks and timers. * Which hooks are always involved? Is there any other than before-change-functions, after-change-functions, pre-command-hook and post-command-hook? * I guess that before-change-functions and after-change-functions are run immediately at each separate buffer change in a command so that there is nothing extra to do during testing. Is this correct? * Is there any general way to test for errors that happened during the execution of these hooks? * For pre-command-hook and post-command-hook I guess you can just run them with run-hooks and check for errors as usual. Is that correct? * How should the idle timers be handled? Is it ok to do it like this (after a suggestion from Christian, the bad function name is mine): (defun nxhtmltest-fontify-w-timers-handlers () (dolist (timer (copy-list timer-idle-list)) (timer-event-handler timer)) (redisplay t)) The pattern for testing a command then to me looks something like this - Setup for testing - Call the pre-command-hook (with error checking) - Check any log buffers - Call the command function (with error checking) - Check any log buffers - Check for after/before-change-hook errors - Call post-command-hook (with error checking) - Check any log buffers - Call idle timers (with error checking) - Check any log buffers - Check the result Does any one have comments or suggestions about this? (One difficulty I can see is that the idle timers maybe should not always be run, but I have no good idea about how to handle this. It is a stochastic problem.)