Subject: 28.0.50; ERT condition printing comes too late

From: Philipp <[email-masked]>
Date: Sun, 01 Aug 2021 14:02:46 +0200

$ emacs -Q -batch -l ert -eval '(ert-deftest f () (with-temp-buffer (insert "foo") (should (equal (point-min-marker) (point-max-marker)))))' -f ert-run-tests-batch-and-exit
Running 1 tests (2021-08-01 13:59:16+0200, selector ‘t’)
Test f backtrace:
  signal(ert-test-failed (((should (equal (point-min-marker) (point-ma
  ert-fail(((should (equal (point-min-marker) (point-max-marker))) :fo
  (if (unwind-protect (setq value-2 (apply fn-0 args-1)) (setq form-de
  (let (form-description-4) (if (unwind-protect (setq value-2 (apply f
  (let ((value-2 'ert-form-evaluation-aborted-3)) (let (form-descripti
  (let* ((fn-0 #'equal) (args-1 (condition-case err (let ((signal-hook
  (progn (insert "foo") (let* ((fn-0 #'equal) (args-1 (condition-case 
  (unwind-protect (progn (insert "foo") (let* ((fn-0 #'equal) (args-1 
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
  (let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
  (closure (t) nil (let ((temp-buffer (generate-new-buffer " *temp*" t
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name f :documentation nil :body (closure (
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests [#s(ert-test 
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("-l" "ert" "-eval" "(ert-deftest f () (with-temp-buf
  command-line()
  normal-top-level()
Test f condition:
    (ert-test-failed
     ((should
       (equal
	(point-min-marker)
	(point-max-marker)))
      :form
      (equal #<marker in no buffer> #<marker in no buffer>)
      :value nil :explanation
      (different-atoms #<marker in no buffer> #<marker in no buffer>)))
   FAILED  1/1  f (0.000374 sec)

Ran 1 tests, 0 results as expected, 1 unexpected (2021-08-01 13:59:17+0200, 0.856999 sec)

1 unexpected results:
   FAILED  f

Note the 'marker in no buffer' representation for the markers.

This behavior is understandable (the condition is printed after the
temporary buffer is gone), but makes debugging test failures a bit
harder (what was the actual marker, and why is it different?).  Similar
things happen for buffers that are killed before printing the test
results.  It would be great to print the condition (and backtrace?) into
a string right when the assertion fails, to improve the debugging output
in such cases.

In GNU Emacs 28.0.50 (build 20, aarch64-apple-darwin20.6.0, NS appkit-2022.60 Version 11.5.1 (Build 20G80))
 of 2021-08-01
Repository revision: 12af7ee46d47152a2c499e24970a6ab4a94aed61
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2022
System Description:  macOS 11.5.1

Configured using:
 'configure --with-modules --without-xml2 --without-pop --with-mailutils
 --enable-gcc-warnings=warn-only --enable-checking=all
 --enable-check-lisp-object-type 'CFLAGS=-ggdb3 -O0''

Configured features:
ACL GNUTLS JSON LCMS2 MODULES NOTIFY KQUEUE NS PDUMPER PNG THREADS
TOOLKIT_SCROLL_BARS ZLIB

Important settings:
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc dired dired-loaddefs rfc822
mml mml-sec epa epg epg-config gnus-util rmail rmail-loaddefs time-date
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils phst skeleton derived edmacro kmacro pcase ffap thingatpt url
url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json map url-vars mailcap rx
gnutls puny dbus xml subr-x seq byte-opt gv bytecomp byte-compile cconv
compile text-property-search comint ansi-color ring cl-loaddefs cl-lib
iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/ns-win ns-win ucs-normalize mule-util
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads kqueue cocoa ns lcms2
multi-tty make-network-process emacs)

Memory information:
((conses 16 70384 4979)
 (symbols 48 8504 1)
 (strings 32 24020 1276)
 (string-bytes 1 783486)
 (vectors 16 16301)
 (vector-slots 8 208282 12573)
 (floats 8 26 26)
 (intervals 56 219 0)
 (buffers 992 10))