[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] scratch/el-mock 3aab4e3daf 29/64: Merge pull request #14 from p
From: |
Stefan Monnier |
Subject: |
[nongnu] scratch/el-mock 3aab4e3daf 29/64: Merge pull request #14 from phst/no-condition-case |
Date: |
Mon, 28 Aug 2023 23:01:40 -0400 (EDT) |
branch: scratch/el-mock
commit 3aab4e3daf87005e21f4ac2559a8546ba7795dcc
Merge: 5cb160b9bd 24337b85e8
Author: Johan Andersson <johan.rejeep@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #14 from phst/no-condition-case
Preserve ERT backtrace
---
el-mock.el | 9 ++++-----
test/el-mock-test.el | 17 +++++++++++++++++
2 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/el-mock.el b/el-mock.el
index 953bcde7d1..ada4e7dc8b 100644
--- a/el-mock.el
+++ b/el-mock.el
@@ -149,17 +149,16 @@ When you adapt Emacs Lisp Mock to a testing framework,
wrap test method around t
-stubbed-functions
-mocked-functions
(in-mocking t)
- any-error)
+ (any-error t))
;; (setplist 'mock-original-func nil)
;; (setplist 'mock-call-count nil)
(unwind-protect
- (condition-case e
+ (prog1
(funcall body-fn)
- (error (setq any-error e)))
+ (setq any-error nil))
(mapc #'stub/teardown -stubbed-functions)
(unwind-protect
- (if any-error
- (signal (car any-error) (cdr any-error))
+ (unless any-error
(mock-verify))
(mapc #'mock/teardown -mocked-functions)))))
diff --git a/test/el-mock-test.el b/test/el-mock-test.el
index 70c202e43b..b539be8b47 100644
--- a/test/el-mock-test.el
+++ b/test/el-mock-test.el
@@ -364,3 +364,20 @@
(mock (foo 1))
(foo)))
)
+
+(defun el-mock-test--signal ()
+ (error "Foo"))
+
+
+(ert-deftest preserve-stacktrace ()
+ "Test that mocking doesn’t mess with the backtrace recorded by
+‘ert-run-test’."
+ (let ((result (ert-run-test
+ (make-ert-test
+ :body (lambda ()
+ (with-mock (el-mock-test--signal)))))))
+ (should (ert-test-failed-p result))
+ (should (equal (ert-test-failed-condition result)
+ '(error "Foo")))
+ (should (equal (car-safe (ert-test-failed-backtrace result))
+ '(t el-mock-test--signal)))))
- [nongnu] scratch/el-mock 86444bfdfc 16/64: Add Travis config, (continued)
- [nongnu] scratch/el-mock 86444bfdfc 16/64: Add Travis config, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 47c04b9cae 19/64: Check for argument count mismatch., Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock d43353c2aa 21/64: Add How to use it section to readme, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 992db170a3 20/64: Merge branch 'bug5', Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 4c54b7247b 22/64: Merge branch 'patch-1', Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock a091520345 23/64: Update Travis config, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 5cb160b9bd 24/64: Don't use sudo on Travis, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 8cb59fc562 25/64: ©setup cask-package-toolset and update gitignore, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock a303e198a7 26/64: Setup coverage, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 8309faf0be 27/64: Add Continous Integration Badges, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 3aab4e3daf 29/64: Merge pull request #14 from phst/no-condition-case,
Stefan Monnier <=
- [nongnu] scratch/el-mock 034c7e5fca 30/64: Run tests on Travis in Emacs 25.1, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 280e988956 33/64: Add more documentation to README.md, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 68992d4361 35/64: Merge pull request #16 from phst/cl-lib, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock e3cff9f127 32/64: Merge pull request #13 from phst/fix-tests, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 136e0550e5 34/64: Migrate from obsolete cl.el to cl-lib, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 9e4d092179 38/64: Merge pull request #19 from ardumont/master, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 84a743cfcb 40/64: Fix all compilation warnings, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock b3accacee4 42/64: el-mock doesn’t need cl.el any more, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 6443c2aef4 46/64: Also run tests under Emacs 25.2, Stefan Monnier, 2023/08/28
- [nongnu] scratch/el-mock 40a4e003e1 48/64: Add Github Actions, Stefan Monnier, 2023/08/28