From 388e0c18f489fc7d4bee8278e21852eefa1dcf19 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Tue, 24 May 2022 14:06:38 +0200 Subject: Make the nativecomp test eln directory more reliably be removed * lisp/startup.el (startup-redirect-eln-cache, normal-top-level): Don't create the nativecomp directory here, because this led to brittle deletions of the directory -- there would be several instances of the directory left over after a test run. * lisp/emacs-lisp/ert.el (ert-run-tests-batch-and-exit): Create the nativecomp directory. --- lisp/emacs-lisp/ert.el | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'lisp/emacs-lisp/ert.el') diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 00da5c718c7..0451be272ab 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -1533,23 +1533,33 @@ Returns the stats object." "Like `ert-run-tests-batch', but exits Emacs when done. The exit status will be 0 if all test results were as expected, 1 -on unexpected results, or 2 if the tool detected an error outside +son unexpected results, or 2 if the tool detected an error outside of the tests (e.g. invalid SELECTOR or bug in the code that runs the tests)." (or noninteractive (user-error "This function is only for use in batch mode")) - ;; Better crash loudly than attempting to recover from undefined - ;; behavior. - (setq attempt-stack-overflow-recovery nil - attempt-orderly-shutdown-on-fatal-signal nil) - (unwind-protect - (let ((stats (ert-run-tests-batch selector))) - (kill-emacs (if (zerop (ert-stats-completed-unexpected stats)) 0 1))) + (let ((eln-dir (and (featurep 'native-compile) + (make-temp-file "test-nativecomp-cache-" t)))) + (when eln-dir + (startup-redirect-eln-cache eln-dir)) + ;; Better crash loudly than attempting to recover from undefined + ;; behavior. + (setq attempt-stack-overflow-recovery nil + attempt-orderly-shutdown-on-fatal-signal nil) (unwind-protect - (progn - (message "Error running tests") - (backtrace)) - (kill-emacs 2)))) + (let ((stats (ert-run-tests-batch selector))) + (when eln-dir + (ignore-errors + (delete-directory eln-dir t))) + (kill-emacs (if (zerop (ert-stats-completed-unexpected stats)) 0 1))) + (unwind-protect + (progn + (message "Error running tests") + (backtrace)) + (when eln-dir + (ignore-errors + (delete-directory eln-dir t))) + (kill-emacs 2))))) (defvar ert-load-file-name nil "The name of the loaded ERT test file, a string. -- cgit v1.2.3 From 7c4cad323090acd09604c511a31a35c99452f5ce Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Wed, 25 May 2022 03:24:52 +0200 Subject: Fix ert-run-tests-batch-and-exit doc string typo * lisp/emacs-lisp/ert.el (ert-run-tests-batch-and-exit): Fix doc string typo. --- lisp/emacs-lisp/ert.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/emacs-lisp/ert.el') diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 0451be272ab..82722add42a 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -1533,7 +1533,7 @@ Returns the stats object." "Like `ert-run-tests-batch', but exits Emacs when done. The exit status will be 0 if all test results were as expected, 1 -son unexpected results, or 2 if the tool detected an error outside +on unexpected results, or 2 if the tool detected an error outside of the tests (e.g. invalid SELECTOR or bug in the code that runs the tests)." (or noninteractive -- cgit v1.2.3 From ef218ac936c3ffe219b57e37e684fd8400389c38 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Wed, 6 Jul 2022 12:31:01 +0200 Subject: ; * lisp/emacs-lisp/ert.el: Remove installation instructions. --- lisp/emacs-lisp/ert.el | 2 -- 1 file changed, 2 deletions(-) (limited to 'lisp/emacs-lisp/ert.el') diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 82722add42a..262d85f9b43 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -47,8 +47,6 @@ ;; environment (like availability of features, external binaries, etc). ;; ;; See ERT's info manual as well as the docstrings for more details. -;; To compile the manual, run `makeinfo ert.texinfo' in the ERT -;; directory, then C-u M-x info ert.info in Emacs to view it. ;; ;; To see some examples of tests written in ERT, see its self-tests in ;; ert-tests.el. Some of these are tricky due to the bootstrapping -- cgit v1.2.3 From 139eb1f845d1ec3e2a26aec5d7fafbcdcbaa5f07 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 7 Jul 2022 23:19:03 +0200 Subject: * lisp/emacs-lisp/ert.el (Commentary): Refer to the Info manual. --- lisp/emacs-lisp/ert.el | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lisp/emacs-lisp/ert.el') diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 262d85f9b43..21bee4c6d8b 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -1,6 +1,6 @@ ;;; ert.el --- Emacs Lisp Regression Testing -*- lexical-binding: t -*- -;; Copyright (C) 2007-2008, 2010-2022 Free Software Foundation, Inc. +;; Copyright (C) 2007-2022 Free Software Foundation, Inc. ;; Author: Christian Ohler ;; Keywords: lisp, tools @@ -46,12 +46,10 @@ ;; processing further, this is useful for checking the test ;; environment (like availability of features, external binaries, etc). ;; -;; See ERT's info manual as well as the docstrings for more details. -;; -;; To see some examples of tests written in ERT, see its self-tests in -;; ert-tests.el. Some of these are tricky due to the bootstrapping -;; problem of writing tests for a testing tool, others test simple -;; functions and are straightforward. +;; See ERT's Info manual `(ert) Top' as well as the docstrings for +;; more details. To see some examples of tests written in ERT, see +;; the test suite distributed with the Emacs source distribution (in +;; the "test" directory). ;;; Code: -- cgit v1.2.3 From ecb2eccad56518992426500dd8119024ea8288a8 Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Sat, 9 Jul 2022 10:54:01 +0200 Subject: Improve ert-test-erts-file documentation * lisp/emacs-lisp/ert.el (ert-test-erts-file): Improve docstring. * doc/misc/ert.texi (erts files): Fix typo. --- doc/misc/ert.texi | 2 +- lisp/emacs-lisp/ert.el | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'lisp/emacs-lisp/ert.el') diff --git a/doc/misc/ert.texi b/doc/misc/ert.texi index 4dccd8edcf0..1b7f38daadf 100644 --- a/doc/misc/ert.texi +++ b/doc/misc/ert.texi @@ -822,7 +822,7 @@ that's pretty difficult to read and write, especially when the text in question is multi-line. So ert provides a function called @code{ert-test-erts-file} that takes -two parameters: The name of a specially-formatted @dfn{erts} file, and +two parameters: the name of a specially-formatted @dfn{erts} file, and (optionally) a function that performs the transform. @findex erts-mode diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el index 21bee4c6d8b..49b54c2d00f 100644 --- a/lisp/emacs-lisp/ert.el +++ b/lisp/emacs-lisp/ert.el @@ -2880,8 +2880,14 @@ To be used in the ERT results buffer." nil) (defun ert-test-erts-file (file &optional transform) - "Parse FILE as a file containing before/after parts. -TRANSFORM will be called to get from before to after." + "Parse FILE as a file containing before/after parts (an erts file). + +This function puts the \"before\" section of an .erts file into a +temporary buffer, calls the TRANSFORM function, and then compares +the result with the \"after\" section. + +See Info node `(ert) erts files' for more information on how to +write erts files." (with-temp-buffer (insert-file-contents file) (let ((gen-specs (list (cons 'dummy t) -- cgit v1.2.3