branch: externals/hyperbole
commit 3e88bb0b176d37425dfb1d4a3a564c3ed5a8de98
Author: bw <r...@gnu.org>
Commit: bw <r...@gnu.org>

    Reuse ert test result items when Smart Keys run tests from defs
    
    Revert batch ert change since interactive works better and updates
    we have made to ert support in "hypb-ert.el".
    
    Fix ert edebug test.
---
 ChangeLog              | 22 ++++++++++++++++++++--
 Makefile               |  8 ++++----
 hbut.el                |  5 ++++-
 hypb-ert.el            | 51 +++++++++++++++++++++++++-------------------------
 man/hyperbole.texi     | 30 ++++++++++++++++-------------
 test/hypb-ert-tests.el |  7 +++----
 6 files changed, 73 insertions(+), 50 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 73b6e5f1d7..be839776ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,25 @@
+2024-01-06  Bob Weiner  <r...@gnu.org>
+
+* Makefile (test-all): Revert to use 'ert-run-tests-interactively' again
+    instead of 'ert-run-tests-batch' so get interactive *ert* features
+    including {b} to show backtraces for failed tests.  With new updates,
+    now can run a previously run test from its definition with the Action
+    Key and it will simply update the result in the existing buffer rather
+    than overwriting the buffer with just that test.
+
+* test/hypb-ert-tests.el (hypb-ert-tests--edebug-is-called): Fix this
+    test by removing mock of `edebug-defun' which is necessary to set
+    the symbol property that registers the name as an ert test.  Without
+    this, `hypb-ert-run-test-at-definition' will not run the test.
+
 2024-01-05  Bob Weiner  <r...@gnu.org>
 
-* hypb-ert.el (hypb-ert-run-test-at-definition): Accept a symbol as
-    a 'test-name' argument.
+* test/hypb-ert-tests.el (hypb-ert-tests--edebug-is-called):
+  hypb-ert.el (hypb-ert-run-test-at-definition,
+               hyperbole-run-test-definition,
+               hyperbole-run-test-definition:help): Remove 'test-name' arg
+    and find any name at point instead.  Return t if run a test, else nil.
+    Simplify logic.
 
 * hmouse-tag.el (smart-emacs-lisp-mode-p): Include 'ert-results-mode'.
                 (smart-lisp-find-tag): Allow 'tag' arg to be a symbol,
diff --git a/Makefile b/Makefile
index b1f97d9d99..14f9cb49c4 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 # Author:       Bob Weiner
 #
 # Orig-Date:    15-Jun-94 at 03:42:38
-# Last-Mod:      5-Jan-24 at 02:24:26 by Bob Weiner
+# Last-Mod:      6-Jan-24 at 01:47:15 by Bob Weiner
 #
 # Copyright (C) 1994-2023  Free Software Foundation, Inc.
 # See the file HY-COPY for license information.
@@ -479,14 +479,14 @@ test-all:
 ifeq ($(TERM), dumb)
 ifneq (,$(findstring .apple.,$(DISPLAY)))
         # Found, on MacOS
-       TERM=xterm-256color $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ((auto-save-default)) 
$(LOAD_TEST_ERT_FILES) (ert-run-tests-batch t) (switch-to-buffer 
\"*Messages*\"))"
+       TERM=xterm-256color $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ((auto-save-default)) 
$(LOAD_TEST_ERT_FILES) (ert-run-tests-interactively t))"
 else
         # Not found, set TERM so tests will at least run within parent Emacs 
session
-       TERM=vt100 $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ($(LET_VARIABLES)) 
$(LOAD_TEST_ERT_FILES) (ert-run-tests-batch t) (switch-to-buffer 
\"*Messages*\"))"
+       TERM=vt100 $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ($(LET_VARIABLES)) 
$(LOAD_TEST_ERT_FILES) (ert-run-tests-interactively t))"
 endif
 else
         # Typical case, run emacs normally
-       $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ($(LET_VARIABLES)) 
$(LOAD_TEST_ERT_FILES) (ert-run-tests-batch t) (switch-to-buffer 
\"*Messages*\"))"
+       $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ($(LET_VARIABLES)) 
$(LOAD_TEST_ERT_FILES) (ert-run-tests-interactively t))"
 endif
 
 batch-tests: test-all-output
