Skip to content
Closed
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
18 changes: 18 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
2026-02-08 Mats Lidell <[email protected]>

* test/hywiki-tests.el (hywiki-tests--word-at): Require wikiword to
exist. Use the wikiword range for verifying the highlighting. Avoids
differences in how wikiwords are found and lets hywiki-word-at decide.
(hywiki-tests--word-face-at-p): Drop interactive requirement.
(hywiki-tests--run-test-case): Don't adjust newpos to buffer
limits. It is set by the test specification.
(hywiki-tests--wikiword-identified-in-emacs-lisp-mode): Mark as
expected failed. There are problems with how the WikiWords are
identified that causes the test to fail.
(hywiki-tests--publish-special-cases): Remove error comments and
enable old failing test.
(hywiki-tests--verify-removal-of-delimiter-updates-face): Adjust test
case and remove expected failed.
(hywiki-tests--maybe-highlight-page-names): Erase buffer between tests
and enable test as expected success.

2026-02-07 Bob Weiner <[email protected]>

* test/hywiki-tests.el (hywiki-tests--verify-removal-of-delimiter-updates-face):
Expand Down
58 changes: 26 additions & 32 deletions test/hywiki-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -1114,15 +1114,10 @@ WikiWord#Csection-subsection

(dolist (v `(("WikiWord WikiWord" . ,(format "%s %s" href href))
("\"WikiWord WikiWord\"" . ,(format "\"%s %s\"" href href))
;; ^ Missing a space!?
("WikiWord Text WikiWord" . ,(format "%s Text %s" href href))
("\"WikiWord Text WikiWord\"" . ,(format "\"%s Text %s\"" href href))
;; ^ Missing " Text "
("WikiWord WikiWord WikiWord" . ,(format "%s %s %s" href href href))
;; !! TODO FIXME
;; (cons "\"WikiWord WikiWord WikiWord\"" (format "\"%s %s %s\"" href href href))
;; ^ Crashes due to (wrong-type-argument integer-or-marker-p nil) caused by buffer-substring-no-properties(nil nil)
))
("\"WikiWord WikiWord WikiWord\"" . ,(format "\"%s %s %s\"" href href href))))
(let ((input (car v))
(regex-output (cdr v))
(revert-without-query '(".*")))
Expand Down Expand Up @@ -1607,7 +1602,6 @@ See gh#rswgnu/hyperbole/669."

(ert-deftest hywiki-tests--word-face-at-p ()
"Verify `hywiki-word-face-at-p'."
(skip-unless (not noninteractive))
(hywiki-tests--preserve-hywiki-mode
(hywiki-mode nil)
(hywiki-tests--insert "WikiWor")
Expand Down Expand Up @@ -1640,12 +1634,14 @@ comparison with expected overlays stable."
"Non-nil to perform face validation of WikiWord.")

(defun hywiki-tests--word-at ()
"Test if there is a HyWikiWord reference at point with a referent.
Choose what test to perform based on value of `hywiki-tests--with-face-test'."
(when (hywiki-referent-exists-p)
(if hywiki-tests--with-face-test
(hywiki-highlighted-word-at)
(hywiki-word-at))))
"Choose what test to perform based on value of `hywiki-tests--with-face-test'."
(let* ((range (hywiki-word-at :range)))
(when (hywiki-get-referent (car range))
(when hywiki-tests--with-face-test
(save-excursion
(goto-char (round (/ (+ (cadr range) (caddr range)) 2.0)))
(should (equal range (hywiki-highlighted-word-at :range)))))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we verify that the highlighted range is the same as what is returned by hywiki-word-at. Point is though adjusted to be within the range since hywiki-word-at does accept point to be outside of the range and still finds the wikiword.

(car range))))

(defun hywiki-tests--verify-hywiki-word (step expected)
"Verify that `hywiki-word-at' returns t if a wikiword is EXPECTED.
Expand Down Expand Up @@ -1691,30 +1687,29 @@ point when the function is called."
(let ((origin (point)))
(ert-info ((format "Test case => '%s'" test-case))
(dolist (steps test-case)
(let ((step (car steps))
(let ((step (car steps))
(vfy (cdr steps)))
(cond ((stringp step)
(dolist (ch (string-to-list step))
(dolist (ch (string-to-list step))
(hywiki-tests--command-execute #'self-insert-command 1 ch))
(save-excursion
(save-excursion
(goto-char (1- (point)))
(hywiki-tests--verify-hywiki-word step vfy)))
((integerp step)
(let ((forward (> step 0)))
(dotimes (_ (abs step))
(if forward
(hywiki-tests--command-execute #'delete-forward-char 1)
(hywiki-tests--command-execute #'delete-forward-char 1)
(hywiki-tests--command-execute #'backward-delete-char 1)))
(hywiki-tests--verify-hywiki-word step vfy)))
((and (symbolp step) (string-prefix-p "p" (symbol-name step)))
(let* ((pos (string-to-number (substring (symbol-name step) 1)))
(newpos (max (min (+ origin (1- pos)) (point-max))
(point-min))))
((and (symbolp step) (string-prefix-p "p" (symbol-name step)))
(let* ((pos (string-to-number (substring (symbol-name step) 1)))
(newpos (+ origin (1- pos))))
(when (or (> (point-min) newpos) (< (point-max) newpos))
(ert-fail (format "New point: '%s' is outside of buffer" newpos)))
(goto-char newpos))
(hywiki-tests--verify-hywiki-word step vfy))
(t (ert-fail (format "Unknown step: '%s' in WikiWord verification" step)))))))))
(hywiki-tests--verify-hywiki-word step vfy))
(t (ert-fail (format "Unknown step: '%s' in WikiWord verification" step)))))))))

(defconst hywiki-tests--wikiword-step-check
'(
Expand Down Expand Up @@ -1835,6 +1830,7 @@ face is verified during the change."

(ert-deftest hywiki-tests--wikiword-identified-in-emacs-lisp-mode ()
"Verify WikiWord is identified when surrounded by delimiters in `emacs-lisp-mode'."
:expected-result :failed
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the test case that fails.

With hywiki-mode :all and WikiWord page created this in emacs-lisp-mode below

;; [[WikiWord]]

There WikiWord is not highlighted but hywiki-word-at says it is a WikiWord. Is that the expected behavior? It seems wrong. It can be reproduced manually.

Ideally tests with or without face check should behave the same.

(hywiki-tests--preserve-hywiki-mode
(emacs-lisp-mode)
(let* ((hsys-org-enable-smart-keys t)
Expand Down Expand Up @@ -1930,16 +1926,15 @@ face is verified during the change."
(ert-deftest hywiki-tests--verify-removal-of-delimiter-updates-face ()
"Verify WikiWord highlight face change when adding/removing a delimiter."
(hywiki-tests--preserve-hywiki-mode
(let ((hywiki-tests--with-face-test t)
(hi-page (cdr (hywiki-add-page "Hi"))))
(let ((page (cdr (hywiki-add-page "Hi"))))
(unwind-protect
(dolist (testcase
'((("\"Hi#a b c\"" . "Hi#a b c") (p3 . "Hi#a b c")
(p11) (-1) (p3 . "Hi#a") (p10) ("\" ") (p3 . "Hi#a b c"))
(dolist (testcase
'((("\"Hi#a b c\"" . t) (p3 . "Hi#a b c")
(p11) (-1) (p3 . "Hi#a") (p10) ("\"" . "Hi#a b c"))
(("(Hi#s n)" . "Hi#s n") (-1) (p3 . "Hi#s") (p8) (")" . "Hi#s n"))))
(erase-buffer)
(erase-buffer)
(hywiki-tests--run-test-case testcase))
(hy-delete-file-and-buffer hi-page)))))
(hy-delete-file-and-buffer page)))))

(ert-deftest hywiki-tests--wikiword-yanked-with-extra-words ()
"Verify that a yanked in WikiWord highlights properly."
Expand Down Expand Up @@ -2016,7 +2011,6 @@ face is verified during the change."
Start and stop point of all highlighted regions in the buffer, as
computed by `hywiki-tests--hywiki-face-regions', are compared to the
expected result."
:expected-result :failed
(hywiki-tests--preserve-hywiki-mode
(let* ((wikiword (cdr (hywiki-add-page "WiWo")))
input
Expand All @@ -2028,12 +2022,12 @@ expected result."
("WiWo text WiWo" . ((1 . 5) (11 . 15)))
("\"WiWo\"" . ((2 . 6)))
("\"WiWo text\"" . ((2 . 6)))
;; Failing tests below.
("\"WiWo WiWo\"" . ((2 . 6) (7 . 11)))
("\"WiWo text WiWo\"" . ((2 . 6) (12 . 16)))
("\"WiWo WiWo WiWo\"" . ((2 . 6) (7 . 11) (12 . 16)))))
(setq input (car v)
overlay-regions (cdr v))
(erase-buffer)
(hywiki-tests--insert input)
(hywiki-maybe-highlight-references (point-min) (point-max))
;; Verify Overlays
Expand Down