branch: externals/hyperbole
commit c57a7b9ee0e7477a949f4f00f27b54ee510235b5
Merge: 30359a2e54 62e9eb4b24
Author: bw <r...@gnu.org>
Commit: bw <r...@gnu.org>

    Merge branch 'master' into rsw
---
 ChangeLog               | 14 ++++++++++++
 Makefile                | 13 +++++++----
 test/hy-test-helpers.el |  5 +++-
 test/hywiki-tests.el    | 61 ++++++++++++++++++++++++++-----------------------
 4 files changed, 59 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 50433ea8b1..bc3efe8854 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,20 @@
     by 'post-command-hook' before they can be used by 'post-self-insert-hook'.
             (hywiki-delimited-p): Add support for strings as well.
 
+2025-04-06  Mats Lidell  <ma...@gnu.org>
+
+* test/hy-test-helpers.el (hy-test-run-failing-flag): Set to non-nil to
+    activate failing test cases. Used by HYPB_ERT_FAILURE.
+
+* Makefile (HYPB_ERT_FAILURE): Command line controlled macro that tells if
+    failing test cases should be run.
+
+* test/hywiki-tests.el (hywiki-tests--run-test-case): Remove per char
+    verification in DSL. Just verify after each insert or remove as whole.
+    (hywiki-tests--wikiword-step-check): Simplify tests after DSL change.
+    (hywiki-tests--verify-hywiki-word): Add verification that
+    hywiki-word-is-p agrees with hywiki-word-at.
+
 2025-04-05  Bob Weiner  <r...@gnu.org>
 
 * hywiki.el (hywiki-word-at, hywiki-word-is-p): If has a #section, ensure
diff --git a/Makefile b/Makefile
index b56b4a368a..2a39b140be 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,7 @@
 # Author:       Bob Weiner
 #
 # Orig-Date:    15-Jun-94 at 03:42:38
-# Last-Mod:     30-Mar-25 at 10:36:42 by Bob Weiner
+# Last-Mod:     12-Apr-25 at 13:15:02 by Bob Weiner
 #
 # Copyright (C) 1994-2025  Free Software Foundation, Inc.
 # See the file HY-COPY for license information.
@@ -538,6 +538,9 @@ else
 HYPB_ERT_BATCH = (ert-run-tests-batch-and-exit)
 HYPB_ERT_INTERACTIVE = (ert-run-tests-interactively t)
 endif
+ifeq ($(origin failure), command line)
+HYPB_ERT_FAILURE = (setq hy-test-run-failing-flag ${failure})
+endif
 
 # For full backtrace run make test FULL_BT=<anything or even empty>
 ifeq ($(origin FULL_BT), command line)
@@ -553,7 +556,7 @@ test-ert:
        --eval "(let ((auto-save-default) (ert-batch-print-level 10) \
                      (ert-batch-print-length nil) \
                      $(HYPB_ERT_BATCH_BT) (ert-batch-backtrace-right-margin 
2048)) \
-                  $(LOAD_TEST_ERT_FILES) $(HYPB_ERT_BATCH))"
+                  $(LOAD_TEST_ERT_FILES) $(HYPB_ERT_FAILURE) 
$(HYPB_ERT_BATCH))"
 
 # Run all tests by starting an Emacs that runs the tests interactively in 
windowed mode.
 all-tests: test-all
@@ -562,14 +565,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) $(HYPB_ERT_INTERACTIVE))"
+       TERM=xterm-256color $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ((auto-save-default)) 
$(LOAD_TEST_ERT_FILES) $(HYPB_ERT_FAILURE) $(HYPB_ERT_INTERACTIVE))"
 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) $(HYPB_ERT_INTERACTIVE))"
+       TERM=vt100 $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ($(LET_VARIABLES)) 
$(LOAD_TEST_ERT_FILES) $(HYPB_ERT_FAILURE) $(HYPB_ERT_INTERACTIVE))"
 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) $(HYPB_ERT_INTERACTIVE))"
+       $(EMACS) --quick $(PRELOADS) --eval "(load-file 
\"test/hy-test-dependencies.el\")" --eval "(let ($(LET_VARIABLES)) 
$(LOAD_TEST_ERT_FILES) $(HYPB_ERT_FAILURE) $(HYPB_ERT_INTERACTIVE))"
 endif
 
 test-all-output:
diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el
index b3db82f1cc..c9ada7d34e 100644
--- a/test/hy-test-helpers.el
+++ b/test/hy-test-helpers.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell <ma...@gnu.org>
 ;;
 ;; Orig-Date:    30-Jan-21 at 12:00:00
-;; Last-Mod:     26-Jan-25 at 18:24:56 by Bob Weiner
+;; Last-Mod:      6-Apr-25 at 19:45:02 by Mats Lidell
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -124,5 +124,8 @@ and the default WORD-LENGTH is 4."
       (setq result (concat result (char-to-string (elt chars (random (length 
chars)))))))
     (replace-regexp-in-string "[[:space:]]" "" (capitalize result))))
 
