[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/buttercup 25462dd 223/340: Record calls to spied-on functi
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/buttercup 25462dd 223/340: Record calls to spied-on functions that throw errors |
Date: |
Thu, 16 Dec 2021 14:59:39 -0500 (EST) |
branch: elpa/buttercup
commit 25462ddfdf430308c5fa9219d2f16a626e2913cf
Author: Ryan C. Thompson <rct@thompsonclan.org>
Commit: Ryan C. Thompson <rct@thompsonclan.org>
Record calls to spied-on functions that throw errors
This addes another slot to the spy-context struct that is used to
record the signal thrown by the spied function, if any.
Fixes #139.
---
buttercup.el | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/buttercup.el b/buttercup.el
index ba5c203..fdddc7e 100644
--- a/buttercup.el
+++ b/buttercup.el
@@ -1025,6 +1025,7 @@ DESCRIPTION has the same meaning as in `xit'. FUNCTION is
ignored."
(cl-defstruct spy-context
args
return-value
+ thrown-signal
current-buffer)
(defun spy-on (symbol &optional keyword arg)
@@ -1106,15 +1107,35 @@ responsibility to ensure ARG is a command."
(defun buttercup--make-spy (fun)
"Create a new spy function wrapping FUN and tracking calls to itself."
(let (this-spy-function)
- (setq this-spy-function
- (lambda (&rest args)
- (let ((return-value (apply fun args)))
+ (setq
+ this-spy-function
+ (lambda (&rest args)
+ (let ((returned nil)
+ (return-value nil))
+ (condition-case err
+ (progn
+ (setq return-value (apply fun args)
+ returned t)
+ (buttercup--spy-calls-add
+ this-spy-function
+ (make-spy-context :args args
+ :return-value return-value
+ :thrown-signal nil
+ :current-buffer (current-buffer)))
+ return-value)
+ (error
+ ;; If returned is non-nil, then the error we caught
+ ;; didn't come from FUN, so we shouldn't record it.
+ (unless returned
(buttercup--spy-calls-add
this-spy-function
(make-spy-context :args args
- :return-value return-value
- :current-buffer (current-buffer)))
- return-value)))
+ :return-value nil
+ :thrown-signal err
+ :current-buffer (current-buffer))))
+ ;; Regardless, we only caught this error order to record
+ ;; it, so we need to re-throw it.
+ (signal (car err) (cdr err)))))))
;; Add the interactive form from `fun', if any
(when (interactive-form fun)
(setq this-spy-function
- [nongnu] elpa/buttercup 5821cd0 184/340: Merge pull request #131 from snogge/markdown, (continued)
- [nongnu] elpa/buttercup 5821cd0 184/340: Merge pull request #131 from snogge/markdown, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup a394fea 191/340: Bump version: 1.13 → 1.14, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 7cea4c6 192/340: Test buttercup-run, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup b410c78 193/340: Separate return code from reporter, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9b230dc 202/340: Fix the "should print the elapsed time for all specs" test, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9d172a7 205/340: Merge pull request #145 from snogge/test-fixes, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c100fad 210/340: Implement buttercup-suppress-warning-capture, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup c994aea 212/340: Add LICENSE file., ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup d9ce620 213/340: Merge branch 'license-file' into master, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 49f01fc 219/340: Merge branch 'master' into test-emacs-26.3, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 25462dd 223/340: Record calls to spied-on functions that throw errors,
ELPA Syncer <=
- [nongnu] elpa/buttercup bf48137 224/340: Add some tests for error-call recording, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fc19598 225/340: Add examples for checking return value and thrown signal of a spy, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 6590360 226/340: Fix a few typos and other small errors, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 8a28489 230/340: Bump version: 1.18 → 1.19, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 0e40587 231/340: Tweak the spy-contexts to be more backward compatible, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 60028db 236/340: docs: Clarify the spy lifespan in writing-tests.md, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 9c4b473 237/340: test: Add missing apostrophe in spec title, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 90654ec 238/340: Update some docstrings, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup 178c795 242/340: README: Add '-L .' to test runner example, ELPA Syncer, 2021/12/16
- [nongnu] elpa/buttercup fc4276a 247/340: Make it possible to abort test run cleanly, ELPA Syncer, 2021/12/16