Subject: bug#25931: closed (Re: bug#25931: 25.1; ERT "show messages" error)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 02 Mar 2017 20:43:03 +0000

Your bug report

#25931: 25.1; ERT "show messages" error

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
25931: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=25931
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#25931: 25.1; ERT "show messages" error
From: Glenn Morris <[email-masked]>
To: [email-masked]
Date: Thu, 02 Mar 2017 15:42:36 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Version: 26.1

commit dacafa8
Date:   Thu Mar 2 15:40:15 2017 -0500

    Ert commands to error if no test at point (bug#25931)
    
    * lisp/emacs-lisp/ert.el (ert-results-mode-menu):
    Deactivate some items if no test at point.
    (ert--results-test-at-point-no-redefinition):
    Add option to signal an error rather than return nil.
    (ert-results-pop-to-backtrace-for-test-at-point)
    (ert-results-pop-to-messages-for-test-at-point)
    (ert-results-pop-to-should-forms-for-test-at-point)
    (ert-results-describe-test-at-point): Error if no test at point.

diff --git a/lisp/emacs-lisp/ert.el b/lisp/emacs-lisp/ert.el
index 785f4ac..cadd66c 100644
--- a/lisp/emacs-lisp/ert.el
+++ b/lisp/emacs-lisp/ert.el
@@ -2079,14 +2079,23 @@ and how to display message."
   '("ERT Results"
     ["Re-run all tests" ert-results-rerun-all-tests]
     "--"
-    ["Re-run test" ert-results-rerun-test-at-point]
-    ["Debug test" ert-results-rerun-test-at-point-debugging-errors]
-    ["Show test definition" ert-results-find-test-at-point-other-window]
+    ;; FIXME?  Why are there (at least) 3 different ways to decide if
+    ;; there is a test at point?
+    ["Re-run test" ert-results-rerun-test-at-point
+     :active (car (ert--results-test-at-point-allow-redefinition))]
+    ["Debug test" ert-results-rerun-test-at-point-debugging-errors
+     :active (car (ert--results-test-at-point-allow-redefinition))]
+    ["Show test definition" ert-results-find-test-at-point-other-window
+     :active (ert-test-at-point)]
     "--"
-    ["Show backtrace" ert-results-pop-to-backtrace-for-test-at-point]
-    ["Show messages" ert-results-pop-to-messages-for-test-at-point]
-    ["Show `should' forms" ert-results-pop-to-should-forms-for-test-at-point]
-    ["Describe test" ert-results-describe-test-at-point]
+    ["Show backtrace" ert-results-pop-to-backtrace-for-test-at-point
+     :active (ert--results-test-at-point-no-redefinition)]
+    ["Show messages" ert-results-pop-to-messages-for-test-at-point
+     :active (ert--results-test-at-point-no-redefinition)]
+    ["Show `should' forms" ert-results-pop-to-should-forms-for-test-at-point
+     :active (ert--results-test-at-point-no-redefinition)]
+    ["Describe test" ert-results-describe-test-at-point
+     :active (ert--results-test-at-point-no-redefinition)]
     "--"
     ["Delete test" ert-delete-test]
     "--"
@@ -2237,22 +2246,24 @@ To be used in the ERT results buffer."
         (and (ert-test-boundp sym)
              sym))))
 
