[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole c4325885a0 114/143: Add single file match tes
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole c4325885a0 114/143: Add single file match tests for some hyrolo hide and show commands (#458) |
Date: |
Mon, 19 Feb 2024 15:59:24 -0500 (EST) |
branch: externals/hyperbole
commit c4325885a0cda7671520ea5e72946e3938917d6f
Author: Mats Lidell <mats.lidell@lidells.se>
Commit: GitHub <noreply@github.com>
Add single file match tests for some hyrolo hide and show commands (#458)
Includes helper method for turning a buffer with invisible regions
into a plain string with the ellipses indicating where the invisible
portions for the file are.
---
ChangeLog | 9 +++
test/hyrolo-tests.el | 190 ++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 198 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 6b76a994c7..6d7b775e4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-30 Mats Lidell <matsl@gnu.org>
+
+* test/hyrolo-tests.el (hyrolo-tests--outline-as-string): Add helper that
+ returns how the buffer looks to the eye.
+ (hyrolo-tests--outline-hide-other)
+ (hyrolo-tests--outline-hide-sublevels)
+ (hyrolo-tests--hyrolo-outline-show-subtree): Add tests for hyrolo
+ outline show and hide commands.
+
2024-01-28 Bob Weiner <rsw@gnu.org>
* hyrolo.el (hyrolo-org-outline-level): Fix to not move point; was causing
errors
diff --git a/test/hyrolo-tests.el b/test/hyrolo-tests.el
index 064dff8708..fcf692f4fd 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: 28-Jan-24 at 15:51:04 by Bob Weiner
+;; Last-Mod: 30-Jan-24 at 14:24:16 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -1067,5 +1067,193 @@ body
(kill-buffer hyrolo-display-buffer)
(hy-delete-files-and-buffers hyrolo-file-list))))
+(defun hyrolo-tests--outline-as-string (&optional begin end)
+ "Return buffer content as a string with hidden text replaced by ellipses.
+The string contains what the outline actually looks like. This
+enables `string-match' tests for verifying text is hidden. With
+optional BEGIN and END only return that part of the buffer."
+ (if (not begin) (setq begin (point-min)))
+ (if (not end) (setq end (point-max)))
+ (save-excursion
+ (let ((result "")
+ in-invisible-section)
+ (goto-char begin)
+ (while (< (point) end)
+ (setq result
+ (concat result
+ (if (get-char-property (point) 'invisible)
+ (cond ((not in-invisible-section)
+ (setq in-invisible-section t)
+ "...")
+ (t nil))
+ (progn
+ (if in-invisible-section
+ (setq in-invisible-section nil))
+ (char-to-string (char-after))))))
+ (goto-char (1+ (point))))
+ result)))
+
+(ert-deftest hyrolo-tests--outline-hide-other ()
+ "Verify `hyrolo-outline-hide-other' hides except current body, parent and
top-level headings."
+ (let* ((org-file1 (make-temp-file "hypb" nil ".org"
hyrolo-tests--outline-content-org))
+ (hyrolo-file-list (list org-file1)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+
+ ;; First line
+ (should (= (point) 1))
+ (hyrolo-outline-hide-other)
+ (should (string-match-p
+ (concat "^===+" (regexp-quote "...\n* h-org 1...\n* h-org
2...\n") "$")
+ (hyrolo-tests--outline-as-string)))
+
+ ;; On first header
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (search-forward "* h-org 1")
+ (beginning-of-line)
+ (hyrolo-outline-hide-other)
+ (should (string= "...\n* h-org 1\nbody...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "* h-org 1\nbody...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string (point))))
+
+ ;; On second header
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (search-forward "** h-org 1.1")
+ (beginning-of-line)
+ (hyrolo-outline-hide-other)
+ (should (string= "...\n* h-org 1\n...\n** h-org 1.1\nbody...\n*
h-org 2...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "** h-org 1.1\nbody...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string (point)))))
+ (kill-buffer hyrolo-display-buffer)
+ (hy-delete-files-and-buffers hyrolo-file-list))))
+
+
+(ert-deftest hyrolo-tests--outline-hide-sublevels ()
+ "Verify `hyrolo-outline-hide-sublevels' hides everything but the top levels."
+ (let* ((org-file1 (make-temp-file "hypb" nil ".org"
hyrolo-tests--outline-content-org))
+ (hyrolo-file-list (list org-file1)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+
+ ;; First line
+ (should (= (point) 1))
+ (hyrolo-outline-hide-sublevels 1)
+ (should (= (point) 1))
+ (should (string= "...\n* h-org 1...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string)))
+
+ ;; On first header
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (search-forward "* h-org 1")
+ (beginning-of-line)
+ (hyrolo-outline-hide-sublevels 1)
+ (should (string= "...\n* h-org 1...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "* h-org 1...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string (point))))
+
+ ;; On second header
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (search-forward "** h-org 1.1")
+ (beginning-of-line)
+ (hyrolo-outline-hide-sublevels 1)
+ (should (string= "...\n* h-org 1...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "1...\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string (point))))
+
+ ;; First line - 2 levels
+ (goto-char (point-min))
+ (should (= (point) 1))
+ (hyrolo-outline-hide-sublevels 2)
+ (should (= (point) 1))
+ (should (string= "...\n* h-org 1...\n** h-org 1.1...\n** h-org
1.2...\n* h-org 2...\n** h-org-2.1...\n"
+ (hyrolo-tests--outline-as-string)))
+
+ ;; On first header - 2 levels
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (search-forward "* h-org 1")
+ (beginning-of-line)
+ (hyrolo-outline-hide-sublevels 2)
+ (should (string= "...\n* h-org 1...\n** h-org 1.1...\n** h-org
1.2...\n* h-org 2...\n** h-org-2.1...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "* h-org 1...\n** h-org 1.1...\n** h-org 1.2...\n*
h-org 2...\n** h-org-2.1...\n"
+ (hyrolo-tests--outline-as-string (point))))
+
+ ;; On second header - 2 levels
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (search-forward "** h-org 1.1")
+ (beginning-of-line)
+ (hyrolo-outline-hide-sublevels 2)
+ (should (string=
+ "...\n* h-org 1...\n** h-org 1.1...\n** h-org 1.2...\n*
h-org 2...\n** h-org-2.1...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "** h-org 1.1...\n** h-org 1.2...\n* h-org 2...\n**
h-org-2.1...\n"
+ (hyrolo-tests--outline-as-string (point)))))
+ (kill-buffer hyrolo-display-buffer)
+ (hy-delete-files-and-buffers hyrolo-file-list))))
+
+(ert-deftest hyrolo-tests--hyrolo-outline-show-subtree ()
+ "Verify `hyrolo-hyrolo-outline-show-subtree' shows everything after heading
at deeper levels."
+ (let* ((org-file1 (make-temp-file "hypb" nil ".org"
hyrolo-tests--outline-content-org))
+ (hyrolo-file-list (list org-file1)))
+ (unwind-protect
+ (progn
+ (hyrolo-grep "body")
+
+ ;; First line - show all
+ (should (= (point) 1))
+ (let ((original-look (hyrolo-tests--outline-as-string)))
+ (hyrolo-outline-hide-subtree)
+ (should (string-match-p
+ (concat "^===+" (regexp-quote "...") "\n$")
+ (hyrolo-tests--outline-as-string)))
+ (hyrolo-outline-show-subtree)
+ (should (string= original-look (hyrolo-tests--outline-as-string))))
+
+ ;; On first header
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (hyrolo-outline-hide-sublevels 1)
+ (search-forward "* h-org 1")
+ (beginning-of-line)
+ (let ((original-look (hyrolo-tests--outline-as-string)))
+ (hyrolo-outline-show-subtree)
+ (should (string= "...\n* h-org 1\nbody\n** h-org 1.1\nbody\n**
h-org 1.2\nbody\n*** h-org 1.2.1\nbody\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "* h-org 1\nbody\n** h-org 1.1\nbody\n** h-org
1.2\nbody\n*** h-org 1.2.1\nbody\n* h-org 2...\n"
+ (hyrolo-tests--outline-as-string (point))))
+ ;; Hide it again
+ (hyrolo-outline-hide-subtree)
+ (should (string= original-look (hyrolo-tests--outline-as-string))))
+
+ ;; On second level header
+ (goto-char (point-min))
+ (hyrolo-outline-show-all)
+ (hyrolo-outline-hide-sublevels 2)
+ (search-forward "** h-org 1.2")
+ (beginning-of-line)
+ (let ((original-look (hyrolo-tests--outline-as-string)))
+ (hyrolo-outline-show-subtree)
+ (should (string= "...\n* h-org 1...\n** h-org 1.1...\n** h-org
1.2\nbody\n*** h-org 1.2.1\nbody\n* h-org 2...\n** h-org-2.1...\n"
+ (hyrolo-tests--outline-as-string)))
+ (should (string= "** h-org 1.2\nbody\n*** h-org 1.2.1\nbody\n*
h-org 2...\n** h-org-2.1...\n"
+ (hyrolo-tests--outline-as-string (point))))
+ ;; Hide it again
+ (hyrolo-outline-hide-subtree)
+ (should (string= original-look
(hyrolo-tests--outline-as-string)))))
+ (kill-buffer hyrolo-display-buffer)
+ (hy-delete-files-and-buffers hyrolo-file-list))))
+
(provide 'hyrolo-tests)
;;; hyrolo-tests.el ends here
- [elpa] externals/hyperbole 19e51dfb0e 009/143: +* hyrolo.el (hyrolo-move-backward, hyrolo-move-forward): Fixes., (continued)
- [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
- [elpa] externals/hyperbole c4325885a0 114/143: Add single file match tests for some hyrolo hide and show commands (#458),
ELPA Syncer <=
- [elpa] externals/hyperbole 29fd0c8540 060/143: Update manual for "hsys-flymake.el" and add to hkey-alist, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 721ab10894 063/143: hsys-flymake.el improvements; hyrolo-tests.el improvements, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 270aab31c7 074/143: Matsl rsw fix more warnings reported by ci/cd (#438), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole d5a9715ef0 079/143: Fix hyrolo-org-mode to conditionalize ref to org-fold if unbound, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 34d4e22f28 087/143: Add tests with more file types and outline structure depth, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 2c67943e47 084/143: Fix a few warnings/bugs pointed out by the byte-compiler, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 2f2d51b816 088/143: Merge pull request #444 from rswgnu/matsl-rsw-add-tests-for-forward-and-backwards-using-multi-file-and-depth-structure, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 7ad3cabb7e 098/143: Revert "Remove skip guard on test that works in batch mode" (#448), ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 68564a0f0d 110/143: Enable HyRolo's extended reveal-mode used in *HyRolo* buffer, ELPA Syncer, 2024/02/19
- [elpa] externals/hyperbole 92ee298bf4 111/143: HyRolo - Fix major-mode and reveal-mode issues affecting *HyRolo*, ELPA Syncer, 2024/02/19