unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
Cc: emacs-devel@gnu.org
Subject: Re: ERT: How to implement expensive initialization and cleanup?
Date: Mon, 05 Jun 2023 14:11:18 +0300	[thread overview]
Message-ID: <83wn0i410p.fsf@gnu.org> (raw)
In-Reply-To: <46df52d2-5f3d-7807-c396-9838a219543e@vodafonemail.de> (message from Jens Schmidt on Sun, 4 Jun 2023 22:04:23 +0200)

> Date: Sun, 4 Jun 2023 22:04:23 +0200
> From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
> 
> Trying to write my first ERT test.  For the tests I need to set up a 
> GnuPG home directory from scratch, including directory creation, key 
> import, and key trust management.  Plus I need to clean up that mess 
> after the tests have finished.  Takes some 2secs on my system with all 
> that process communication between Emacs and GnuPG.

Are these test files constant, i.e. do you need to create the same
files time and again each time the test is run?  If so, perhaps take a
look at ert-resource-directory and its friends in ert-x.el.  You will
see in our test suite several examples of tests that use such constant
data.  Data that is the same in all tests is better made part of the
test suite, so it doesn't need to be generated as part of running the
test.

> The cleanest solution would be to do that for every test, but that would 
> get expensive if I go for many small tests, which seems to be better in 
> terms of diagnosability.

I wouldn't worry about performance too much in this case.  Don't
forget that an important feature of the test suite is to be able to
run each test in the FOO-tests.el file individually.  So you'll need
to allow per-test initialization anyway.



      reply	other threads:[~2023-06-05 11:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-04 20:04 ERT: How to implement expensive initialization and cleanup? Jens Schmidt
2023-06-05 11:11 ` Eli Zaretskii [this message]

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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83wn0i410p.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jschmidt4gnu@vodafonemail.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).