emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/hyperbole e0c4a0006b 3/4: hypb-ert.el: Rewrite to impro


From: ELPA Syncer
Subject: [elpa] externals/hyperbole e0c4a0006b 3/4: hypb-ert.el: Rewrite to improve naming and to load tests once only
Date: Sun, 9 Jan 2022 15:57:39 -0500 (EST)

branch: externals/hyperbole
commit e0c4a0006b4c5c4d686486b87ff6766f7503c025
Author: Robert Weiner <rsw@gnu.org>
Commit: Robert Weiner <rsw@gnu.org>

    hypb-ert.el: Rewrite to improve naming and to load tests once only
---
 ChangeLog                          |  8 ++++--
 HY-NEWS                            | 25 +++++++++--------
 hypb-ert.el                        | 57 ++++++++++++++++++++++----------------
 install-test/local-install-test.sh |  2 +-
 test/hmouse-drv-tests.el           | 11 ++++----
 5 files changed, 58 insertions(+), 45 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4611685449..fa3164563c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,11 +10,15 @@
 
 * hypb.el (hypb:string-count-matches): Rewrite to handle start and end 
properly.
 
-* hypb.el (hyupb:insert-hyperbole-banner): Renamed from 
'hypb:display-file-with-logo-emacs'
-    and removed unused 'file' parameter.
+* hypb.el (hypb:insert-hyperbole-banner): Rename from 
'hypb:display-file-with-logo-emacs'
+    and remove unused 'file' parameter.
 
 * hypb.el: Use lexical binding and remove any lexical binding errors.
 
+* hypb-ert.el: Rewrite to improve naming and to load tests once only using 
require.
+
+* test/hmouse-drv-tests.el (hbut-defal): Generalize to prevent failures.
+
 2022-01-08  Bob Weiner  <rsw@gnu.org>
 
 * hpath.el (hpath:return-one-value): Complete rewrite to handle complex
diff --git a/HY-NEWS b/HY-NEWS
index dc7e63c0ec..6b99b710d2 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -65,25 +65,26 @@
 
   TEST CASES
 
-    - Hyperbole Automated Testing: Hyperbole now includes over 170 test cases
+    - Hyperbole Automated Testing: Hyperbole now includes over 200 test cases
       in the test/ subdirectory.  Simply run 'make test' or 'make test-all'
       from the command-line when in the Hyperbole source directory and you
       should see all tests pass.  If any fail, you can press the Action Key
       to see the source of the failure.
 
-    - Defal implicit buttons hypb-ert-sym and hypb-ert-sel: For running
-      hyperbole ert test from hyperbole source files.
-       Defines an implicit button for running an ert test
-
-       Example:
-         Run the test hbut-defal-url
-         <hypb-ert-sym hbut-defal-url>
+    - Implicit Button Types to Run Tests: The file "hypb-ert.el" contains two
+      action link types:
+        hyperbole-run-test  - run a single Hyperbole test by name
+        hyperbole-run-tests - run one more tests matching a pattern
+      
+        Example uses:
+          Run the test hbut-defal-url
+            <hyperbole-run-test hbut-defal-url>
 
-         Run the tests specified by the test selector hbut-defal
-         <hypb-ert-sel hbut-defal>
+          Run the tests specified by the test selector hbut-defal
+            <hyperbole-run-tests hbut-defal>
 
-         Run all tests
-         <hypb-ert-sel t>
+          Run all tests
+            <hyperbole-run-tests t>
 
   HYROLO
 
diff --git a/hypb-ert.el b/hypb-ert.el
index 1397bcfb6a..0a77308f25 100644
--- a/hypb-ert.el
+++ b/hypb-ert.el
@@ -1,6 +1,6 @@
-;;; hypb-ert --- ert button support                   -*- lexical-binding: t; 
-*-
+;;; hypb-ert.el --- ert button support                   -*- lexical-binding: 
t; -*-
 
-;; Author: Mats Lidell <matsl@gnu.org>
+;; Author: Mats Lidell <matsl@gnu.org> and Bob Weiner <rsw@gnu.org>
 ;;
 ;; Orig-Date: 31-Mar-21 at 21:11:00
 ;;
@@ -11,17 +11,18 @@
 
 ;;; Commentary:
 
-;; Defines an implicit button for running an ert test
+;; Creates two action link implicit button types for running any Hyperbole test
+;; defined in "${hyperb:dir}/test/".
 ;;
-;; Example:
-;;   Run the test hbut-defal-url
-;;   <hypb-ert-sym hbut-defal-url>
+;; Examples:
+;;   Run the test named hbut-defal-url:
+;;     <hyperbole-run-test hbut-defal-url>
 ;;