diff --git a/hbut.el b/hbut.el
index 2f55428706..8781701a74 100644
--- a/hbut.el
+++ b/hbut.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    18-Sep-91 at 02:57:09
-;; Last-Mod:      3-Jan-24 at 23:32:27 by Mats Lidell
+;; Last-Mod:      6-Jan-24 at 00:40:15 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -2322,6 +2322,9 @@ move to the first occurrence of the button."
 (defun    ibut:operate (&optional new-name edit-flag)
   "Insert/modify an ibutton based on `hbut:current' in current buffer.
 
+This is for internal Hyperbole use only.  Use `ibut:program' and `ibut:create'
+(an alias of `defib'), if programming applications with Hyperbole.
+
 IMPORTANT:
 Caller must either call `hbut:at-p' or manually set the attributes of
 `hbut:current' prior to invoking this function, i.e. there must be an
diff --git a/hypb-ert.el b/hypb-ert.el
index ce5745718a..db7e90d248 100644
--- a/hypb-ert.el
+++ b/hypb-ert.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <ma...@gnu.org> and Bob Weiner <r...@gnu.org>
 ;;
 ;; Orig-Date:    31-Mar-21 at 21:11:00
-;; Last-Mod:      5-Jan-24 at 15:11:42 by Bob Weiner
+;; Last-Mod:      6-Jan-24 at 01:33:34 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -97,7 +97,7 @@ With optional START-END-FLAG, return a list of (test-name 
start-pos end-pos)."
              (memq (char-after (point))
                    '(?\( ?\) ?\[ ?\] ?{ ?} ?< ?>)))
     (save-excursion
-      (forward-line 0)
+      (beginning-of-line)
       (when (looking-at (concat "(ert-deftest\\(-async\\)?[ \t]+"
                                "\\(" lisp-mode-symbol-regexp "\\)"
                                "\\s-*("))
@@ -105,26 +105,27 @@ With optional START-END-FLAG, return a list of (test-name 
start-pos end-pos)."
            (list (match-string-no-properties 2) (match-beginning 2) (match-end 
2))
          (match-string-no-properties 2))))))
 
-(defun hypb-ert-run-test-at-definition (test-name &optional edebug-it)
-  "Eval and run the ert TEST-NAME defined at point.
-Assume point is on the text of the first line of an ert test def,
-With optional EDEBUG-IT non-nil (when the assist-key is pressed),
-edebug the test when it is run."
-  (let ((test-sym (if (symbolp test-name) test-name (intern-soft test-name))))
-    ;; Ensure run the latest version of the test, either with the
-    ;; edebugger if already instrumented for it; otherwise, with the
-    ;; normal evaluator.
-    (if (and test-sym edebug-it)
-       (edebug-defun)
-      (eval-defun nil)
-      (setq test-sym (intern-soft test-name))
-      (when (and test-sym edebug-it)
-       (edebug-defun)))
-    (setq test-sym (intern-soft test-name))
-    (when (and test-sym (ert-test-boundp test-sym))
-      (when (and buffer-file-name (string-prefix-p hyperb:dir 
buffer-file-name))
-       (hypb-ert-require-libraries))
-      (hypb-ert test-sym))))
+(defun hypb-ert-run-test-at-definition (&optional edebug-it)
+  "Eval and run any Hyperbole ert test defined at point and return t.
+Otherwise, return nil.  Point should be on the text of the first
+line of an ert test def.  With optional EDEBUG-IT non-nil (when
+the assist-key is pressed), edebug the test when it is run."
+  (let* ((test-name (hypb-ert-def-at-p))
+        (test-sym (intern-soft test-name)))
+    (when test-name
+      ;; Ensure run the latest version of the test, either with the
+      ;; edebugger if `edebug-it' is non-nil; otherwise, with the
+      ;; normal evaluator.
+      (if edebug-it
+         (edebug-defun)
+       (eval-defun nil))
+      (unless test-sym
+       (setq test-sym (intern-soft test-name)))
+      (when (and test-sym (ert-test-boundp test-sym))
+       (when (and buffer-file-name (string-prefix-p hyperb:dir 
buffer-file-name))
+         (hypb-ert-require-libraries))
+       (when (hypb-ert test-sym)
+         t)))))
 
 (defib hyperbole-run-test-definition ()
   "If on the name in the first line of an ert test def, eval and run the test.
@@ -132,13 +133,11 @@ With an Assist Key press instead, edebug the test and 
step through it."
   (let ((test-name-and-positions (hypb-ert-def-at-p t)))
     (when test-name-and-positions
       (apply #'ibut:label-set test-name-and-positions)
-      (hact 'hypb-ert-run-test-at-definition (car test-name-and-positions)))))
+      (hact 'hypb-ert-run-test-at-definition))))
 
 (defun hyperbole-run-test-definition:help (_hbut)
   "If on the name in the first line of an ert test def, edebug the test."
-  (let ((test-name (hypb-ert-def-at-p)))
-    (when test-name
-      (hypb-ert-run-test-at-definition test-name t))))
+  (hypb-ert-run-test-at-definition t))
 
 (provide 'hypb-ert)
 ;;; hypb-ert.el ends here
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index 8b4dbcd8c2..46da3d6620 100644
--- a/man/hyperbole.texi
+++ b/man/hyperbole.texi
@@ -7,7 +7,7 @@
 @c Author:       Bob Weiner
 @c
 @c Orig-Date:     6-Nov-91 at 11:18:03
-@c Last-Mod:      4-Jan-24 at 13:12:14 by Bob Weiner
+@c Last-Mod:      6-Jan-24 at 01:18:32 by Bob Weiner
 
 @c %**start of header (This is for running Texinfo on a region.)
 @setfilename hyperbole.info
@@ -156,7 +156,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</P>
 
 <PRE>
 Edition 9.0.0
-Printed January 3, 2024.
+Printed January 6, 2024.
 
   Published by the Free Software Foundation, Inc.
   Author:    Bob Weiner
@@ -198,7 +198,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 @example
 Edition 9.0.0
-January 3, 2024
+January 6, 2024
 
   Published by the Free Software Foundation, Inc.
   Author:    Bob Weiner
@@ -7198,17 +7198,21 @@ by the implicit button; that must be done separately.
 @vindex class, hbut
 @vindex file, hib-kbd.el
 By default, a request for help on an implicit button will display the
-button's attributes in the same manner as is done for explicit buttons.
-For some implicit button types, other forms of help will be more
-appropriate.  If an Emacs Lisp function is defined whose name is formed
-from the concatenation of the type name followed by @samp{:help}, e.g.@:
-@code{my-ibtype:help}, it is used as the assist-action whenever the
-Assist Key is pressed, to respond to requests for help on buttons of
-that type.  Any such function should take a single argument of an
-implicit button construct.  (This is what
+button's attributes in the same manner as is done for explicit
+buttons.  For some implicit button types, other forms of help will be
+more appropriate.  If an Emacs Lisp function is defined whose name is
+formed from the concatenation of the type name followed by
+@samp{:help}, e.g.@: @code{my-ibtype:help}, it is used as the
+assist-action whenever the Assist Key is pressed, to respond to
+requests for help on buttons of that type.  Any such function should
+take a single argument of an implicit button construct.  (This is what
 @code{(ibut:at-p)} returns when point is within an implicit button
-context).  The button may be queried for its attributes using
-functions from the @samp{hbut} and @samp{hattr} classes.  See
+context).  Remember that the standard help for buttons with custom
+help functions is still available with @bkbd{C-h A} for the Action Key
+and @bkbd{C-u C-h A} for the Assist Key.
+
+To programmatically query implicit buttons for their attributes, use
+the functions from the @samp{hbut} and @samp{hattr} classes.  See
 the @file{hib-kbd.el} file for an example of a custom help function.
 
 @node Explicit Button Technicalities, Encapsulating Systems, Creating Types, 
Developing with Hyperbole
diff --git a/test/hypb-ert-tests.el b/test/hypb-ert-tests.el
index cdc39118f9..99f10f1ed5 100644
--- a/test/hypb-ert-tests.el
+++ b/test/hypb-ert-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:     1-Jan-24 at 23:11:54
-;; Last-Mod:      2-Jan-24 at 00:28:42 by Mats Lidell
+;; Last-Mod:      6-Jan-24 at 01:34:38 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -55,9 +55,8 @@
       (insert "(ert-deftest " test-name " ()\n\"Docstring.\"\nt\n)\n")
       (emacs-lisp-mode)
       (goto-char (1+ (point-min)))
-      (mocklet (((edebug-defun) => t)
-                ((hypb-ert *) => t))
-        (hypb-ert-run-test-at-definition test-name t)))))
+      (mocklet (((hypb-ert *) => t))
+        (hypb-ert-run-test-at-definition t)))))
 
 (provide 'hypb-ert-tests)
 ;;; hypb-ert-tests.el ends here

Reply via email to