+(defvar hy-test-run-failing-flag nil
+  "Non-nil means test cases that are known to fail will be tried.")
+
 (provide 'hy-test-helpers)
 ;;; hy-test-helpers.el ends here
diff --git a/test/hywiki-tests.el b/test/hywiki-tests.el
index 7fd9d47b3a..c762ba7b52 100644
--- a/test/hywiki-tests.el
+++ b/test/hywiki-tests.el
@@ -3,7 +3,7 @@
 ;; Author:       Mats Lidell
 ;;
 ;; Orig-Date:    18-May-24 at 23:59:48
-;; Last-Mod:      6-Apr-25 at 18:35:32 by Bob Weiner
+;; Last-Mod:     12-Apr-25 at 13:16:10 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -1382,9 +1382,11 @@ If EXPECTED is a string also verify that the wikiword 
matches the
 string."
   (if (not expected)
       (should-not (hywiki-word-at))
-    (if (stringp expected)
-        (should (string= expected (hywiki-word-at)))
-      (should (hywiki-word-at)))))
+    (let ((hywiki-word-found (hywiki-word-at)))
+      (if (stringp expected)
+          (should (string= expected hywiki-word-found))
+        (should hywiki-word-found))
+      (should (hywiki-word-is-p hywiki-word-found)))))
 
 (defun hywiki-tests--run-test-case (test-case)
   "Run the TEST-CASE from point.
@@ -1392,30 +1394,32 @@ Each test case consists of cons cells with an operation 
and the expected
 state of the WikiWord being constructed.  Operations are either a string
 to be inserted, a number of chars to be deleted or a symbol p<number>
 for where to move point.  The expected state is either nil for not a
-wikiword or non-nil for a wikiword.  If equal to a string it is checked
-for match with the wikiword.  Movement of point is relative to point
-when the function is called."
+wikiword or non-nil for a wikiword.  The state is checked after all
+chars of the string are inserted.  If equal to a string it is checked for
+match with the wikiword.  Movement of point is relative to point when
+the function is called."
   (let ((origin (point)))
-    (should (listp test-case))           ; For traceability
+
+    ;; For traceability when looking through the list of should
+    ;; clauses in a failing test.
+    (should (listp test-case))
+
     (dolist (steps test-case)
       (let ((step (car steps))
             (vfy (cdr steps)))
         (cond ((stringp step)
                (dolist (ch (string-to-list step))
-                (unless (characterp ch)
-                  (message "(hywiki-tests--run-test-case):\n  steps = %s\n  
test-case = %s" steps test-case)
-                  (debug))
-                 (hywiki-tests--command-execute #'self-insert-command 1 ch)
-                 (save-excursion
-                   (goto-char (1- (point)))
-                   (hywiki-tests--verify-hywiki-word vfy))))
+                 (hywiki-tests--command-execute #'self-insert-command 1 ch))
+               (save-excursion
+                 (goto-char (1- (point)))
+                 (hywiki-tests--verify-hywiki-word vfy)))
               ((integerp step)
                (let ((forward (> step 0)))
                  (dotimes (_ (abs step))
                    (if forward
                        (hywiki-tests--command-execute #'delete-forward-char 1)
-                     (hywiki-tests--command-execute #'backward-delete-char 1))
-                   (hywiki-tests--verify-hywiki-word vfy))))
+                     (hywiki-tests--command-execute #'backward-delete-char 1)))
+                 (hywiki-tests--verify-hywiki-word vfy)))
               ((and (symbolp step) (string-prefix-p "p" (symbol-name step)))
                (let* ((pos (string-to-number (substring (symbol-name step) 1)))
                       (newpos (+ origin (1- pos))))
@@ -1427,19 +1431,20 @@ when the function is called."
 
 (defconst hywiki-tests--wikiword-step-check
   '(
-    (("H") ("i" . "Hi"))
-    (("H") ("iHo" . t) ("#") ("s " . "HiHo#s"))
-    (("H") ("iHo" . t) ("#") ("s" . t) (-1) (-1 . "HiHo"))
-    (("H") ("iHo" . t) ("#") ("s" . t) (-1) (-3 . t) (-1) ("i" . "Hi"))
-    (("H") ("iHo" . t) ("#") ("s " . t) ("n"))
-    (("H") ("iHo" . t) ("#") ("s " . t) (" n"))
+    (("Hi" . "Hi"))
+    (("HiHo" . t) ("#"))
+    (("HiHo" . t) ("#s " . "HiHo#s"))
+    (("HiHo" . t) ("#s" . t) (-2 . "HiHo"))
+    (("HiHo#s" . t) (-4 . t) (-1) ("i" . "Hi"))
+    (("HiHo#s " . t) ("n"))
+    (("HiHo#s " . t) (" n"))
     ;; With delimiters
-    (("(H") ("iHo" . t) ("#") ("s" . "HiHo#s") (" " . "HiHo#s"))
-    (("(H") ("iHo" . t) ("#") ("s" . "HiHo#s") (")" . "HiHo#s"))
-    (("(H") ("iHo" . t) ("#") ("s" . "HiHo#s") ("-" . "HiHo#s-") ("n" . 
"HiHo#s-n") (")" . "HiHo#s-n"))
+    (("(HiHo#s" . "HiHo#s") (" " . "HiHo#s"))
+    (("(HiHo#s" . "HiHo#s") (")" . "HiHo#s)")) ; Delimiter part of WikiWord. 
See below too.
+    (("(HiHo#s" . "HiHo#s") ("-" . "HiHo#s-") ("n" . "HiHo#s-n") (")" . 
"HiHo#s-n)"))
     ;; Insert and delete between WikiWords
-    (("H") ("iHo" . t) (p3 . t) (" " . "Hi") (p4 . "Ho") (-1 . "HiHo"))
-    (("H") ("iho" . t) (p3 . t) (" " . "Hi") (p4) (-1 . "Hiho"))
+    (("HiHo" . t) (p3 . t) (" " . "Hi") (p4 . "Ho") (-1 . "HiHo"))
+    (("Hiho" . t) (p3 . t) (" " . "Hi") (p4) (-1 . "Hiho"))
     )
   "List of test cases for WikiWords.")
 

Reply via email to