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

From: Noam Postavsky <[email-masked]>
Date: Sat, 23 Sep 2017 11:48:38 -0400

tags 28333 + patch
quit

Gemini Lasswell <[email-masked]> writes:

> Noam Postavsky writes:
>
>> Maybe this could be fixed with something equivalent to the following?
>
> I've been running this for a few days and haven't seen any more missing
> backtraces.

Actually, I think it's giving one extra frame.  Using `debugger' as the
BASE seems to cover both cases nicely:

>From 847ed811022f4d4fe43f2d5e14660f93538423dd Mon Sep 17 00:00:00 2001
From: Noam Postavsky <[email-masked]>
Date: Sat, 23 Sep 2017 11:40:14 -0400
Subject: [PATCH] Fix ert backtrace saving for non-`signal'ed errors
 (Bug#28333)

* lisp/emacs-lisp/ert.el (ert--run-test-debugger): Take the frames
above the `debugger' frame, rather than assuming there will be a
`signal' frame.
---
 lisp/emacs-lisp/ert.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index d4276221ba..83acbacb88 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -742,9 +742,8 @@ ert--run-test-debugger
               ;; backtrace ready for printing is important for batch
               ;; use.
               ;;
-              ;; Grab the frames starting from `signal', frames below
-              ;; that are all from the debugger.
-              (backtrace (backtrace-frames 'signal))
+              ;; Grab the frames above the debugger.
+              (backtrace (cdr (backtrace-frames debugger)))
               (infos (reverse ert--infos)))
          (setf (ert--test-execution-info-result info)
                (cl-ecase type
-- 
2.11.0