[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Testing a command

From: Lennart Borgman (gmail)
Subject: Testing a command
Date: Sat, 16 Aug 2008 03:18:07 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

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.)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]