all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Christian Ohler <ohler@gnu.org>
To: Stefan Merten <smerten@oekonux.de>
Cc: emacs-devel@gnu.org
Subject: Re: Running ert tests on buffers in rst.el and elsewhere
Date: Sat, 23 Jun 2012 00:37:36 +0200	[thread overview]
Message-ID: <4FE4F3B0.6070309@gnu.org> (raw)
In-Reply-To: <6280.1340054412@theowa.merten-home.homelinux.org>

Stefan Merten, 2012-06-18:

> I wanted to test functions which operate on buffers - i.e. use buffer
> content as input and possibly modify the buffer. Buffer includes point
> and mark in this case. Since I found no support for this requirement
> in the ert package I wrote some support code for it.

I only glanced at your code so far, but please do take a look at the 
current version of ERT, in particular the utility functions in ert-x.el 
and the way ert-x-tests.el uses them.

Some preliminary notes:

Is it true that your code covers two features, one about turning buffer 
content, point and mark into a data structure and back as well as 
comparing such data structures, the other about providing input to 
interactive functions like completing-read?

The function `ert-run-test-with-buffer' combines both features, and I 
don't think that's a good thing; it would be better to have a more 
primitive function `ert-run-with-interactive-inputs' (or similar) that 
doesn't do any of the buffer management, and let the programmer combine 
that function with `ert-with-test-buffer' and `ert-Buf-to-buffer' as 
appropriate.

Similarly, `ert-compare-test-with-buffer' looks like it checks a bunch 
of things that should probably be left as separate `should' forms on the 
caller's side.

With functions like `ert-equal-buffer', your code introduces a notion of 
equality of buffers, and its definition seems somewhat arbitrary, so I'm 
not sure it's a good one.  For example, it doesn't take buffer-local 
variables or markers into account.  It should be easy to avoid the 
question of what the right notion of buffer equality is by letting the 
programmer extract ert-Buf data structures from buffers and compare 
those in `should' forms with some equality predicate.

However, compared to the existing approach as used in the tests 
`ert-test-run-tests-interactively-2' and `ert-test-describe-test', your 
buffer handling functions add the ability to test the position of point 
and mark, while sacrificing the ability to test text properties (and 
thus font locking).  From a high-level perspective, testing point and 
mark looks like a small feature on top of testing buffer content, so I'm 
not sure it justifies as much additional machinery as your code seems to 
add; we should look for ways to simplify things.

As a first step, could make the two features (providing interactive 
input and handling buffer content) orthogonal and send separate patches, 
perhaps simplifying the buffer content code after looking at how it's 
done in ert-x-tests.el?


> The next step I considered was to support testing font locking - or
> may be text properties in general. However, I didn't start this yet.
> It certainly would be useful.

ert-x.el does have features related to this, see 
`ert-propertized-string' and `ert-equal-including-properties'.  ERT's 
self-tests make use of them.

Christian.




  parent reply	other threads:[~2012-06-22 22:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-18 21:20 Running ert tests on buffers in rst.el and elsewhere Stefan Merten
2012-06-19 18:06 ` Stefan Monnier
2012-06-25  9:20   ` Stefan Merten
2012-06-22 22:37 ` Christian Ohler [this message]
2012-06-25 10:06   ` Stefan Merten

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=4FE4F3B0.6070309@gnu.org \
    --to=ohler@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=smerten@oekonux.de \
    /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.