Skip to content

hywiki-tests--referent-test - Remove referent caching from macro#911

Merged
rswgnu merged 2 commits intomasterfrom
rsw
Mar 21, 2026
Merged

hywiki-tests--referent-test - Remove referent caching from macro#911
rswgnu merged 2 commits intomasterfrom
rsw

Conversation

@rswgnu
Copy link
Owner

@rswgnu rswgnu commented Mar 21, 2026

  • hywiki-tests--referent-cache-test - Add to test saving and reloading a bookmark referent from cache.

  • hywiki-tests--save-referent-org-id - Fix to call 'hywiki-add-referent' around 'hywiki-add-org-id' since interactive runs of this test without that wrapper return nil for comparison to the expected (cons 'org-id "generated-org-id".

rswgnu added 2 commits March 21, 2026 14:09
hywiki-tests--referent-cache-test - Add to test saving and reloading
a bookmark referent from cache.

hywiki-tests--save-referent-org-id - Fix to call 'hywiki-add-referent'
around 'hywiki-add-org-id' since interactive runs of this test without
that wrapper return nil for comparison to the expected
(cons 'org-id "generated-org-id".
@rswgnu rswgnu merged commit 05252eb into master Mar 21, 2026
4 checks passed
(goto-char (point-max))
(hywiki-add-org-id wiki-word-non-page)
(hywiki-get-referent wiki-word-non-page)))
(hywiki-add-referent wiki-word-non-page
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is interesting. Adding the referent using hywiki-add-referent is basically what the test is about so doing that explicitly will not test the right thing. The tests purpose is to verify that hywiki-add-org-id will call hywiki-add-referent here.

With this version:

; TEST: Old test for checking verification
(ert-deftest hywiki-tests--save-referent-org-id-alt ()
  "Verify saving and loading a referent org id works."
  (hywiki-tests--referent-test-with-cache
    (cons 'org-id "generated-org-id")
    (save-excursion
      (let ((filea (make-temp-file "hypb" nil ".org")))
        (unwind-protect
            (with-current-buffer (find-file filea)
              (hywiki-tests--insert "* header\n")
              (mocklet (((org-id-get) => "generated-org-id"))
                (goto-char (point-max))
                ;; 1 - (hywiki-get-referent-hasht)
                ;; 2 - (should-not (hywiki-get-referent wiki-word-non-page))
	        (hywiki-add-org-id wiki-word-non-page)))
	  (hy-delete-file-and-buffer filea))))))

When I run it in my development Emacs it fails as you have seen at your end but when I run it in a clean docker environment also interactively it works.

Even more confusing is that if I uncomment either or line beinning with ";; 1" or ";; 2" the test does also work in my development Emacs. (And continues to work in docker.)

And if that was not enough - In the commited version the call to hywiki-add.-org-id will actually call hywiki-add-referent before hywiki-add-referent is called from the test code. (Since the return value of hywiki-add-org-id comes from the call to hywiki-add-referent. Bah.)

Anyway - I think having the call to hywiki-add-referent in the test is misleading. We need to figure out why this is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants