From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: ERT: How to implement expensive initialization and cleanup? Date: Mon, 05 Jun 2023 14:11:18 +0300 Message-ID: <83wn0i410p.fsf@gnu.org> References: <46df52d2-5f3d-7807-c396-9838a219543e@vodafonemail.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10261"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jens Schmidt Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jun 05 13:12:24 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q688O-0002X0-BM for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Jun 2023 13:12:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q687R-0000f1-0u; Mon, 05 Jun 2023 07:11:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q687O-0000e6-28 for emacs-devel@gnu.org; Mon, 05 Jun 2023 07:11:22 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q687N-00046G-A3; Mon, 05 Jun 2023 07:11:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=+bO2VsDL6m2p7mJJHI4bFtPWKp8htYU9T+Yzw4ZEXZY=; b=pgUG28jJRkqp cBkMfn2xz/mze8YJSGqMV75xlSoWYWTmrx/xehkMukoxif3O8giGNqRRHSpXfSBfqvcZgexK654me asACbwzxox/xYHW2j14Uq9XwbfpwlUPQDwxUr2vF/uWbZ1iqQwXJtP4OqSjSkW65PDLzTNsgfYu70 pBE2KDHo0gH3lTSKMGOSnkNYtHEX7OxlIEBQb17dKO07NC579x2/xbFyO75Ux5qpUkpyTSmljyrQD /fRkkS88aFOwDiT60YGWeb40NRKm31aU4uq+jpnMSEhdxvz5tmWTrbRf88xcWrPvLeQSZxGgB3tLF 4RQBXBpY2w19Qdb1iF7crw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q687M-0004Ls-Pg; Mon, 05 Jun 2023 07:11:21 -0400 In-Reply-To: <46df52d2-5f3d-7807-c396-9838a219543e@vodafonemail.de> (message from Jens Schmidt on Sun, 4 Jun 2023 22:04:23 +0200) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:306645 Archived-At: > Date: Sun, 4 Jun 2023 22:04:23 +0200 > From: Jens Schmidt > > 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.