-(defun ert--results-test-at-point-no-redefinition ()
+(defun ert--results-test-at-point-no-redefinition (&optional error)
   "Return the test at point, or nil.
-
+If optional argument ERROR is non-nil, signal an error rather than return nil.
 To be used in the ERT results buffer."
   (cl-assert (eql major-mode 'ert-results-mode))
-  (if (ert--results-test-node-or-null-at-point)
-      (let* ((node (ert--results-test-node-at-point))
-             (test (ert--ewoc-entry-test (ewoc-data node))))
-        test)
-    (let ((progress-bar-begin ert--results-progress-bar-button-begin))
-      (when (and (<= progress-bar-begin (point))
-                 (< (point) (button-end (button-at progress-bar-begin))))
-        (let* ((test-index (- (point) progress-bar-begin))
-               (test (aref (ert--stats-tests ert--results-stats)
+  (or
+   (if (ert--results-test-node-or-null-at-point)
+       (let* ((node (ert--results-test-node-at-point))
+              (test (ert--ewoc-entry-test (ewoc-data node))))
+         test)
+     (let ((progress-bar-begin ert--results-progress-bar-button-begin))
+       (when (and (<= progress-bar-begin (point))
+                  (< (point) (button-end (button-at progress-bar-begin))))
+         (let* ((test-index (- (point) progress-bar-begin))
+                (test (aref (ert--stats-tests ert--results-stats)
                            test-index)))
-          test)))))
+           test))))
+   (if error (user-error "No test at point"))))
 
 (defun ert--results-test-at-point-allow-redefinition ()
   "Look up the test at point, and check whether it has been redefined.
@@ -2377,7 +2388,7 @@ To be used in the ERT results buffer."
 
 To be used in the ERT results buffer."
   (interactive)
-  (let* ((test (ert--results-test-at-point-no-redefinition))
+  (let* ((test (ert--results-test-at-point-no-redefinition t))
          (stats ert--results-stats)
          (pos (ert--stats-test-pos stats test))
          (result (aref (ert--stats-test-results stats) pos)))
@@ -2406,7 +2417,7 @@ To be used in the ERT results buffer."
 
 To be used in the ERT results buffer."
   (interactive)
-  (let* ((test (ert--results-test-at-point-no-redefinition))
+  (let* ((test (ert--results-test-at-point-no-redefinition t))
          (stats ert--results-stats)
          (pos (ert--stats-test-pos stats test))
          (result (aref (ert--stats-test-results stats) pos)))
@@ -2427,7 +2438,7 @@ To be used in the ERT results buffer."
 
 To be used in the ERT results buffer."
   (interactive)
-  (let* ((test (ert--results-test-at-point-no-redefinition))
+  (let* ((test (ert--results-test-at-point-no-redefinition t))
          (stats ert--results-stats)
          (pos (ert--stats-test-pos stats test))
          (result (aref (ert--stats-test-results stats) pos)))
@@ -2554,7 +2565,7 @@ To be used in the ERT results buffer."
 
 To be used in the ERT results buffer."
   (interactive)
-  (ert-describe-test (ert--results-test-at-point-no-redefinition)))
+  (ert-describe-test (ert--results-test-at-point-no-redefinition t)))

 ;;; Actions on load/unload.

Subject: 25.1; ERT "show messages" error
From: Live System User <[email-masked]>
To: [email-masked]
Date: Thu, 02 Mar 2017 05:28:38 -0500
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

        When running ERT, I get the following error:

0. emacs -Q &

1. M-x ert

[Run test]

>From menubar:

2. ERT Results->Show messages

   I then get a *Backtrace* buffer:
   
Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
  ert--stats-test-key(nil)
  ert-results-pop-to-messages-for-test-at-point()
  funcall-interactively(ert-results-pop-to-messages-for-test-at-point)
  call-interactively(ert-results-pop-to-messages-for-test-at-point nil nil)
  command-execute(ert-results-pop-to-messages-for-test-at-point)

   Thanks.

In GNU Emacs 25.1.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.20.9)
 of 2016-10-13 built on buildvm-05.phx2.fedoraproject.org
Windowing system distributor 'Fedora Project', version 11.0.11803000
Configured using:
 'configure --build=x86_64-redhat-linux-gnu
 --host=x86_64-redhat-linux-gnu --program-prefix=
 --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
 --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
 --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
 --libexecdir=/usr/libexec --localstatedir=/var
 --sharedstatedir=/var/lib --mandir=/usr/share/man
 --infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
 --with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
 --with-gpm=no --with-xwidgets build_alias=x86_64-redhat-linux-gnu
 host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
 -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4
 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
 -m64 -mtune=generic' LDFLAGS=-Wl,-z,relro
 PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig'

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

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Group

Minor modes in effect:
  cursor-sensor-mode: t
  gnus-undo-mode: t
  tooltip-mode: t
  global-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
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
250 2.1.0 Ok
250 2.1.5 Ok
354 End data with <CR><LF>.<CR><LF>
Sending email 
Sending email done
250 2.0.0 Ok: queued as F400538000095
221 2.0.0 Bye
Sending...done
Discard changes to this group and exit? (y or n) y
Making completion list... [3 times]

Load-path shadows:
~/.emacs.d/lisp/gdb-mi hides /usr/share/emacs/25.1/lisp/progmodes/gdb-mi

Features:
(shadow emacsbug mailalias smtpmail sendmail thingatpt etags xref
project ring misearch multi-isearch sort gnus-cite smiley ansi-color
mail-extr gnus-async gnus-bcklg gnus-dup qp gnus-ml disp-table
cursor-sensor nndraft nnmh mm-archive jka-compr timezone url-http url-gw
url-cache url-auth url-handlers utf-7 rfc2104 nnfolder network-stream
nsm starttls gnus-agent gnus-srvr gnus-score score-mode nnvirtual
gnus-msg nntp gnus-cache epa-file epa derived nnreddit mm-url 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 url-vars json map seq byte-opt bytecomp byte-compile cl-extra
cconv gnus-art mm-uu mml2015 mm-view mml-smime smime dig mailcap cl gv
sieve sieve-mode sieve-manage nnir gnus-sum gnus-group gnus-undo
gnus-start gnus-cloud nnimap nnmail mail-source tls gnutls utf7 netrc
parse-time gnus-spec gnus-int gnus-range message dired format-spec
rfc822 mml mml-sec password-cache epg epg-config mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
gmm-utils mailheader gnus-win gnus gnus-ems wid-edit nnoo nnheader
gnus-util mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib
mail-prsvr mail-utils time-date 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
xwidget-internal move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 20710438 836754)
 (symbols 48 246820 59)
 (miscs 40 252 1237)
 (strings 32 1340214 60180)
 (string-bytes 1 88321431)
 (vectors 16 239820)
 (vector-slots 8 3573784 54801)
 (floats 8 447 1932)
 (intervals 56 3090703 8519)
 (buffers 976 53)
 (heap 1024 776098 41763))