Subject: bug#58941: 28.1.90; ERT tests and backtraces

From: Ihor Radchenko <[email-masked]>
Date: Tue, 01 Nov 2022 06:04:49 +0000

Hi,

Currently, when one runs tests and error is thrown inside `should'
forms, no meaningful backtrace is being produced.

This is because `should' wraps the code into `condition-case' that
truncates the backtraces.

Would it be possible to allow more informative backtraces in failed ERT
tests?

An example of useless backtrace can be found in
https://builds.sr.ht/~bzg/job/872738:

Test test-ob-scheme/unspecified backtrace:
  signal(void-function (p))
  apply(signal (void-function (p)))
  (setq value-1494 (apply fn-1492 args-1493))
  (unwind-protect (setq value-1494 (apply fn-1492 args-1493)) (setq fo
  (if (unwind-protect (setq value-1494 (apply fn-1492 args-1493)) (set
  (let (form-description-1496) (if (unwind-protect (setq value-1494 (a
  (let ((value-1494 (quote ert-form-evaluation-aborted-1495))) (let (f
  (let* ((fn-1492 (function equal)) (args-1493 (condition-case err (le
  (closure (t) nil (let* ((fn-1492 (function equal)) (args-1493 (condi
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name test-ob-scheme/unspecified :documenta
  ert-run-or-rerun-test(#s(ert--stats :selector "\\(org\\|ob\\|ox\\)" 
  ert-run-tests("\\(org\\|ob\\|ox\\)" #f(compiled-function (event-type
  ert-run-tests-batch("\\(org\\|ob\\|ox\\)")
  ert-run-tests-batch-and-exit("\\(org\\|ob\\|ox\\)")
  (let ((org-id-track-globally t) (org-test-selector (if org-test-sele
  org-test-run-batch-tests("\\(org\\|ob\\|ox\\)")
  eval((org-test-run-batch-tests org-test-select-re))
  command-line-1(("--load" "/home/build/.emacs.d/init.el" "--eval" "(s
  command-line()
  normal-top-level()
Test test-ob-scheme/unspecified condition:
    (void-function p)
   FAILED   236/1034  test-ob-scheme/unspecified

The real backtrace there is

  p(nil)
  geiser-repl-project-root()
  geiser-repl-buffer-name(guile)
  geiser-repl--to-repl-buffer(guile)
  geiser-repl--start-repl(guile nil)
  geiser(guile)
  org-babel-scheme-get-repl(guile nil)
  org-babel-scheme-execute-with-geiser("'(1 2 3)" nil guile nil)
  org-babel-execute:scheme("'(1 2 3)" ((:colname-names) (:rowname-name
  org-babel-execute-src-block(nil)
  org-babel-execute-src-block-maybe()
  org-babel-execute-maybe()

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>