]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid excessively large backtraces in ert-tests (bug#71988)
authorPip Cet <pipcet@protonmail.com>
Mon, 8 Jul 2024 19:50:16 +0000 (19:50 +0000)
committerEshel Yaron <me@eshelyaron.com>
Sun, 22 Jun 2025 08:08:46 +0000 (10:08 +0200)
* test/lisp/emacs-lisp/ert-tests.el (ert-test-run-tests-batch-expensive):
Temporarily make `cl-print-object' not print out vectors while running
the test.

(cherry picked from commit 0264ab11181b1d49d8f07186599396d503f24d1f)

test/lisp/emacs-lisp/ert-tests.el

index 7ecffa79e776bb645d13bcf01c04dfcbe8185683..03a62f74313ebfe0779cbd1cad722c8860b06144 100644 (file)
@@ -595,9 +595,14 @@ This macro is used to test if macroexpansion in `should' works."
                         :body (lambda () (should (equal complex-list 1))))))
     (let ((ert-debug-on-error nil)
           messages)
-      (cl-letf* (((symbol-function 'message)
+      (cl-letf* (((symbol-function 'cl-print-object)
+                  (symbol-function 'cl-print-object))
+                 ((symbol-function 'message)
                   (lambda (format-string &rest args)
                     (push (apply #'format format-string args) messages))))
+        ;; don't print the ert--stats-tests vector, which would run out of
+        ;; memory if previous tests have failed.
+        (cl-defmethod cl-print-object ((_object vector) _stream))
         (save-window-excursion
           (let ((case-fold-search nil)
                 (ert-batch-backtrace-right-margin nil)
@@ -612,7 +617,9 @@ This macro is used to test if macroexpansion in `should' works."
                 do
                 (unless found-frame
                   (setq found-frame (cl-search frame msg :test 'equal))))
-        (should found-frame)))))
+        (should found-frame))))
+  ;; ensure our temporary binding was undone.
+  (should (equal (cl-prin1-to-string [a]) "[a]")))
 
 (ert-deftest ert-test-special-operator-p ()
   (should (ert--special-operator-p 'if))