[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup df7f98e110 03/16: Do not collect backtraces for
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup df7f98e110 03/16: Do not collect backtraces for failed specs |
Date: |
Wed, 4 Sep 2024 18:59:23 -0400 (EDT) |
branch: elpa/buttercup
commit df7f98e1102ee28f1f428caf7edb3576e1ddc0b3
Author: Ola Nilsson <ola.nilsson@gmail.com>
Commit: Ola Nilsson <ola.nilsson@gmail.com>
Do not collect backtraces for failed specs
There is no reason to collect backtraces for expect form where the
matcher detects a mismatch. It's all buttercup infrastructure at that
point.
---
buttercup.el | 6 +++---
tests/test-buttercup.el | 37 +++++++++++++++++++++----------------
2 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index d9c5a99d93..7f30f2c38d 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -2107,8 +2107,9 @@ ARGS according to `debugger'."
;; args is (error (signal . data) ....) where the tail
;; may be empty
(cl-destructuring-bind (signal-type . data) (cl-second args)
- (unless (eq signal-type 'buttercup-pending)
- (buttercup--backtrace))))))
+ (cl-case signal-type
+ ((buttercup-pending buttercup-failed))
+ (otherwise (buttercup--backtrace)))))))
(defalias 'buttercup--mark-stackframe #'ignore
"Marker to find where the backtrace start.")
@@ -2129,7 +2130,6 @@ ARGS according to `debugger'."
;; 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?
diff --git a/tests/test-buttercup.el b/tests/test-buttercup.el
index 31a9fbbd4f..e2ab163725 100644
--- a/tests/test-buttercup.el
+++ b/tests/test-buttercup.el
@@ -1969,22 +1969,27 @@ before it's processed by other functions."
(fmakunbound 'bc-bt-foo)
(fmakunbound 'bc-bt-bar)
(fmakunbound 'bc-bt-baz))
- (it "should be printed for each failed spec"
- (with-local-buttercup
- :reporter #'backtrace-reporter
- (describe "suite"
- (it "expect 2" (expect (+ 1 2) :to-equal 2))
- (it "expect nil" (expect nil)))
- (buttercup-run :noerror))
- (expect (buttercup-output) :to-match
- (rx string-start
- (= 2 (seq (= 40 ?=) "\n"
- "suite expect " (or "2" "nil") "\n"
- "\n"
- "Traceback (most recent call last):\n"
- (* (seq " " (+ not-newline) "\n"))
- (or "FAILED" "error") ": " (+ not-newline) "\n\n"))
- string-end)))
+ (it "should not be collected or printed for failed specs"
+ (let (test-suites)
+ (spy-on 'buttercup--backtrace :and-call-through)
+ (with-local-buttercup
+ :reporter #'backtrace-reporter
+ (describe "suite"
+ (it "expect 2" (expect (+ 1 2) :to-equal 2))
+ (it "expect nil" (expect nil)))
+ (buttercup-run :noerror)
+ (setq test-suites buttercup-suites))
+ (expect 'buttercup--backtrace :not :to-have-been-called)
+ ;; Checking both if buttercup--backtrace have been called and
+ ;; the failure-stack value might be overkill
+ (expect (cl-every #'null
+ (mapcar #'buttercup-spec-failure-stack
+ (buttercup-suite-children (car test-suites)))))
+ (expect (buttercup-output) :to-match
+ (rx string-start
+ (= 40 ?=) "\nsuite expect " "2" "\nFAILED: " (+
not-newline) "\n\n"
+ (= 40 ?=) "\nsuite expect " "nil" "\nFAILED: " (+
not-newline) "\n\n"
+ string-end))))
(describe "with style"
:var (test-suites long-string)
;; Set up tests to test
- [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, 2024/09/04
- [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 <=
- [nongnu] elpa/buttercup 4b1682ec98 01/16: Use the base argument of backtrace-frame, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup a1d0d73999 11/16: Improve docstring of buttercup-define-matcher, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 789570cf7d 10/16: Merge pull request #249 from snogge/fix-247, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup f577efc524 09/16: Remove remaining uses of `buttercup--mark-stackframe', ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 9bb00a269d 13/16: Improve the docstring of the expect macro, ELPA Syncer, 2024/09/04
- [nongnu] elpa/buttercup 19e1a86626 14/16: Clarify that buttercup--wrap-expr is only meant for expect, ELPA Syncer, 2024/09/04