all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* ERT: How to implement expensive initialization and cleanup?
@ 2023-06-04 20:04 Jens Schmidt
  2023-06-05 11:11 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Jens Schmidt @ 2023-06-04 20:04 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-05 11:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-04 20:04 ERT: How to implement expensive initialization and cleanup? Jens Schmidt
2023-06-05 11:11 ` Eli Zaretskii

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.