[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 8969fe9 43/50: Merge branch 'master' of hyper
From: |
Stefan Monnier |
Subject: |
[elpa] externals/hyperbole 8969fe9 43/50: Merge branch 'master' of hyperbole |
Date: |
Wed, 17 Mar 2021 18:44:22 -0400 (EDT) |
branch: externals/hyperbole
commit 8969fe9fc84ee83a68ae1f8f42a72fe2206251e6
Merge: fccc0e5 cd36bea
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>
Merge branch 'master' of hyperbole
---
Changes | 27 +++++++++
hbut.el | 2 +-
test/demo-tests.el | 16 +++---
test/hbut-tests.el | 148 ++++++++++++++++++++++++++++++++++++++++++++++++
test/hibtypes-tests.el | 20 +++----
test/hpath-tests.el | 29 ++++++++++
test/hy-test-helpers.el | 10 ++++
7 files changed, 230 insertions(+), 22 deletions(-)
diff --git a/Changes b/Changes
index 2fe2317..efcdf96 100644
--- a/Changes
+++ b/Changes
@@ -10,12 +10,39 @@
just below the source reference line so if not on a Hyperbole button,
move back a line and check for a source line again.
+2021-03-06 Mats Lidell <matsl@gnu.org>
+
+* test/hibtypes-tests.el (ibtypes::ctags-vgrind-test):
+ (ibtypes::etags-test): Updated since tags info changed
+
+* 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/hy-test-helpers.el
+ (hy-test-helpers:action-key-should-call-hpath:find): Add helper for
+ verifying hpath:find is called
+
2021-02-28 Bob Weiner <rsw@gnu.org>
* (hyrolo-grep-file): Disable magit-auto-revert-mode-enable-in-buffers
for hyrolo buffers; not needed and can slow/hang file loading. Fixes
issue reported by Gravitypost.
+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.
+
+* 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.
+
+* (demo-man-appropos-test, ibtypes::man-apropos-test): Mock call to man.
+
2021-02-21 Bob Weiner <rsw@gnu.org>
* hui-mouse.el (smart-magit-tab): Do what TAB does unless TAB does nothing
diff --git a/hbut.el b/hbut.el
index a558b78..9d84c94 100644
--- a/hbut.el
+++ b/hbut.el
@@ -1809,7 +1809,7 @@ commit changes."
(hact ,link-expr button-text))
(let ((referent (when (and button-text (stringp ,link-expr)
(string-match ,text-regexp
button-text))
- (replace-match ,link-expr nil nil
button-text))))
+ (replace-match ,link-expr t nil
button-text))))
(ibtype:activate-link referent))))))
(put (intern (format "ibtypes::%s" ',type))
'function-documentation
diff --git a/test/demo-tests.el b/test/demo-tests.el
index 44f50e8..e258f4e 100644
--- a/test/demo-tests.el
+++ b/test/demo-tests.el
@@ -24,6 +24,7 @@
(require 'hib-social)
(require 'eww)
(require 'compile)
+(require 'el-mock)
(load (expand-file-name "hy-test-helpers"
(file-name-directory (or load-file-name
@@ -347,15 +348,12 @@
;; Man appropos
(ert-deftest demo-man-appropos-test ()
- (unwind-protect
- (with-temp-buffer
- (insert "rm (1) - remove")
- (goto-char 4)
- (action-key)
- (sit-for 0.2)
- (set-buffer "*Man 1 rm*")
- (should (looking-at "RM\(1\)")))
- (kill-buffer "*Man 1 rm*")))
+ (with-temp-buffer
+ (insert "rm (1) - remove")
+ (goto-char 4)
+ (with-mock
+ (mock (man "rm(1)") => t)
+ (action-key))))
;; Explicit buttons
(ert-deftest demo-factorial-test ()
diff --git a/test/hbut-tests.el b/test/hbut-tests.el
new file mode 100644
index 0000000..1da63c3
--- /dev/null
+++ b/test/hbut-tests.el
@@ -0,0 +1,148 @@
+;;; hbut-tests.el --- hbut unit tests -*- lexical-binding: t; -*-
+
+;; Author: Mats Lidell <matsl@gnu.org>
+;;
+;; Orig-Date: 28-Feb-21 at 22:52:00
+;;
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; See the "HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+
+;; Runs unit tests on some of the examples given in the DEMO file.
+
+;;; Code:
+
+(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 defal-path "${hyperb:dir}/\\1")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<defal-path DEMO>")
+ (goto-char 4)
+ (action-key)
+ (should (string= (concat hyperb:dir "DEMO") buffer-file-name))))
+ (progn
+ (kill-buffer "DEMO")
+ (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 defal-path-missing "${hyperb:dir}/\\1")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<defal-path-missing UNKNOWN-FILE>")
+ (goto-char 4)
+ (condition-case err
+ (action-key)
+ (error
+ (progn
+ (should (equal (car err) 'error))
+ (should (string-search "hpath:find" (cadr err)))))))
+ (ibtype:delete 'ibtypes::defal-path-missing)))
+
+(ert-deftest hbut-defil-it ()
+ (defil defil-path-it "<<<" ">>>" ".*" "${hyperb:dir}/\\&")
+ (unwind-protect
+ (with-temp-buffer
+ (insert "<<<DEMO>>>")
+ (goto-char 4)
+ (action-key)
+ (should (string= (concat hyperb:dir "DEMO") buffer-file-name)))
+ (progn
+ (kill-buffer "DEMO")
+ (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 71041ce..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)
@@ -189,16 +189,12 @@
;; man-apropos
(ert-deftest ibtypes::man-apropos-test ()
- (unwind-protect
- (with-temp-buffer
- (insert "rm (1) - remove")
- (goto-char 4)
- (ibtypes::man-apropos)
- (sit-for 0.2)
- (set-buffer "*Man 1 rm*")
- (should (looking-at "RM\(1\)")))
- (kill-buffer "*Man 1 rm*")))
-
+ (with-temp-buffer
+ (insert "rm (1) - remove")
+ (goto-char 4)
+ (with-mock
+ (mock (man "rm(1)") => t)
+ (ibtypes::man-apropos))))
;; klink
diff --git a/test/hpath-tests.el b/test/hpath-tests.el
new file mode 100644
index 0000000..525433c
--- /dev/null
+++ b/test/hpath-tests.el
@@ -0,0 +1,29 @@
+;;; hpath-tests.el --- unit tests for hpath -*- lexical-binding: t; -*-
+
+;; Author: Mats Lidell <matsl@gnu.org>
+;;
+;; Orig-Date: 28-Feb-21 at 23:26:00
+;;
+;; Copyright (C) 2021 Free Software Foundation, Inc.
+;; See the "HY-COPY" file for license information.
+;;
+;; This file is part of GNU Hyperbole.
+
+;;; Commentary:
+
+;; Unit tests for "../hpath.el"
+
+;;; Code:
+
+(require 'ert)
+(require 'hpath)
+
+(ert-deftest hpath:find-report-lisp-variable-path-name-when-not-exists ()
+ "hpath:find prints out the wrong filename on lisp variable expanded
filenames"
+ :expected-result :failed
+ (condition-case err
+ (hpath:find "${hyperb:dir}/UNKNOWNFILE")
+ (error (should (string-search (concat hyperb:dir "UNKNOWNFILE") (cadr
err))))))
+
+(provide 'hpath-tests)
+;;; hpath-tests.el ends here
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 781bbb5 17/50: Merge pull request #41 from rswgnu/update-git-repo-cache-interactively, (continued)
- [elpa] externals/hyperbole 781bbb5 17/50: Merge pull request #41 from rswgnu/update-git-repo-cache-interactively, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 22439e6 20/50: Add klink ref cmds, ebut:program and defiblink for programmatic creation, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole e999fc7 21/50: Stop man-apropos from matching to log file entries, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole cfc61a3 22/50: Eliminate a number of order-based byte-compilation warnings, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole e3544c8 23/50: Revert improper application of "Use \\0 for matched Nth substitution", Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole f1b2cba 24/50: Add dependency on hvar to resolve use of var:remove-all (#43), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 312c858 25/50: kexport.el - use lowercase HTML tags; mail-address ibtype allow trigger in any major mode, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole a3b9d6d 26/50: Merge branch 'master' of github.com:rswgnu/hyperbole, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 398f8e4 32/50: Add hypb:def-to-buffer to hypb.el for fast def copying, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole a831ef9 36/50: Fix bug #46606 by replacing hkey-define-key with hkey-global-set-key, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 8969fe9 43/50: Merge branch 'master' of hyperbole,
Stefan Monnier <=
- [elpa] externals/hyperbole c8947dd 47/50: Merge branch 'master' of hyperbole, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole db73cf7 19/50: Use \0 for matched Nth substitution (see also commit #c0e48fb3), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 1826307 27/50: Resolve bug#43644 where final double quote was trimmed from strings., Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole f38a8dd 28/50: Fix Hyrolo logicial searches; bug fixes; handle file:// URLs better, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 3469ea3 29/50: Release defil and defal simpler implicit button type create macros, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole 6a8154a 33/50: Add first unit tests (#46), Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole a44b392 34/50: Add UNIX shell error implicit button support, Stefan Monnier, 2021/03/17
- [elpa] externals/hyperbole aa6f2f6 38/50: Verify error message from hpath:find is correct (#50), Stefan Monnier, 2021/03/17
- [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