[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 54b537cfdf 1/2: Add location checks to existi
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 54b537cfdf 1/2: Add location checks to existing test cases (#158) |
Date: |
Sun, 6 Feb 2022 15:57:41 -0500 (EST) |
branch: externals/hyperbole
commit 54b537cfdfe5b2c02ff659828186ad7037898029
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>
Add location checks to existing test cases (#158)
* Add loc test
* Add hbut verification helper
* Remove duplicated tests
* Add hbut verification helper
* Remove duplicated tests
* Use helper function with keyworded args
* Remove local changes from Changelog
Co-authored-by: Robert Weiner <rsw@gnu.org>
---
ChangeLog | 4 ++++
test/hbut-tests.el | 32 ++++++++++---------------------
test/hui-tests.el | 50 +++++++++++++------------------------------------
test/hy-test-helpers.el | 11 ++++++++++-
4 files changed, 37 insertions(+), 60 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7c845b3946..fbb2dda055 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -82,6 +82,7 @@
* hsmail.el (mail-yank-original): Fix indentation of this overloaded function.
(message--yank-original-internal): Add overloading of this
function.
+
2022-02-04 Mats Lidell <matsl@gnu.org>
* test/hargs-tests.el (hargs-get-verify-extension-characters)
@@ -95,6 +96,9 @@
2022-02-03 Mats Lidell <matsl@gnu.org>
+* test/hy-test-helpers.el (hy-test-helpers-verify-hattr-at-p): Add helper
+ function and use it.
+
* hypb.el (hypb--installation-type): Return 10 digit git hash.
2022-02-02 Mats Lidell <matsl@gnu.org>
diff --git a/test/hbut-tests.el b/test/hbut-tests.el
index f66e268f92..b8d94744d7 100644
--- a/test/hbut-tests.el
+++ b/test/hbut-tests.el
@@ -5,7 +5,7 @@
;; Orig-Date: 30-may-21 at 09:33:00
;; Last-Mod: 24-Jan-22 at 00:38:20 by Bob Weiner
;;
-;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
@@ -36,6 +36,7 @@ Needed since hyperbole expands all links to absolute paths and
(ebut:program "label" 'link-to-directory "/tmp")
(should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-directory))
(hbut-tests:should-match-tmp-folder (hattr:get (hbut:at-p) 'args))
+ (should (equal (hattr:get (hbut:at-p) 'loc) file))
(should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
(delete-file file))))
@@ -46,9 +47,7 @@ Needed since hyperbole expands all links to absolute paths and
(progn
(find-file file)
(ebut:program "label" 'link-to-directory temporary-file-directory)
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-directory))
- (should (equal (hattr:get (hbut:at-p) 'args) (list
temporary-file-directory)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-directory :args (list temporary-file-directory) :loc file
:lbl-key "label"))
(delete-file file))))
(ert-deftest ebut-program-shell-cmd ()
@@ -58,9 +57,7 @@ Needed since hyperbole expands all links to absolute paths and
(progn
(find-file file)
(ebut:program "label" 'exec-shell-cmd "ls /tmp")
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::exec-shell-cmd))
- (should (equal (hattr:get (hbut:at-p) 'args) '("ls /tmp")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::exec-shell-cmd
:args '("ls /tmp") :loc file :lbl-key "label"))
(delete-file file))))
(ert-deftest ebut-delete-removes-ebut-and-returns-button-data ()
@@ -99,6 +96,7 @@ Needed since hyperbole expands all links to absolute paths and
(with-current-buffer test-buffer
(should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-directory))
(hbut-tests:should-match-tmp-folder (hattr:get (hbut:at-p) 'args))
+ (should (equal (hattr:get (hbut:at-p) 'loc) test-file))
(should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
(delete-file test-file))))
@@ -112,9 +110,7 @@ Needed since hyperbole expands all links to absolute paths
and
(mock (find-file-noselect (expand-file-name hbmap:filename
hbmap:dir-user)) => test-buffer)
(gbut:ebut-program "global" 'eval-elisp '()))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::eval-elisp))
- (should (equal (hattr:get (hbut:at-p) 'args) '(())))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::eval-elisp
:args '(()) :loc test-file :lbl-key "global")))
(delete-file test-file))))
(ert-deftest gbut-program-link-to-file ()
@@ -127,9 +123,7 @@ Needed since hyperbole expands all links to absolute paths
and
(mock (find-file-noselect (expand-file-name hbmap:filename
hbmap:dir-user)) => test-buffer)
(gbut:ebut-program "global" 'link-to-file test-file))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-file))
- (should (equal (hattr:get (hbut:at-p) 'args) (list test-file)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::link-to-file
:args (list test-file) :loc test-file :lbl-key "global")))
(delete-file test-file))))
(ert-deftest gbut-program-link-to-file-line ()
@@ -142,9 +136,7 @@ Needed since hyperbole expands all links to absolute paths
and
(mock (find-file-noselect (expand-file-name hbmap:filename
hbmap:dir-user)) => test-buffer)
(gbut:ebut-program "global" 'link-to-file-line test-file 10))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-file-line))
- (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-file-line :args (list test-file 10) :loc test-file :lbl-key
"global")))
(delete-file test-file))))
(ert-deftest gbut-program-link-to-file-line-and-column ()
@@ -157,9 +149,7 @@ Needed since hyperbole expands all links to absolute paths
and
(mock (find-file-noselect (expand-file-name hbmap:filename
hbmap:dir-user)) => test-buffer)
(gbut:ebut-program "global" 'link-to-file-line-and-column
test-file 10 20))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-file-line-and-column))
- (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10
20)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-file-line-and-column :args (list test-file 10 20) :loc
test-file :lbl-key"global")))
(delete-file test-file))))
(ert-deftest hypb:program-create-ebut-in-buffer ()
@@ -177,9 +167,7 @@ Needed since hyperbole expands all links to absolute paths
and
(progn
(find-file test-file)
(ebut:program "label" 'link-to-file-line-and-column test-file 2 3)
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-file-line-and-column))
- (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 2 3)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-file-line-and-column :args (list test-file 2 3) :loc
test-file :lbl-key "label"))
(delete-file test-file))))
;; FIXME: This file can only be byte-compiled when `el-mock' is installed.
diff --git a/test/hui-tests.el b/test/hui-tests.el
index f8fa933d92..190fb2615e 100644
--- a/test/hui-tests.el
+++ b/test/hui-tests.el
@@ -5,7 +5,7 @@
;; Orig-Date: 30-Jan-21 at 12:00:00
;; Last-Mod: 6-Feb-22 at 00:59:55 by Bob Weiner
;;
-;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
@@ -93,9 +93,7 @@
(find-file file)
(should (hact 'kbd-key "C-h h e c label RET RET link-to-directory
RET RET"))
(hy-test-helpers:consume-input-events)
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-directory))
- (should (equal (hattr:get (hbut:at-p) 'args) '("./")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-directory :args '("./") :loc file :lbl-key "label"))
(delete-file file))))
(ert-deftest hui-ebut-create-link-to-www-url ()
@@ -105,9 +103,7 @@
(find-file file)
(with-simulated-input "label RET RET www-url RET www.hypb.org RET"
(hui:ebut-create)
- (should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::www-url))
- (should (equal (hattr:get (hbut:at-p) 'args) '("www.hypb.org")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::www-url :args
'("www.hypb.org") :loc file :lbl-key "label"))
(delete-file file))))
(ert-deftest
hui-ebut-modify-link-to-www-url-keeping-all-values-should-not-modify-buffer-or-ebut
()
@@ -118,14 +114,10 @@ Modifying the button but keeping the label creates a
dubbel label."
(find-file file)
(with-simulated-input "label RET RET www-url RET www.hypb.org RET"
(hui:ebut-create)
- (should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::www-url))
- (should (equal (hattr:get (hbut:at-p) 'args) '("www.hypb.org")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::www-url :args
'("www.hypb.org") :loc file :lbl-key "label"))
(with-simulated-input "RET RET RET RET"
(hui:ebut-modify "label")
- (should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::www-url))
- (should (equal (hattr:get (hbut:at-p) 'args) '("www.hypb.org")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label"))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::www-url :args
'("www.hypb.org") :loc file :lbl-key "label")
(should (string= "<(label)>" (buffer-string)))))
(delete-file file)))
@@ -140,9 +132,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(mark-word)
(should (hact 'kbd-key "C-h h e c RET link-to-directory RET RET"))
(hy-test-helpers:consume-input-events)
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-directory))
- (should (equal (hattr:get (hbut:at-p) 'args) '("./")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-directory :args '("./") :loc file :lbl-key "label"))
(delete-file file))))
(ert-deftest hui-ebut-www-link ()
@@ -154,9 +144,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(find-file file)
(should (hact 'kbd-key "C-h h e c label RET RET www-url RET
www.example.com RET"))
(hy-test-helpers:consume-input-events)
- (should (eq (hattr:get (hbut:at-p) 'actype) 'actypes::www-url))
- (should (equal (hattr:get (hbut:at-p) 'args) '("www.example.com")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::www-url :args
'("www.example.com") :loc file :lbl-key "label"))
(delete-file file))))
(ert-deftest hui-ebut-create-exec-shell-cmd ()
@@ -168,9 +156,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(find-file file)
(should (hact 'kbd-key "C-h h e c label RET RET exec-shell-cmd RET
ls SPC /tmp RET y n C-x C-s"))
(hy-test-helpers:consume-input-events)
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::exec-shell-cmd))
- (should (equal (hattr:get (hbut:at-p) 'args) '("ls /tmp" t nil)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "label")))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::exec-shell-cmd
:args '("ls /tmp" t nil) :loc file :lbl-key "label"))
(delete-file file))))
(ert-deftest hui-ebut-create-link-to-info-index-using-completion ()
@@ -182,9 +168,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(find-file file)
(should (hact 'kbd-key "C-h h e c emacs-package-button RET RET
link-to-Info-index-item RET (emacs)packag TAB RET"))
(hy-test-helpers:consume-input-events)
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-Info-index-item))
- (should (equal (hattr:get (hbut:at-p) 'args) '("(emacs)Package")))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key)
"emacs-package-button")))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-Info-index-item :args '("(emacs)Package") :loc file :lbl-key
"emacs-package-button"))
(progn
(kill-buffer "*info*")
(delete-file file)))))
@@ -199,9 +183,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(mock (find-file-noselect (gbut:file)) => test-buffer)
(hui:gibut-create "global" test-file))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-file))
- (should (equal (hattr:get (hbut:at-p) 'args) (list test-file)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype 'actypes::link-to-file
:args (list test-file) :loc test-file :lbl-key "global")))
(delete-file test-file))))
(ert-deftest hui-gibut-create-link-to-file-line ()
@@ -214,9 +196,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(mock (find-file-noselect (gbut:file)) => test-buffer)
(hui:gibut-create "global" (concat test-file ":10")))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-file-line))
- (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-file-line :args (list test-file 10) :loc test-file :lbl-key
"global")))
(delete-file test-file))))
(ert-deftest hui-gibut-create-link-to-file-line-and-column ()
@@ -229,9 +209,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(mock (find-file-noselect (gbut:file)) => test-buffer)
(hui:gibut-create "global" (concat test-file ":10:20")))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-file-line-and-column))
- (should (equal (hattr:get (hbut:at-p) 'args) (list test-file 10
20)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-file-line-and-column :args (list test-file 10 20) :loc
test-file :lbl-key "global")))
(delete-file test-file))))
(ert-deftest hui-gibut-create-info-node ()
@@ -245,9 +223,7 @@ Modifying the button but keeping the label creates a dubbel
label."
(mock (find-file-noselect (gbut:file)) => test-buffer)
(hui:gibut-create "global" (concat "\"" info-node "\"")))
(with-current-buffer test-buffer
- (should (eq (hattr:get (hbut:at-p) 'actype)
'actypes::link-to-Info-node))
- (should (equal (hattr:get (hbut:at-p) 'args) (list info-node)))
- (should (equal (hattr:get (hbut:at-p) 'lbl-key) "global"))))
+ (hy-test-helpers-verify-hattr-at-p :actype
'actypes::link-to-Info-node :args (list info-node) :loc test-file :lbl-key
"global")))
(delete-file test-file))))
;; This file can't be byte-compiled without `with-simulated-input' which
diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el
index 3bdee969ad..952b425cad 100644
--- a/test/hy-test-helpers.el
+++ b/test/hy-test-helpers.el
@@ -5,7 +5,7 @@
;; Orig-Date: 30-Jan-21 at 12:00:00
;; Last-Mod: 24-Jan-22 at 00:40:54 by Bob Weiner
;;
-;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; Copyright (C) 2021-2022 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
@@ -52,5 +52,14 @@
(funcall function)
(should was-called))))
+(cl-defun hy-test-helpers-verify-hattr-at-p (&key actype args loc lbl-key)
+ "Verify the attribute of hbut at point.
+Checks ACTYPE, ARGS, LOC and LBL-KEY."
+ (let ((hbut-at-p (hbut:at-p)))
+ (should (eq (hattr:get hbut-at-p 'actype) actype))
+ (should (equal (hattr:get hbut-at-p 'args) args))
+ (should (equal (hattr:get hbut-at-p 'loc) loc))
+ (should (equal (hattr:get hbut-at-p 'lbl-key) lbl-key))))
+
(provide 'hy-test-helpers)
;;; hy-test-helpers.el ends here