summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/ert.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-05-24 14:06:38 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-05-24 14:06:38 +0200
commit388e0c18f489fc7d4bee8278e21852eefa1dcf19 (patch)
treebb8508ce394d3b3b7b915d84da977bf6979962ed /lisp/emacs-lisp/ert.el
parent533500522d8deb84e85e40427c0d71761d620f5a (diff)
downloademacs-388e0c18f489fc7d4bee8278e21852eefa1dcf19.tar.gz
emacs-388e0c18f489fc7d4bee8278e21852eefa1dcf19.tar.bz2
emacs-388e0c18f489fc7d4bee8278e21852eefa1dcf19.zip
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.
Diffstat (limited to 'lisp/emacs-lisp/ert.el')
-rw-r--r--lisp/emacs-lisp/ert.el34
1 files changed, 22 insertions, 12 deletions
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.