From: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
To: Emacs Devel <emacs-devel@gnu.org>,
Phil Hagelberg <phil@hagelb.org>,
Christian Ohler <ohler+emacs@fastmail.net>
Subject: Testing a command
Date: Sat, 16 Aug 2008 03:18:07 +0200 [thread overview]
Message-ID: <48A62ACF.3080700@gmail.com> (raw)
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 other threads:[~2008-08-16 1:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48A62ACF.3080700@gmail.com \
--to=lennart.borgman@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=ohler+emacs@fastmail.net \
--cc=phil@hagelb.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.