From: Sebastian Rose <sebastian_rose@gmx.de>
To: Christian Ohler <ohler+emacs@fastmail.net>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
emacs-devel Mailinglist <emacs-devel@gnu.org>
Subject: Re: testing framework and package.el
Date: Sun, 03 Oct 2010 22:52:17 +0200 [thread overview]
Message-ID: <87vd5jvw1q.fsf@gmx.de> (raw)
In-Reply-To: <4CA86026.1020000@fastmail.net> (Christian Ohler's message of "Sun, 03 Oct 2010 21:51:18 +1100")
Christian Ohler <ohler+emacs@fastmail.net> writes:
> On 2/10/10 13:53, Sebastian Rose wrote:
>> Below that directory, a tree like the source tree exists:
>>
>> project
>> +-- lisp/
>> | +-- a.el
>> | `-- b/
>> | +-- b.el
>> |
>> `-- tests/
>> +-- a.el/
>> | +-- tests.el
>> | `-- a-defun.el
>> `-- b/
>> +-- b.el/
>> +-- tests.el
>> `-- b-defun.el
>>
>> If this setup exists, when editing defun-x in lisp/a.el,
>> `M-x org-test-test-current-defun' will load tests/a.el/defun-x.el
>> (fallback: tests.el there) and execute all tests with selector
>> "^a-defun".
>> `M-x org-test-test-buffer-file' in that same source file will load all
>> *.el files in tests/a.el/ and execute all ERT tests for selector "^a".
>>
>> This would a) recommend a certain structure for testing (what ever the
>> structure will be) and b) make testing a key-stroke.
> This structure looks like it is optimized for many test files for each file of
> non-test code. Right now, Emacs has 1735 .el files, and 35 files total in the
> tests/ directory. This ratio is not likely to invert any time soon. The
> structure that you describe could work, but isn't it overkill?
Might be overkill, yes. All I wrote here was just after the first
glance at ERT and few experiments. You're not the only one who says so
:)
I'll drop that probably. A structure like that could be enforced later
if needed. We will start with a very small project. I want to make it
easy to jump to the test-file for a given source-file and execute tests
for current defun automatically. This could be done based on such a
structure (i.e. conventions).
I guess reading more of ERT's code I'll find other ways to find the file
a certain test (or tests matching a selector) is defined.
>> 2.) Create temp buffers for output
>>
>> One thing I miss is a way to create output buffers automagically (I
>> didn't look deeper into the sources yet).
>>
>> I know Lennart Borgman has written something for nXhtml. It's called
>> ert2.el and part of the nXhtml distribution (but I did not comprehend
>> what's going on there yet - my elisp is badbadbad :). Maybe Lennart
>> will help here or even care for that addition?
> Lennart's code is already integrated in ERT, obsoleting ert2. I remember that I
> wasn't quite happy with his design, but didn't have time to fix it, and since it
> solved an important problem, I included it as an experimental addition in
> ert-exp.el.
OK, good. Found that, thanks. From skimming over that file I guess
that's what I was looking for and maybe even a bit more.
>> 3.) Compare output to control files
>>
>> ediff the contents of those output buffers with control files. We need
>> this feature to test org's exports. No one will find the time to sit
>> there and search hundreds of output files for errors "by hand" (once
>> tests exist).
> What do you mean by "sitting there and searching hundreds of output files for
> errors"? Do you have an example of tests where ERT's error reporting is too
> unspecific to be useful?
>
> I remember writing some tests roughly like this:
>
> (ert-deftest foo ()
> (with-temp-buffer
> (insert "initial buffer contents")
> (... invoke code under test ...)
> (should (equal (ert-filter-string (buffer-string) ...)
> "expected final buffer contents"))))
>
> Are you sure that you want the initial/expected buffer contents in their own
> files? Such a split between the inputs and the invocation of the code under
> test seems cumbersome. I guess if your inputs/expected outputs are complex
> enough, moving them out into files can make sense. Can you point me to some
> examples where you think the data is too complex to be in-line?
Org's exports to XHTML, LaTeX etc. We could compare them to control
files. The publishing mechanism might create quite big files and even
entire file/directory trees. Currently we publish our stuff and detect
regressions when clicking a link that points nowhere or validating a
XHTML page (spot checking).
> One limitations of my approach is that we really need some kind of
> "with-test-buffer" rather than "with-temp-buffer" that keeps the buffer around
> for inspection if the test fails, but this is item 2.) on your list already.
> Another limitation is that the explainer for `equal' is not as pretty as ediff,
> but OTOH, as soon as you want to compare text properties, ediff can't help
> anymore (AFAIK), while there is an explainer for
> ert-equal-including-properties'.
Also, I believe ediff is too interactive for a simple test run (diff's
exit status is 0 if no difference is found - don't know yet if and to
how ediff could be used non-interactively).
> Text properties (e.g., font lock properties) are important to many kinds of
> tests. Both ediff and using files are problematic in such cases because they
> don't support text properties. Do text properties never come up in your
> context?
Some so some so I guess. I didn't start to write actual tests yet.
This will be done by many people (I hope) and there will be many
different types of tests (I hope). Some will involve text properties,
too.
Thank's for your comments! I think I have enough to fill my spare time
this week :)
Sebastian
next prev parent reply other threads:[~2010-10-03 20:52 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-27 15:18 testing framework and package.el Sebastian Rose
2010-09-27 22:57 ` Stefan Monnier
2010-09-27 23:42 ` Sebastian Rose
2010-09-27 23:55 ` Sebastian Rose
2010-10-01 13:01 ` Christian Ohler
2010-10-02 3:53 ` Sebastian Rose
2010-10-03 10:51 ` Christian Ohler
2010-10-03 20:52 ` Sebastian Rose [this message]
2010-10-04 15:36 ` Christian Ohler
2010-10-04 16:48 ` Chong Yidong
2010-10-05 1:17 ` Christian Ohler
2010-10-05 1:38 ` Lennart Borgman
2010-10-05 1:50 ` Sebastian Rose
2010-10-05 3:31 ` Christian Ohler
2010-10-05 4:39 ` Stephen J. Turnbull
2010-10-05 16:43 ` Eric Schulte
2010-10-05 23:18 ` Stefan Monnier
2010-10-11 9:26 ` Christian Ohler
2010-10-12 3:02 ` Stephen J. Turnbull
2010-10-12 9:41 ` Lennart Borgman
2010-10-12 13:39 ` Stephen J. Turnbull
2010-10-12 16:28 ` Lennart Borgman
2010-10-12 17:37 ` Stephen J. Turnbull
2010-10-12 17:54 ` Lennart Borgman
2010-10-13 0:36 ` Stefan Monnier
2010-10-13 9:03 ` Stephen J. Turnbull
2010-10-13 10:00 ` Christian Ohler
2010-10-13 14:19 ` Stephen J. Turnbull
2010-10-17 6:37 ` Christian Ohler
2010-10-17 14:54 ` Stefan Monnier
2010-10-18 6:55 ` Stephen J. Turnbull
2010-10-12 14:36 ` Christian Ohler
2010-10-12 17:41 ` Stephen J. Turnbull
2010-10-13 10:00 ` Christian Ohler
2010-10-13 14:13 ` Stephen J. Turnbull
2010-10-17 6:37 ` Christian Ohler
2010-10-12 14:19 ` Christian Ohler
2010-10-12 17:58 ` Stephen J. Turnbull
2010-10-12 18:13 ` Lennart Borgman
2010-10-13 10:00 ` Christian Ohler
2010-10-04 17:22 ` Eric Schulte
2010-10-05 0:01 ` Sebastian Rose
2010-10-04 13:02 ` Masatake YAMATO
2010-10-05 3:29 ` Christian Ohler
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=87vd5jvw1q.fsf@gmx.de \
--to=sebastian_rose@gmx.de \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=ohler+emacs@fastmail.net \
/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.