aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorPhilipp Stephani2020-11-29 14:24:57 +0100
committerPhilipp Stephani2020-12-06 17:47:52 +0100
commit40e11743ca3803bdc2c6c612f35ab695efb3eb8b (patch)
tree85d9362c7e46106a3212716dff5f2cfd30ffdaba /test/src
parent87a9fc6dcd8e364c9ae27da27fee439dc41c2e25 (diff)
downloademacs-40e11743ca3803bdc2c6c612f35ab695efb3eb8b.tar.gz
emacs-40e11743ca3803bdc2c6c612f35ab695efb3eb8b.zip
Print a backtrace on unhandled errors in batch mode (Bug#44942).
* src/eval.c (signal_or_quit): Print a backtrace in batch mode if no error handler was found. * test/src/eval-tests.el (eval-tests/backtrace-in-batch-mode) (eval-tests/backtrace-in-batch-mode/demoted-errors): New unit tests. * etc/NEWS: Document change.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/eval-tests.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el
index 074f5be1ef9..4125573dc6a 100644
--- a/test/src/eval-tests.el
+++ b/test/src/eval-tests.el
@@ -27,6 +27,7 @@
27 27
28(require 'ert) 28(require 'ert)
29(eval-when-compile (require 'cl-lib)) 29(eval-when-compile (require 'cl-lib))
30(require 'subr-x)
30 31
31(ert-deftest eval-tests--bug24673 () 32(ert-deftest eval-tests--bug24673 ()
32 "Check that Bug#24673 has been fixed." 33 "Check that Bug#24673 has been fixed."
@@ -176,4 +177,36 @@ in Common Lisp). Instead, make sure substitution in backquote
176expressions works for identifiers starting with period." 177expressions works for identifiers starting with period."
177 (should (equal (let ((.x 'identity)) (eval `(,.x 'ok))) 'ok))) 178 (should (equal (let ((.x 'identity)) (eval `(,.x 'ok))) 'ok)))
178 179
180(ert-deftest eval-tests/backtrace-in-batch-mode ()
181 (let ((emacs (expand-file-name invocation-name invocation-directory)))
182 (skip-unless (file-executable-p emacs))
183 (with-temp-buffer
184 (let ((status (call-process emacs nil t nil
185 "--quick" "--batch"
186 (concat "--eval="
187 (prin1-to-string
188 '(progn
189 (defun foo () (error "Boo"))
190 (foo)))))))
191 (should (natnump status))
192 (should-not (eql status 0)))
193 (goto-char (point-min))
194 (ert-info ((concat "Process output:\n" (buffer-string)))
195 (search-forward " foo()")
196 (search-forward " normal-top-level()")))))
197
198(ert-deftest eval-tests/backtrace-in-batch-mode/demoted-errors ()
199 (let ((emacs (expand-file-name invocation-name invocation-directory)))
200 (skip-unless (file-executable-p emacs))
201 (with-temp-buffer
202 (should (eql 0 (call-process emacs nil t nil
203 "--quick" "--batch"
204 (concat "--eval="
205 (prin1-to-string
206 '(with-demoted-errors "Error: %S"
207 (error "Boo")))))))
208 (goto-char (point-min))
209 (should (equal (string-trim (buffer-string))
210 "Error: (error \"Boo\")")))))
211
179;;; eval-tests.el ends here 212;;; eval-tests.el ends here