[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 29dda66c3e 059/143: Merge remote branch 'rsw'
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 29dda66c3e 059/143: Merge remote branch 'rsw' of hyperbole into rsw |
Date: |
Mon, 19 Feb 2024 15:58:55 -0500 (EST) |
branch: externals/hyperbole
commit 29dda66c3e14bf38a4852653aa4beb73f28f05ae
Merge: e67d0f733f a08fd67af3
Author: bw <rsw@gnu.org>
Commit: bw <rsw@gnu.org>
Merge remote branch 'rsw' of hyperbole into rsw
---
ChangeLog | 16 ++-
test/hyrolo-tests.el | 289 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 302 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2f41b2d8d2..fda5fffae2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,7 +28,21 @@
for the Assist Key when on a Hyperbole button.
hmouse-drv.el (hkey-help): Update to display proper Assist Key help.
-2024-01-02 Mats Lidell <matsl@gnu.org>
+2023-01-02 Mats Lidell <matsl@gnu.org>
+
+* test/hyrolo-tests.el (hyrolo-tests--level-number)
+ (hyrolo-tests--generate-header-contents-for-tests)
+ (hyrolo-tests--gen-outline): Add helper for constructing org files for
+ tests.
+ (hyrolo-tests--outline-next-visible-header)
+ (hyrolo-tests--tab-through-matches)
+ (hyrolo-tests--outline-hide-show-heading)
+ (hyrolo-tests--outline-up-header, hyrolo-tests--edit-entry)
+ (hyrolo-tests--outline-next-visible-header-two-sections): Add test for
+ working with hyrolo matches.
+ (hyrolo-tests--get-file-list-change)
+ (hyrolo-tests--get-file-list-wrong-suffice): Add hyrolo tests for
+ get-file-list.
* test/hypb-ert-tests.el (hypb-ert-tests--def-at-p)
(hypb-ert-tests--edebug-is-called): Add tests for hypb-ert.
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index 68dac7f64f..9856a93147 100644
--- a/test/hyrolo-tests.el
+++ b/test/hyrolo-tests.el
@@ -3,7 +3,7 @@
;; Author: Mats Lidell <matsl@gnu.org>
;;
;; Orig-Date: 19-Jun-21 at 22:42:00
-;; Last-Mod: 30-Dec-23 at 23:22:54 by Bob Weiner
+;; Last-Mod: 1-Jan-24 at 22:38:40 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -24,6 +24,7 @@
(require 'hyrolo-demo)
(require 'hy-test-helpers "test/hy-test-helpers")
(require 'hib-kbd)
+(require 'kotl-mode)
(require 'with-simulated-input)
(declare-function hy-test-helpers:consume-input-events "hy-test-helpers")
@@ -42,7 +43,7 @@
(hyrolo-add "a/b")
(hyrolo-add "a/b/c")
(beginning-of-line)
- (should (looking-at-p "\*\*\* c")))
+ (should (looking-at-p "\\*\\*\\* c")))
(hy-delete-file-and-buffer hyrolo-file))))
(ert-deftest hyrolo-demo-search-work ()
@@ -449,5 +450,289 @@ Match a string in the second cell."
(kill-buffer hyrolo-display-buffer)
(delete-directory temporary-file-directory))))
+(ert-deftest hyrolo-tests--get-file-list-change ()
+ "Verify a change to hyrolo-file-list is noticed by hyrolo-get-file-list."
+ (let* ((tmp-file (make-temp-file "hypb" nil ".org"))
+ (hyrolo-file-list (list tmp-file)))
+ (unwind-protect
+ (let ((hl (hyrolo-get-file-list)))
+ (should (= 1 (length hl)))
+ (should (string= (car hl) tmp-file)))
+ (hy-delete-file-and-buffer tmp-file))))
+
+(ert-deftest hyrolo-tests--get-file-list-wrong-suffice ()
+ "Verify files need to have the proper suffix in hyrolo-file-list."
+ (let ((tmp-file (make-temp-file "hypb" nil)))
+ (unwind-protect
+ (should-error
+ (let ((hyrolo-file-list (list tmp-file)))
+ ()))
+ (hy-delete-file-and-buffer tmp-file))))
+
+;; Outline movement tests
+(defun hyrolo-tests--level-number (section depth)
+ "Generate the number for the SECTION at DEPTH.
+
+The format is the section followed by the depth given by the
+sequence up to depth starting from 2.
+ Depth 1: section
+ Depth <depth>: section.2.3.4..<depth>"
+ (let (result)
+ (dotimes (d depth)
+ (setq result
+ (if (= 0 d)
+ (number-to-string section)
+ (concat result
+ "."
+ (number-to-string (+ 1 d))))))
+ result))
+
+(defun hyrolo-tests--generate-header-contents-for-tests (header section body
depth)
+ "Generate the HEADER and BODY contents for the SECTION with DEPTH."
+ (let (result)
+ (dotimes (d depth)
+ (setq result
+ (concat result
+ (make-string (1+ d) ?*) " " header " "
(hyrolo-tests--level-number section (1+ d)) "\n"
+ body " " (hyrolo-tests--level-number section (1+ d))
"\n")))
+ result))
+
+(defun hyrolo-tests--gen-outline (header sections body depth)
+ "Generate an outline structure suitable for hyrolo outline test.
+
+The contents is constructed with an outline HEADER and BODY text.
+Each is repeated in SECTIONS with one set of hierarchical headers
+to the specified DEPTH.
+
+Example:
+ * header 1
+ body 1
+ ** header 2
+ body 1.2
+ [...]
+ * header <sections>
+ body <sections>
+ ** header <sections>.2
+ body <section>.2
+ [...]"
+ (let (result)
+ (dotimes (section sections)
+ (setq result
+ (concat result
+ (hyrolo-tests--generate-header-contents-for-tests header
(1+ section) body depth))))
+ result))
+
+(ert-deftest hyrolo-tests--outline-next-visible-header ()
+ "Verify movement to next visible header."
+ (let* ((org-file (make-temp-file "hypb" nil ".org"
+ (hyrolo-tests--gen-outline "header" 2
"body" 2)))
+ (hyrolo-file-list (list org-file)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+ (should (string= "*HyRolo*" (buffer-name)))
+
+ ;; Move down
+ (should (looking-at-p "==="))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\* header 1"))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\*\\* header 1\\.2"))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\* header 2"))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\*\\* header 2\\.2"))
+ (should (hact 'kbd-key "n"))
+ (should (eobp))
+
+ ;; Move back up
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\*\\* header 2\\.2"))
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\* header 2"))
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\*\\* header 1\\.2"))
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\* header 1"))
+ (should (hact 'kbd-key "p"))
+
+ ;; BUG: This fails in Emacs 29 and 30
+ ;; This is the expected behavior that works in Emacs 27 and 28.
+ ;; (should (looking-at-p "==="))
+ ;; (should (bobp))
+ ;; This is what we get
+ (should (looking-at-p "@loc>"))
+ (should (= 2 (line-number-at-pos))))
+ (kill-buffer "*HyRolo*")
+ (hy-delete-file-and-buffer org-file))))
+
+(ert-deftest hyrolo-tests--outline-up-header ()
+ "Verify movement from sub header to next header one level above."
+ (let* ((org-file (make-temp-file "hypb" nil ".org"
+ (hyrolo-tests--gen-outline "header" 2
"body" 3)))
+ (hyrolo-file-list (list org-file)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+ (should (string= "*HyRolo*" (buffer-name)))
+
+ ;; Move to last header
+ (goto-char (point-max))
+ (forward-line -2)
+ (should (looking-at-p "^\\*\\*\\* header 2\\.2\\.3$"))
+ (should (hact 'kbd-key "u"))
+ (should (looking-at-p "^\\*\\* header 2\\.2$"))
+ (should (hact 'kbd-key "u"))
+ (should (looking-at-p "^\\* header 2$"))
+ (should-error (hact 'kbd-key "u")))
+ (kill-buffer "*HyRolo*")
+ (hy-delete-file-and-buffer org-file))))
+
+(ert-deftest hyrolo-tests--outline-next-visible-header-two-sections ()
+ "Verify movement to next visible header with two sections."
+ (let* ((org-file1 (make-temp-file "hypb" nil ".org"
+ (hyrolo-tests--gen-outline "header-a" 1
"body-a" 2)))
+ (org-file2 (make-temp-file "hypb" nil ".org"
+ (hyrolo-tests--gen-outline "header-b" 1
"body-b" 2)))
+ (hyrolo-file-list (list org-file1 org-file2)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+ (should (string= "*HyRolo*" (buffer-name)))
+
+ ;; Move down
+ (should (looking-at-p "==="))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\* header-a 1$"))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\*\\* header-a 1\\.2$"))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\* header-b 1$"))
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^\\*\\* header-b 1\\.2$"))
+ (should (hact 'kbd-key "n"))
+ (should (eobp))
+
+ ;; Move back up
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\*\\* header-b 1\\.2$"))
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\* header-b 1$"))
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\*\\* header-a 1\\.2$"))
+ (should (hact 'kbd-key "p"))
+ (should (looking-at-p "^\\* header-a 1$"))
+ (should (hact 'kbd-key "p"))
+
+ ;; BUG: This fails in Emacs 29 and 30
+ ;; This is the expected behavior that works in Emacs 27 and 28.
+ ;; (should (looking-at-p "==="))
+ ;; (should (bobp))
+ ;; This is what we get
+ (should (looking-at-p "@loc>"))
+ (should (= 2 (line-number-at-pos))))
+ (kill-buffer "*HyRolo*")
+ (hy-delete-file-and-buffer org-file1)
+ (hy-delete-file-and-buffer org-file2))))
+
+(ert-deftest hyrolo-tests--outline-hide-show-heading ()
+ "Verify hiding and showing headers."
+ (let* ((org-file (make-temp-file "hypb" nil ".org"
+ (hyrolo-tests--gen-outline "header" 2
"body" 2)))
+ (hyrolo-file-list (list org-file)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+ (should (string= "*HyRolo*" (buffer-name)))
+
+ ;; Hide first line hides whole section
+ (should (looking-at-p "==="))
+ (should (hact 'kbd-key "h"))
+ (end-of-line)
+ (should (get-char-property (point) 'invisible))
+ (goto-char (point-min))
+ (should (hact 'kbd-key "a"))
+ (should (looking-at-p "^===+$"))
+
+ (should (hact 'kbd-key "n"))
+ (should (looking-at-p "^* header 1$"))
+ ;; BUG: This gives an unexpected error when trying to hide
+ ;; org-fold-region: Calling ‘org-fold-core-region’ with missing SPEC
+ (should-error (hact 'kbd-key "h"))
+ ;; Expected is not to fail on hiding the header.
+ ;; Seems to be version dependent for 29 and 30!?
+
+ ;; TBC - When bug above is resolved or understood better.
+ )
+ (kill-buffer "*HyRolo*")
+ (hy-delete-file-and-buffer org-file))))
+
+(ert-deftest hyrolo-tests--tab-through-matches ()
+ "Verify tabbing through search matches."
+ (let* ((org-file (make-temp-file "hypb" nil ".org"
+ (hyrolo-tests--gen-outline "header" 2
"body" 2)))
+ (hyrolo-file-list (list org-file)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+ (should (string= "*HyRolo*" (buffer-name)))
+
+ ;; Search Down
+ (should (looking-at-p "==="))
+ (should (hact 'kbd-key "TAB"))
+ (should (looking-at-p "^body 1$"))
+ (should (hact 'kbd-key "TAB"))
+ (should (looking-at-p "^body 1\\.2"))
+ (should (hact 'kbd-key "TAB"))
+ (should (looking-at-p "^body 2$"))
+ (should (hact 'kbd-key "TAB"))
+ (should (looking-at-p "^body 2\\.2"))
+ (should-error (hact 'kbd-key "TAB"))
+ (should (looking-at-p "^body 2\\.2"))
+
+ ;; Search Up
+ (should (hact 'kbd-key "<backtab>"))
+ (should (looking-at-p "^body 2$"))
+ (should (hact 'kbd-key "<backtab>"))
+ (should (looking-at-p "^body 1\\.2"))
+ (should (hact 'kbd-key "<backtab>"))
+ (should (looking-at-p "^body 1$"))
+ (should-error (hact 'kbd-key "<backtab>")))
+ (kill-buffer "*HyRolo*")
+ (hy-delete-file-and-buffer org-file))))
+
+(ert-deftest hyrolo-tests--edit-entry ()
+ "Verify {e} brings up entry in new window."
+ (let* ((org-file (make-temp-file "hypb" nil ".org"
+ (hyrolo-tests--gen-outline "header" 1
"body" 2)))
+ (hyrolo-file-list (list org-file)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+ (should (string= "*HyRolo*" (buffer-name)))
+
+ ;; Search Down
+ (should (looking-at-p "==="))
+ (should (hact 'kbd-key "TAB"))
+ (should (looking-at-p "^body 1$"))
+
+ ;; Edit record
+ (let ((revisit-normally (concat "y" (if noninteractive " RET"))))
+ (with-simulated-input revisit-normally
+ (should (hact 'kbd-key "e"))))
+ (should (string= (buffer-name) (file-name-nondirectory org-file)))
+ (should (looking-at-p "^body 1$"))
+
+ ;; Edit next record
+ (switch-to-buffer "*HyRolo*")
+ (should (hact 'kbd-key "TAB"))
+ (should (looking-at-p "^body 1\\.2$"))
+ (should (hact 'kbd-key "e"))
+ (should (string= (buffer-name) (file-name-nondirectory org-file)))
+ (should (looking-at-p "^body 1\\.2$"))
+ )
+ (kill-buffer "*HyRolo*")
+ (hy-delete-file-and-buffer org-file))))
+
(provide 'hyrolo-tests)
;;; hyrolo-tests.el ends here
- [elpa] externals/hyperbole 966605b7a3 028/143: hkey-window-link, {M-o w} - invert the meaning of prefix arg, (continued)
- [elpa] externals/hyperbole 966605b7a3 028/143: hkey-window-link, {M-o w} - invert the meaning of prefix arg, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 7adb441c0e 036/143: kotl-mode - fix kill and yank commands not moving to valid pos first, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 2187b3522b 049/143: Add test for hiding and showing, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole e995fc8905 050/143: Add test for moving between two sections, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 7657601745 043/143: hyrolo-mode-map - bind {n} and {C-c C-n} to the same command, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole e67d0f733f 058/143: Fix edebugging of tests that have not been previously defined, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole fc6df9d652 056/143: Merge remote branch 'rsw' into rsw, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole acec506a2c 061/143: Require hbut so defib is defined, needed for compiling (#430), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 12e714d824 072/143: Move xref extensions to new "hsys-xref.el". Add ibut API extensions, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole a08fd67af3 057/143: Merge pull request #427 from rswgnu/matsl-rsw-add-hyrolo-tests, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 29dda66c3e 059/143: Merge remote branch 'rsw' of hyperbole into rsw,
ELPA Syncer <=
- [elpa] externals/hyperbole 19e51dfb0e 009/143: +* hyrolo.el (hyrolo-move-backward, hyrolo-move-forward): Fixes., ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 564c147587 046/143: Add tests for hypb-ert (#429), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 97f4e12386 023/143: hui--link-possible-types - ensure only 1 specific type per test, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole badf1e5281 027/143: Merge remote branch 'rsw' into rsw, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 00d5af41be 039/143: Add Smart Key support for rsw's new ert-results.el package, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 586a568992 054/143: Update ChangeLog, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 84fe259016 064/143: hyrolo.el - Fix *HyRolo* {n} and {p} movement commands, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 7a5e3071b6 097/143: Merge branch 'rsw' of hyperbole into rsw, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole ac7d6ed874 106/143: Remove unused function (#455), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 678f62a79d 105/143: hyperbole-web-search: when service is a func, let it prompt for term, ELPA Syncer, 2024/02/19