emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/buttercup 45d53515da 02/16: Stop adding frames to backtrac


From: ELPA Syncer
Subject: [nongnu] elpa/buttercup 45d53515da 02/16: Stop adding frames to backtrace once a buttercup wrap func is found
Date: Wed, 4 Sep 2024 18:59:23 -0400 (EDT)

branch: elpa/buttercup
commit 45d53515da379ddb621b7fc14d1860604b149d54
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>

    Stop adding frames to backtrace once a buttercup wrap func is found
    
    This will limit the backtrace for errors signalled from within a
    wrapped expression.  There is still a set of other conditions that
    have to be handled in buttercup--backtrace.
---
 buttercup.el | 40 +++++++++++++++-------------------------
 1 file changed, 15 insertions(+), 25 deletions(-)

diff --git a/buttercup.el b/buttercup.el
index 7e562aebf4..d9c5a99d93 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -89,7 +89,6 @@ forms:
 and the return value will be EXPR, unevaluated. The quoted EXPR
 is useful if EXPR is a macro call, in which case the `quote'
 ensures access to the un-expanded form."
-  (cl-assert (functionp fun) t "Expected FUN to be a function")
   (if (buttercup--thunk-p fun)
       (buttercup--thunk--expr fun)
   (pcase fun
@@ -2122,30 +2121,21 @@ ARGS according to `debugger'."
                   (backtrace-frame n #'buttercup--debugger))
            (frame-list nil))
       ((not frame) frame-list)
-    (push frame frame-list)
-      ;; keep frames until one of the known functions are found, after
-      ;; this is just the buttercup framework and not interesting for
-      ;; users (incorrect for testing buttercup). Some frames before the
-      ;; function also have to be discarded
-      (cl-labels ((tree-find (key tree)
-                             (cl-block tree-find
-                               (while (consp tree)
-                                 (let ((elem (pop tree)))
-                                   (when (or (and (consp elem)
-                                                  (tree-find key elem))
-                                             (and (buttercup--thunk-p elem)
-                                                  (tree-find key (aref elem 
1)))
-                                             (eql key elem))
-                                     (cl-return-from tree-find t))))
-                               (cl-return-from tree-find
-                                 (and tree (eql tree key))))))
-        ;; TODO: Only check the cadr of frame, that is where the function is.
-        ;;       The buttercup--mark-stackframe should only be in wrapped 
expressions,
-        ;;       optimize by checking if it is a wrapped expression?
-        ;;       Will we even need the marker if we can check that?
-        (when (tree-find 'buttercup--mark-stackframe frame)
-          (pop frame-list)
-          (cl-return frame-list)))))
+    ;; Keep frames until one if the end conditions is met. After
+    ;; this is just the buttercup framework and not interesting for
+    ;; users - except for testing buttercup.
+    (when (or
+           ;; When the error occurs in the calling of one of the
+           ;; wrapped expressions of an expect.
+           (buttercup--wrapper-fun-p (cadr frame))
+           ;; TODO: error in `it' but outside `expect'
+           ;; TODO: matchers that do not match should not collect backtrace
+           ;; TODO: What about an error in a matcher?
+           ;; TODO: What about :to-throw?
+           ;; TODO: What about signals in before and after blocks?
+           )
+      (cl-return frame-list))
+    (push frame frame-list)))
 
 (defun buttercup--format-stack-frame (frame &optional style)
   "Format stack FRAME according to STYLE.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]