Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
2026-11-04 Mats Lidell <matsl@gnu.org>

* Makefile (verify-clean-test-run): Target that runs checks for left over
resources.
(test-ert): Use verify-clean-test-run.

* test/hywiki-tests.el (hywiki-tests--preserve-hywiki-mode): Store and reset
prior hywiki-directory on test completion. Resetting hywiki-mode recreates
the temporary hywiki-directory otherwise.

* test/hib-social-tests.el (hibtypes-repo-cache-does-not-exist-test):
* test/hyrolo-tests.el (hyrolo-tests--rename):
* test/hywiki-tests.el (hywiki-tests--edit): Avoid deleting files that do
not exist.

* test/hywiki-tests.el (hywiki-tests--kill-empty-wiki-buffer): Helper for
removing empty hywiki files and trigger a test error if it is not removed
when buffer is killed.
(hywiki-tests--add-path-link-v2):
(hywiki-tests--action-key-on-hywikiword-displays-page): Use
hywiki-tests--kill-empty-wiki-buffer.

2026-10-30 Mats Lidell <matsl@gnu.org>

* man/Lucide-LICENSE: Licens information for svg icons.
Expand Down
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,15 @@ test-ert:
(ert-batch-print-length nil) \
$(HYPB_ERT_BATCH_BT) (ert-batch-backtrace-right-margin 2048)) \
$(LOAD_TEST_ERT_FILES) $(HYPB_ERT_FAILURE) $(HYPB_ERT_BATCH))"
$(MAKE) verify-clean-test-run

# Verify that temporary files and directories are cleaned after a test run.
.PHONY: verify-clean-test-run
verify-clean-test-run:
@if [ -n "$$(find /tmp -name 'hywiki*' -print -quit 2>/dev/null)" ]; then \
echo "hywiki test folders not removed!"; \
exit 1; \
fi

# Run all tests by starting an Emacs that runs the tests interactively in windowed mode.
.PHONY: all-tests test-all
Expand Down
11 changes: 6 additions & 5 deletions test/hib-social-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Mats Lidell <matsl@gnu.org>
;;
;; Orig-Date: 20-Feb-21 at 23:24:00
;; Last-Mod: 3-Mar-24 at 11:28:17 by Mats Lidell
;; Last-Mod: 4-Nov-26 at 17:33:51 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand All @@ -14,7 +14,7 @@

;;; Commentary:

;;
;;

;;; Code:

Expand Down Expand Up @@ -63,8 +63,10 @@
(let ((hibtypes-git-repos-cache "not-existing-file"))
(unwind-protect
(mocklet (((hibtypes-git-build-repos-cache t) => t))
(should (hibtypes-git-build-or-add-to-repos-cache "project")))
(hy-delete-file-and-buffer hibtypes-git-repos-cache))))
(should (hibtypes-git-build-or-add-to-repos-cache "project"))
(should-not (file-exists-p hibtypes-git-repos-cache)))
(when (file-exists-p hibtypes-git-repos-cache)
(delete-file hibtypes-git-repos-cache)))))

(ert-deftest hibtypes-repo-cache-exist-test ()
"Verify project is added if cache exist."
Expand All @@ -84,4 +86,3 @@
;; End:

;;; hib-social-tests.el ends here

10 changes: 7 additions & 3 deletions test/hyrolo-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
;; Author: Mats Lidell <matsl@gnu.org>
;;
;; Orig-Date: 19-Jun-21 at 22:42:00
;; Last-Mod: 13-Oct-26 at 17:51:03 by Bob Weiner
;; Last-Mod: 4-Nov-26 at 17:26:40 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
Expand Down Expand Up @@ -2145,8 +2145,12 @@ Dependencies on the consult package are mocked."
(should (string-search "Your personal rolo file is now" cap)))
(should (file-exists-p new-file-backup))
(with-current-buffer (find-file new-file)
(should (looking-at-p "old-file"))))
(hy-delete-files-and-buffers (list old-file old-file-backup new-file new-file-backup)))))
(should (looking-at-p "old-file")))
(dolist (f (list old-file old-file-backup))
(should-not (file-exists-p f))))
(dolist (f (list old-file old-file-backup))
(delete-file f))
(hy-delete-files-and-buffers (list new-file new-file-backup)))))

