[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole cd36bea 39/50: Add more defal and defil tests
From: |
Stefan Monnier |
Subject: |
[elpa] externals/hyperbole cd36bea 39/50: Add more defal and defil tests (#51) |
Date: |
Wed, 17 Mar 2021 18:44:21 -0400 (EDT) |
branch: externals/hyperbole
commit cd36bea27df3ccc7a57c44d1080c5ee1f26141b0
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>
Add more defal and defil tests (#51)
---
Changes | 17 +++++++-
test/hbut-tests.el | 106 ++++++++++++++++++++++++++++++++++++++++++++----
test/hibtypes-tests.el | 4 +-
test/hy-test-helpers.el | 10 +++++
4 files changed, 124 insertions(+), 13 deletions(-)
diff --git a/Changes b/Changes
index 94d489e..d014dcb 100644
--- a/Changes
+++ b/Changes
@@ -1,12 +1,25 @@
+2021-03-06 Mats Lidell <matsl@gnu.org>
+
+* test/hbut-tests.el (hbut-defal-url, hbut-defal-key-sequence)
+ (hbut-defil-it, hbut-defil, hbut-defil-url, hbut-defil-key-sequence):
+ Added more tests for defal and defil.
+
+* test/hibtypes-tests.el (ibtypes::ctags-vgrind-test):
+ (ibtypes::etags-test): Updated since tags info changed
+
+* test/hy-test-helpers.el
+ (hy-test-helpers:action-key-should-call-hpath:find): Add helper for
+ verifying hpath:find is called
+
2021-02-28 Mats Lidell <matsl@gnu.org>
* test/hpath-tests.el
(hpath:find-report-lisp-variable-path-name-when-not-exists): Verify
- not found file name error message contains the expanded lisp variable.
+ not found file name error message contains the expanded lisp variable.
* hbut.el (defil): Use FIXEDCASE is non-nil to not alter the case of the
replacement text.
-
+
* test/hbut-tests.el (hbut-defal, hbut-defal-fails-on-file-missing)
(hbut-defil): Test for defal and defil implicit button macros.
diff --git a/test/hbut-tests.el b/test/hbut-tests.el
index 766f755..1da63c3 100644
--- a/test/hbut-tests.el
+++ b/test/hbut-tests.el
@@ -18,23 +18,78 @@
(require 'ert)
(require 'hbut)
+(load (expand-file-name "hy-test-helpers"
+ (file-name-directory (or load-file-name
+ default-directory))))
+(declare-function hy-test-helpers:consume-input-events "hy-test-helpers")
+
(ert-deftest hbut-defal ()
- (defal hfile "${hyperb:dir}/\\1")
+ (defal defal-path "${hyperb:dir}/\\1")
(unwind-protect
(with-temp-buffer
- (insert "<hfile DEMO>")
+ (insert "<defal-path DEMO>")
(goto-char 4)
(action-key)
(should (string= (concat hyperb:dir "DEMO") buffer-file-name))))
(progn
(kill-buffer "DEMO")
- (fmakunbound 'ibtypes::hfile)))
+ (ibtype:delete 'ibtypes::defal-path)))
+
+(defun hbut-defal-url (url &optional new-window)
+ "Verify call with proper URL and optional NEW-WINDOW."
+ (should (equal url "https://github.com/rswgnu/hyperbole/pull/34"))
+ (should (equal new-window nil)))
+
+(ert-deftest hbut-defal-url ()
+ (defal defal-url "https://github.com/rswgnu/hyperbole/pull/\\1")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<defal-url 34>")
+ (goto-char 4)
+ (let ((browse-url-browser-function 'hbut-defal-url))
+ (action-key)))
+ (ibtype:delete 'ibtypes::defal-url)))
+
+(ert-deftest hbut-defal-key-sequence ()
+ (skip-unless (not noninteractive))
+ (defal defal-key "{C-h v \\1 RET}")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<defal-key emacs-version>")
+ (goto-char 4)
+ (action-key)
+ (hy-test-helpers:consume-input-events)
+ (set-buffer "*Help*")
+ (should (looking-at "emacs-version")))
+ (ibtype:delete 'ibtypes::defal-key)))
+
+;; This test seems to break the ert tests when rerun in the same emacs
+;; process so commenting out for now. As defined now it is an expected
+;; failure anyway.
+;;
+;; (defun hbut-verify-defal (x)
+;; "Verify function i called with X set to the string `test'."
+;; (should (string= x "test")))
+;;
+;; (ert-deftest hbut-defal-function ()
+;; "defal call function should only supply the argument portion of
+;; the button text?"
+;; :expected-result :failed
+;; (defal defal-func 'hbut-verify-defal)
+;; (unwind-protect
+;; (with-temp-buffer
+;; (insert "<defal-func test>")
+;; (goto-char 4)
+;; (action-key)))
+;; (progn
+;; (ibtype:delete 'ibtypes::defal-func)))
+
(ert-deftest hbut-defal-fails-on-file-missing ()
- (defal hfile "${hyperb:dir}/\\1")
+ (defal defal-path-missing "${hyperb:dir}/\\1")
(unwind-protect
(with-temp-buffer
- (insert "<hfile UNKNOWN-FILE>")
+ (insert "<defal-path-missing UNKNOWN-FILE>")
(goto-char 4)
(condition-case err
(action-key)
@@ -42,10 +97,10 @@
(progn
(should (equal (car err) 'error))
(should (string-search "hpath:find" (cadr err)))))))
- (fmakunbound 'ibtypes::hfile)))
+ (ibtype:delete 'ibtypes::defal-path-missing)))
-(ert-deftest hbut-defil ()
- (defil hfile "<<<" ">>>" ".*" "${hyperb:dir}/\\&")
+(ert-deftest hbut-defil-it ()
+ (defil defil-path-it "<<<" ">>>" ".*" "${hyperb:dir}/\\&")
(unwind-protect
(with-temp-buffer
(insert "<<<DEMO>>>")
@@ -54,7 +109,40 @@
(should (string= (concat hyperb:dir "DEMO") buffer-file-name)))
(progn
(kill-buffer "DEMO")
- (fmakunbound 'ibtypes::hfile))))
+ (ibtype:delete 'ibtypes::defil-path-it))))
+
+(ert-deftest hbut-defil ()
+ (defil defil-path "<<<" ">>>" ".*" "${hyperb:dir}/\\&")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<<<DEMO>>>")
+ (goto-char 4)
+ (hy-test-helpers:action-key-should-call-hpath:find
"${hyperb:dir}/DEMO"))
+ (progn
+ (ibtype:delete 'ibtypes::defil-path))))
+
+(ert-deftest hbut-defil-url ()
+ (defil defil-url "<<<" ">>>" ".*"
"https://github.com/rswgnu/hyperbole/pull/\\&")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<<<34>>>")
+ (goto-char 4)
+ (let ((browse-url-browser-function 'hbut-defal-url))
+ (action-key)))
+ (ibtype:delete 'ibtypes::defil-url)))
+
+(ert-deftest hbut-defil-key-sequence ()
+ (skip-unless (not noninteractive))
+ (defil defil-key "<<<" ">>>" ".*" "{C-h v \\& RET}")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<<<emacs-version>>>")
+ (goto-char 4)
+ (action-key)
+ (hy-test-helpers:consume-input-events)
+ (set-buffer "*Help*")
+ (should (looking-at "emacs-version")))
+ (ibtype:delete 'ibtypes::defil-key)))
(provide 'hbut-tests)
;;; hbut-tests.el ends here
diff --git a/test/hibtypes-tests.el b/test/hibtypes-tests.el
index b0a4cc5..c095711 100644
--- a/test/hibtypes-tests.el
+++ b/test/hibtypes-tests.el
@@ -118,7 +118,7 @@
(ert-deftest ibtypes::ctags-vgrind-test ()
(unwind-protect
(with-temp-buffer
- (insert "hy-test-helpers:consume-input-events hy-test-helpers.el 20\n")
+ (insert "hy-test-helpers:consume-input-events hy-test-helpers.el 21\n")
(goto-char (point-min))
(forward-char 4)
(let ((default-directory (concat default-directory "test")))
@@ -133,7 +133,7 @@
(with-temp-buffer
(insert "\n")
(insert "hy-test-helpers.el,103\n")
- (insert "(defun hy-test-helpers:consume-input-events 20,359\n")
+ (insert "(defun hy-test-helpers:consume-input-events 21,359\n")
(rename-buffer (concat "TAGS" (buffer-name)))
(goto-char (point-min))
(forward-line 2)
diff --git a/test/hy-test-helpers.el b/test/hy-test-helpers.el
index c5fe773..28b6dfe 100644
--- a/test/hy-test-helpers.el
+++ b/test/hy-test-helpers.el
@@ -16,6 +16,7 @@
;;; Code:
(require 'ert)
+(require 'cl-macs)
(defun hy-test-helpers:consume-input-events ()
"Use recusive-edit to consume the events kbd-key generate."
@@ -29,5 +30,14 @@
(goto-char (point-max))
(search-backward msg (- (point-max) 350))))))
+(defun hy-test-helpers:action-key-should-call-hpath:find (str)
+ "Call action-key and check that hpath:find was called with STR."
+ (let ((was-called nil))
+ (cl-letf (((symbol-function 'hpath:find)
+ (lambda (filename)
+ (setq was-called (should (string= str filename))))))
+ (action-key)
+ (should was-called))))
+
(provide 'hy-test-helpers)
;;; hy-test-helpers.el ends here
- [elpa] externals/hyperbole aad4494 40/50: Add smart-magit-tab: Do what TAB or RET does, (continued)
- [elpa] externals/hyperbole aad4494 40/50: Add smart-magit-tab: Do what TAB or RET does, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole d1dcd54 41/50: * Disable magit-auto-revert-mode-enable-in-buffers in hyrolo buffer, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole c7d62e1 46/50: Make defil handle action type symbols and strings, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 6b2c073 49/50: Correct test cases failing on mac (#55), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 4eef4e9 50/50: Install with-simulated-input if not available (#54), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 25ba634 31/50: Add fast window link button creation via {M-o w} with Ace Window., Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 64579b0 30/50: Fix defil with function improper call to regexp-quote, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole fccc0e5 42/50: Limit Action Button function arg to parameter after function name, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 1219e12 35/50: Merge branch 'master' of hyperbole, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 9ca5b0f 45/50: More tests for ib with labels (#53), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole cd36bea 39/50: Add more defal and defil tests (#51),
Stefan Monnier <=
- [elpa] externals/hyperbole aeb5a31 37/50: Add defal defil tests plus some extras (#49), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 1c21784 44/50: Add tests for ib with labels (#52), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole faa061e 48/50: Magit Action/Assist Mouse Key on header line toggles diff/all sections visibility, Stefan Monnier, 2021/03/17