all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jens Schmidt <jschmidt4gnu@vodafonemail.de>
To: emacs-devel@gnu.org
Subject: ERT: How to implement expensive initialization and cleanup?
Date: Sun, 4 Jun 2023 22:04:23 +0200	[thread overview]
Message-ID: <46df52d2-5f3d-7807-c396-9838a219543e@vodafonemail.de> (raw)

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.

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.

So a one-time setup at the beginning of "all tests" and a one-time 
cleanup at the end of "all tests" would be what I need, independently of 
where "all tests" begin and end: It might be really all tests when I do 
a batch run or just one test when I execute `ert-run-tests-interactively'.

I thought about some `ert-setup-hook' and `ert-cleanup-hook' executed 
e.g. in `ert-run-tests', but I haven't found anything like that. 
Besides that, this works out only if you run tests from only one "test 
set" which all share the same setup and cleanup.

Lazy initialization would also work for this kind or problem, but how 
would I trigger "lazy cleanup", then?  Just leave (in my case) the 
temporary GnuPG home directory to be cleaned up by the OS?  Or at least 
clean it up at the end of the test file, which would cover the batch 
tests, but not single tests?

Anything else?

Thanks



             reply	other threads:[~2023-06-04 20:04 UTC|newest]

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

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=46df52d2-5f3d-7807-c396-9838a219543e@vodafonemail.de \
    --to=jschmidt4gnu@vodafonemail.de \
    --cc=emacs-devel@gnu.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.