[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.
- [nongnu] elpa/buttercup updated (dfbef21772 -> 8408579758), ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 45d53515da 02/16: Stop adding frames to backtrace once a buttercup wrap func is found,
ELPA Syncer <=
- [nongnu] elpa/buttercup 0444816a60 07/16: tests: Refactor test that no backtraces are collected for skipped specs, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup ee000fabd1 04/16: tests: Cleanup and comments, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 0552fe4d5b 12/16: Add :to-be-close-to docstring, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup c8f34ae3ed 05/16: Limit backtraces for spec exceptions outside expect, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup add32f8cbf 08/16: Collect stacktraces for errors in matchers, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup be72aa872c 06/16: tests: Verify that backtraces are not collected for passed specs, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 8408579758 16/16: Rewrite buttercup-expect with pcase, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 925af155be 15/16: tests: Add backtrace tests for function matchers, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup df7f98e110 03/16: Do not collect backtraces for failed specs, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 4b1682ec98 01/16: Use the base argument of backtrace-frame, ELPA Syncer, 2024/09/04