(ert-deftest hyrolo-tests--edit-entry-edits-the-selected-match ()
"Verify `hyrolo-edit-entry' moves to the selected match and not a substring."
Expand Down
39 changes: 33 additions & 6 deletions test/hywiki-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,16 @@ Last two elements are optional.")
:test-num test-num
:before before :after after)))))
hywiki-tests--edit-string-pairs))
(let ((default-directory hywiki-directory))
(hy-delete-files-and-buffers
'("AI.org" "FAI.org" "Hi.org" "HiHo.org" "HyWiki.org" "HyWikiW.org" "HyWikiWord.org" "MyWikiWord.org" "Non.org" "Wiki.org")))))
(let ((files '("AI.org" "FAI.org" "Hi.org" "HiHo.org" "HyWiki.org" "HyWikiW.org" "HyWikiWord.org" "MyWikiWord.org" "Non.org" "Wiki.org")))
;; Remove buffers for files. We remove empty HyWiki buffers so
;; this will remove the file if it is empty.
(dolist (f files)
(let ((buf (get-file-buffer f)))
(when buf
(kill-buffer buf))))
;; Go over and remove the files that still exists
(dolist (f files)
(delete-file f)))))
(message "(hywiki-tests--edit): took %.2f seconds" test-time)))

(defun hywiki-tests--get-brace-strings (s)
Expand Down Expand Up @@ -288,10 +295,23 @@ around the call. This is for simulating the command loop."
(run-hooks 'post-self-insert-hook))
(run-hooks 'post-command-hook))))

(defun hywiki-tests--kill-empty-wiki-buffer (wikifile)
"Delete empty WIKIFILE by deleting its buffer.
Verify that the file is deleted. If it is still there raise a test error
and remove it."
(should (file-exists-p wikifile))
(let ((buf (get-file-buffer wikifile)))
(kill-buffer buf))
(unwind-protect
(should-not (file-exists-p wikifile))
(when (file-exists-p wikifile)
(delete-file wikifile))))

(defmacro hywiki-tests--preserve-hywiki-mode (&rest body)
"Restore hywiki-mode after running BODY."
(declare (indent 0) (debug t))
`(let ((prior-hywiki-mode hywiki-mode)
(prior-hywiki-directory hywiki-directory)
(hywiki-directory (file-name-as-directory (make-temp-file "hywiki" t)))
wiki-page)
(save-window-excursion
Expand All @@ -313,9 +333,14 @@ around the call. This is for simulating the command loop."
;; after `hywiki-mode' is enabled.
(setq wiki-page (cdr (hywiki-add-page "WikiWord" nil t)))
,@body)
(hy-delete-files-and-buffers (list wiki-page (hywiki-cache-default-file)))
(let ((buf (get-file-buffer wiki-page)))
(when buf
(kill-buffer buf))
(delete-file wiki-page))
(hy-delete-file-and-buffer (hywiki-cache-default-file))
(hywiki-tests--delete-hywiki-dir-and-buffer hywiki-directory)
(unless (eq hywiki-mode prior-hywiki-mode)
(setq hywiki-directory prior-hywiki-directory)
(hywiki-mode prior-hywiki-mode))))))))

(ert-deftest hywiki-tests--verify-preserve-hywiki-mode ()
Expand Down Expand Up @@ -364,7 +389,8 @@ around the call. This is for simulating the command loop."
(action-key)
(should (equal (cons 'page wikifile) (hywiki-get-referent "WikiPage"))))
(sit-for 0.01)
(hy-delete-file-and-buffer (expand-file-name wikifile hywiki-directory))))))
(hywiki-tests--kill-empty-wiki-buffer
(expand-file-name wikifile hywiki-directory))))))

(ert-deftest hywiki-tests--assist-key-on-hywikiword-displays-help ()
"Verify `assist-key' on a prefixed WikiWord, outside of hywiki-directory, displays help for the WikiWord link."
Expand Down Expand Up @@ -2050,7 +2076,8 @@ expected result."
(hywiki-add-path-link "HoRef" wikiHo 3)
(should (string= (concat (file-name-nondirectory wikiHo) ":L1:C2")
(cdr (hywiki-get-referent "HoRef"))))))
(hy-delete-files-and-buffers (list wikiHi wikiHo))))))
(hywiki-tests--kill-empty-wiki-buffer wikiHi)
(hy-delete-file-and-buffer wikiHo)))))

(ert-deftest hywiki-test--hywiki-mode ()
"Verify activating local and global `hywiki-mode'."
Expand Down
Loading