Subject: 25.1; cl-assert always calls the default debugger on assertion failures

From: David Shepherd <[email-masked]>
Date: Sun, 23 Oct 2016 20:00:03 +0100

This causes problems with ert if you use cl-assert.

For example with the following saved in temp.el

    (require 'cl-macs)

    (ert-deftest cl-assert-failure ()
      (cl-assert (equal 1 2) "uh oh"))

and run with

    emacs -Q -batch -l ert -l temp.el -f ert-run-tests-batch-and-exit

(as recommended by the ert manual) the output is

    Running 1 tests (2016-10-23 19:48:21+0100)
    Debugger entered: ((cl-assertion-failed (equal 1 2) nil))
      cl--assertion-failed((equal 1 2))
      (or (equal 1 2) (cl--assertion-failed (quote (equal 1 2))))
      (progn (or (equal 1 2) (cl--assertion-failed (quote (equal 1 2)))) nil)

followed by a large backtrace. Whereas

    (ert-deftest normal-error-call ()
      (error "uh oh"))

gives the output

    Running 1 tests (2016-10-23 19:52:07+0100)
    Test normal-error-call backtrace:
      (lambda nil (error "uh oh"))()
      ert--run-test-internal([cl-struct-ert--test-execution-info [cl-struc
      ert-run-test([cl-struct-ert-test normal-error-call nil (lambda nil (
      ert-run-or-rerun-test([cl-struct-ert--stats t [[cl-struct-ert-test n
      ert-run-tests(t #[385 "\306\307\"\203G\211\211G\310U\203\211@\20
      ert-run-tests-batch(nil)
      ert-run-tests-batch-and-exit()
      command-line-1(("-l" "ert" "-l" "temp.el" "-f" "ert-run-tests-batch-
      command-line()
      normal-top-level()
    Test normal-error-call condition:
        (error "uh oh")
       FAILED  1/1  normal-error-call

    Ran 1 tests, 0 results as expected, 1 unexpected (2016-10-23 19:52:07+0100)

    1 unexpected results:
   FAILED  normal-error-call

Older versions of emacs gave something like the second output even when
cl-assert was used.

This doesn't seem to be an issue if ert tests are run interactively, I'm
not sure why.

Removing the lines

    (if debug-on-error
       (apply debugger `(cl-assertion-failed ,form ,string ,@sargs))

from cl--assertion-failed seems to solve the problem, but I don't know
if that would break other things.

In GNU Emacs 25.1.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2016-10-23 built on david-entroware
Repository revision: f0eb70d8935be90f7c03e187c12d9b60e7214cc6
Windowing system distributor 'The X.Org Foundation', version 11.0.11803000
System Description:    Ubuntu 16.04.1 LTS

Configured using:
 'configure --with-x-toolkit=lucid 'CFLAGS=-O3 -march=native''

Configured features:
XAW3D XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF
GSETTINGS NOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF
XFT ZLIB TOOLKIT_SCROLL_BARS LUCID X11

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

Major mode: Emacs-Lisp

Minor modes in effect:
  electric-pair-mode: t
  editorconfig-mode: t
  highlight-symbol-mode: t
  suppress-multiline-string-indent-mode: ds/line-in-string-block?
  nameless-mode: t
  rainbow-delimiters-mode: t
  which-key-mode: t
  global-discover-mode: t
  discover-mode: t
  aggressive-fill-paragraph-mode: t
  ws-butler-global-mode: t
  ws-butler-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  hl-sexp-mode: t
  global-diff-hl-mode: t
  diff-hl-mode: t
  savehist-mode: t
  helm-mode: t
  async-bytecomp-package-mode: t
  projectile-global-mode: t
  projectile-mode: t
  flycheck-mode: t
  global-company-mode: t
  company-mode: t
  diff-auto-refine-mode: t
  global-git-commit-mode: t
  recentf-mode: t
  shell-dirtrack-mode: t
  frames-only-mode: t
  super-save-mode: t
  evil-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  evil-local-mode: t
  global-subword-mode: t
  subword-mode: t
  global-anzu-mode: t
  anzu-mode: t
  save-place-mode: t
  global-auto-revert-mode: t
  whitespace-mode: t
  global-linum-mode: t
  linum-mode: t
  global-page-break-lines-mode: t
  page-break-lines-mode: t
  show-paren-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-layout-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  prettify-symbols-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  global-visual-line-mode: t
  visual-line-mode: t
  transient-mark-mode: t

Recent messages:
Saving file /home/david/code/espuds/test/espuds-test.el...
Wrote /home/david/code/espuds/test/espuds-test.el
(Cannot open load file: No such file or directory, f)
Mark set [2 times]
Saving file /home/david/code/espuds/test/test-helper.el...
Wrote /home/david/code/espuds/test/test-helper.el
Reverting buffer ‘espuds-test.el’.
Saving file /home/david/code/espuds/espuds.el...
Wrote /home/david/code/espuds/espuds.el

Load-path shadows:
~/.emacs.d/vc-packages/projectile/helm-projectile hides
/home/david/.emacs.d/elpa/helm-projectile-20151220.221/helm-projectile
/home/david/.emacs.d/elpa/helm-20160409.113/helm-multi-match hides
/home/david/.emacs.d/elpa/helm-core-20160407.2135/helm-multi-match
~/.emacs.d/vc-packages/projectile/projectile hides
/home/david/.emacs.d/elpa/projectile-20160210.905/projectile
/home/david/.emacs.d/elpa/seq-20150928.1218/seq hides
/usr/local/share/emacs/25.1/lisp/emacs-lisp/seq

Features:
(shadow sort mail-extr emacsbug sendmail two-column helm-ring ansi
espuds jka-compr expand-region text-mode-expansions cc-mode-expansions
the-org-mode-expansions python-el-fgallina-expansions js-mode-expansions
html-mode-expansions feature-mode-expansions css-mode-expansions
clojure-mode-expansions er-basic-expansions expand-region-core
expand-region-custom misearch multi-isearch image-file helm-command
eieio-opt speedbar sb-image ezimage dframe helm-elisp helm-eval
editorconfig-core editorconfig-core-handle editorconfig-fnmatch winner
elec-pair company-yasnippet hamburger-menu tmm ivy delsel editorconfig
emerge fill-function-arguments highlight-symbol scratch ag vc-svn
find-dired crux flycheck-cask smooth-scrolling nameless lisp-mnt
rainbow-delimiters multiple-cursors mc-hide-unmatched-lines-mode
mc-separate-operations rectangular-region-mode mc-mark-pop mc-mark-more
mc-cycle-cursors mc-edit-lines multiple-cursors-core helm-dash lex-mode
feature-mode cucumber-mode yaml-mode replace-pairs electric-operator ess
ess-inf ess-mode ess-noweb-mode ess-utils ess-custom ess-compat
which-key discover makey aggressive-fill-paragraph ws-butler
imenu-anywhere avy deft yasnippet list-register goto-last-change
markdown-mode hl-sexp names-dev diff-hl face-remap vc-hg vc-git vc-dir
vc vc-dispatcher savehist ds/toggle-electricity names evil-matchit
evil-surround smartparens key-chord helm-mode helm-config helm-easymenu
async-bytecomp async helm-projectile flx helm-files image-dired
dired-aux helm-buffers helm-elscreen helm-tags helm-bookmark
helm-adaptive helm-info bookmark helm-locate helm-grep helm-regexp
helm-plugin helm-external helm-net xml url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap helm-utils helm-help helm-types helm helm-source eieio-compat
helm-multi-match helm-lib cmake-mode projectile ibuf-macs ibuf-ext
ibuffer typescript-mode cider cider-debug cider-browse-ns
cider-inspector cider-mode cider-interaction arc-mode archive-mode
cider-repl cider-resolve cider-test cider-overlays cider-stacktrace
cider-doc org-table cider-grimoire cider-popup cider-eldoc cider-client
cider-common cider-util clojure-mode nrepl-client queue nrepl-dict
cider-compat sh-script executable css-mode smie sqlup-mode sql view
ds-js json-mode json-reformat json-snatcher grep align js sgml-mode
imenu javadoc-lookup evil-args company-anaconda anaconda-mode f json-rpc
python matlab gud tempo ds/scheme scheme reftex reftex-vars
reftex-global modern-cpp-font-lock flycheck json map compile cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs skeleton smart-mode-line-dark-theme smart-mode-line-light-theme
smart-mode-line rich-minority company-oddmuse company-keywords
company-etags company-gtags company-dabbrev-code company-dabbrev
company-files company-capf company-cmake company-xcode company-clang
company-semantic company-eclim company-template company-css company-nxml
company-bbdb company magit-blame magit-stash magit-bisect magit-remote
magit-commit epa magit-sequence magit dired-x magit-log magit-apply
magit-wip magit-diff smerge-mode diff-mode magit-core magit-process
magit-popup magit-mode magit-git crm magit-section magit-utils ido
git-commit recentf tree-widget log-edit message rfc822 mml mml-sec epg
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log
with-editor warnings term disp-table ehelp esh-var esh-io esh-cmd
esh-opt esh-ext esh-proc esh-arg esh-groups eshell esh-module esh-mode
esh-util dired tramp-sh tramp tramp-compat tramp-loaddefs trampver shell
server frames-only-mode ediff-wind ediff-help ediff-init org-agenda org
org-macro org-footnote org-pcomplete pcomplete org-list org-faces
org-entities noutline outline org-version ob-emacs-lisp ob ob-tangle
ob-ref ob-lob ob-table ob-exp org-src ob-keys ob-comint comint
ansi-color ob-core ob-eval org-compat org-macs org-loaddefs format-spec
cal-menu calendar cal-loaddefs super-save evil evil-integration
undo-tree diff evil-maps evil-commands ffap url-parse auth-source
gnus-util mm-util help-fns mail-prsvr password-cache url-vars
evil-command-window evil-types evil-search evil-ex evil-macros
evil-repeat evil-states evil-core evil-common windmove rect
evil-digraphs evil-vars cap-words superword subword anzu thingatpt
saveplace autorevert filenotify whitespace linum page-break-lines
browse-url etags xref project eieio aggressive-indent shepherd-theme
time-date paren s ucs-normalize dash validate cus-edit cus-start
cus-load wid-edit paradox paradox-menu paradox-commit-list derived hydra
ring lv paradox-execute let-alist paradox-github paradox-core spinner
subr-x package-utils epl rx cl-seq use-package diminish cl bind-key
easy-mmode ert pp find-func ewoc debug finder-inf tex-site
go-mode-autoloads eieio-core cl-macs advice info package epg-config seq
byte-opt gv bytecomp byte-compile cl-extra help-mode cconv hi-lock
edebug easymenu edmacro kmacro cl-loaddefs pcase cl-lib mule-util
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame 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 charscript case-table epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote dbusbind inotify dynamic-setting
system-font-setting font-render-setting x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 1651645 597548)
 (symbols 48 70565 14)
 (miscs 40 3875 4877)
 (strings 32 200962 89787)
 (string-bytes 1 6503680)
 (vectors 16 130612)
 (vector-slots 8 3417816 168105)
 (floats 8 11594 2168)
 (intervals 56 92902 10298)
 (buffers 976 497)
 (heap 1024 120587 60830))