Subject: bug#28333: 26.0.50; Backtrace not printed when ERT test fails

From: Noam Postavsky <[email-masked]>
Date: Sat, 2 Sep 2017 17:28:51 -0400

tag 28333 confirmed
quit

On Sat, Sep 2, 2017 at 3:20 PM, Gemini Lasswell <[email-masked]> wrote:
> ERT used to print a backtrace for every failed test, but recently that
> stopped happening. I git bisected and found that the commit which
> introduced the problem is ead545824e, "Improve ert backtrace
> recording".

Hah, ironic isn't it. The problem is this code here:

              ;; Grab the frames starting from `signal', frames below
              ;; that are all from the debugger.
              (backtrace (backtrace-frames 'signal))

When the error comes from division by 0, there is `signal' frame at
all, hence we store `nil' as the backtrace. Maybe this could be fixed
with something equivalent to the following?

--- i/lisp/emacs-lisp/ert.el
+++ w/lisp/emacs-lisp/ert.el
@@ -739,7 +739,8 @@ ert--run-test-debugger
               ;;
               ;; Grab the frames starting from `signal', frames below
               ;; that are all from the debugger.
-              (backtrace (backtrace-frames 'signal))
+              (backtrace (or (backtrace-frames 'signal)
+                             (cdr (backtrace-frames 'ert--run-test-debugger))))
               (infos (reverse ert--infos)))
          (setf (ert--test-execution-info-result info)
                (cl-ecase type