-;;   Run the tests that start with the string, "hbut-defal"
-;;   <hypb-ert-sel hbut-defal>
+;;   Run the tests that start with the string, "hbut-defal":
+;;     <hyperbole-run-tests hbut-defal>
 ;;
-;;   Run all Hyperbole tests
-;;   <hypb-ert-sel t>
+;;   Run all Hyperbole tests:
+;;     <hyperbole-run-tests t>
 
 ;;; Code:
 
@@ -29,27 +30,35 @@
 (require 'hbut)
 (require 'hargs)
 
-(defun hypb-run-ert-test-libraries ()
-  "Return the list of test Lisp libraries to load."
-  (directory-files (expand-file-name "test" hyperb:dir) t "^[a-zA-Z].*\\.el$"))
+(defun hypb-ert-get-require-symbols ()
+  "Return the list of test Lisp library symbols to require."
+  (mapcar (lambda (file)
+           (intern (substring file 0 -3)))
+         (directory-files (expand-file-name "test" hyperb:dir) nil 
"^[a-zA-Z].*\\.el$")))
 
-(defun hypb-run-ert-test-symbol (test-symbol)
-  "Run the specified TEST-SYMBOL ert test."
-  (mapc #'load-file (hypb-run-ert-test-libraries))
-  (ert (intern test-symbol)))
+(defun hypb-ert-require-libraries ()
+  (mapc #'require (hypb-ert-get-require-symbols)))
 
-(defun hypb-run-ert-test-selector (test-selector)
+(defun hypb-ert-run-test (test-name)
+  "Run the specified TEST-NAME ert test."
+  (hypb-ert-require-libraries)
+  (let ((test-sym (intern-soft test-name)))
+    (if test-sym
+       (ert test-sym)
+      (user-error "Invalid test name: %s" test-name))))
+
+(defun hypb-ert-run-tests (test-selector)
   "Run the specified TEST-SELECTOR defined ert test."
-  (mapc #'load-file (hypb-run-ert-test-libraries))
-  (ert test-selector))
+  (hypb-ert-require-libraries)
+  (ert (regexp-quote test-selector)))
 
-(defal hypb-ert-sym "hypb-run-ert-test-symbol")
-(defal hypb-ert-sel "hypb-run-ert-test-selector")
+(defal hyperbole-run-test  "hypb-ert-run-test")
+(defal hyperbole-run-tests "hypb-ert-run-tests")
 
-(defun hypb-run-all-tests ()
+(defun hypb-ert-run-all-tests ()
   "Run every ert test."
   (interactive)
-  (mapc #'load-file (hypb-run-ert-test-libraries))
+  (hypb-ert-require-libraries)
   (ert t))
 
 (provide 'hypb-ert)
diff --git a/install-test/local-install-test.sh 
b/install-test/local-install-test.sh
index 56c9d88aa2..05f24d6f71 100755
--- a/install-test/local-install-test.sh
+++ b/install-test/local-install-test.sh
@@ -16,5 +16,5 @@ cd $app/$install_method
 emacs --batch -l $app/$install_method/.emacs \
       --eval '(load (expand-file-name "test/hy-test-dependencies.el" 
hyperb:dir))' \
       -l hypb-ert \
-      --eval "(mapc #'load-file (hypb-run-ert-test-libraries))" \
+      --eval "(hypb-ert-require-libraries)" \
       -f ert-run-tests-batch-and-exit
diff --git a/test/hmouse-drv-tests.el b/test/hmouse-drv-tests.el
index c036751c6f..c6340c9e55 100644
--- a/test/hmouse-drv-tests.el
+++ b/test/hmouse-drv-tests.el
@@ -31,11 +31,10 @@
       (with-temp-buffer
         (insert "<defal-path DEMO>")
         (goto-char 4)
-        (action-key)
-        (should (string= (expand-file-name "DEMO" hyperb:dir) 
buffer-file-name))))
-    (progn
-      (kill-buffer "DEMO")
-      (ibtype:delete 'ibtypes::defal-path)))
+        (hy-test-helpers:action-key-should-call-hpath:find 
"${hyperb:dir}/DEMO"))
+    (when (string-match-p "DEMO" (buffer-name))
+      (kill-buffer (current-buffer)))
+    (ibtype:delete 'ibtypes::defal-path)))
 
 (defun hbut-defal-url (url &optional new-window)
   "Verify call with proper URL and optional NEW-WINDOW."
@@ -102,7 +101,7 @@
           (error
            (progn
              (should (equal (car err) 'error))
-             (should (string-match "hpath:find" (cadr err)))))))
+             (should (string-match-p "hpath:find" (cadr err)))))))
     (ibtype:delete 'ibtypes::defal-path-missing)))
 
 (ert-deftest hbut-defil-it ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]