Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dumb-jump-goto-file-line-test failure against GNU Emacs 29.1 #442

Open
dogsleg opened this issue Nov 18, 2023 · 3 comments
Open

dumb-jump-goto-file-line-test failure against GNU Emacs 29.1 #442

dogsleg opened this issue Nov 18, 2023 · 3 comments

Comments

@dogsleg
Copy link

dogsleg commented Nov 18, 2023

Hi,

Thanks for your work on dumb-jump.

I'm getting the following error when run against GNU Emacs 29.1 from the Debian unstable archive:

passed   88/161  dumb-jump-go-var-let-test (0.041804 sec)
Test dumb-jump-goto-file-line-test backtrace:
  signal(mock-error (not-called ring-insert))
  mock-verify()
  #f(compiled-function () #<bytecode -0x108c38f63c4a627d>)()
  mock-protect((closure ((js-file . "/home/dogsleg/freedom/packaging/e
  (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake.js"))) (
  (closure (t) nil (let ((js-file (f-join test-data-dir-proj1 "src" "j
  ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
  ert-run-test(#s(ert-test :name dumb-jump-goto-file-line-test :docume
  ert-run-or-rerun-test(#s(ert--stats :selector t :tests ... :test-map
  ert-run-tests(t #f(compiled-function (event-type &rest event-args) #
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("-l" "package" "--eval" "(add-to-list 'package-direc
  command-line()
  normal-top-level()
Test dumb-jump-goto-file-line-test condition:
    (mock-error not-called ring-insert)
   FAILED   89/161  dumb-jump-goto-file-line-test (0.003110 sec) at test/dumb-jump-test.el:348

All other tests are fine.

@jobor
Copy link

jobor commented Mar 28, 2024

The failing test does

(mock (ring-insert * *))

and in Emacs 29, ring-insert is not called anymore.

dumb-jump-goto-file-line has the following bit at the start:

  (if (fboundp 'xref-push-marker-stack)
      (xref-push-marker-stack)
    (ring-insert find-tag-marker-ring (point-marker)))

In recent Emacs versions, xref-push-marker-stack is called. Thus, the test essentially checks the implementation of that function.

xref-push-marker-stack looks like this in Emacs 28:

(defun xref-push-marker-stack (&optional m)
  "Add point M (defaults to `point-marker') to the marker stack."
  (ring-insert xref--marker-ring (or m (point-marker))))

In Emacs 29, it's

(defun xref-push-marker-stack (&optional m)
  "Add point M (defaults to `point-marker') to the marker stack.
Erase the stack slots following this one."
  (xref--push-backward (or m (point-marker)))
  (let ((history (xref--get-history)))
    (dolist (mk (cdr history))
      (set-marker mk nil nil))
    (setcdr history nil)))

and

(defun xref--push-backward (m)
  "Push marker M onto the backward history stack."
  (let ((history (xref--get-history)))
    (unless (equal m (caar history))
      (push m (car history)))))

Long story short: ring-insert is not called anymore in Emacs 29. The test is faulty.

We could fix the issue like this:

(ert-deftest dumb-jump-goto-file-line-test ()
  (let ((js-file (f-join test-data-dir-proj1 "src" "js" "fake.js")))
    (with-mock
     (when (version< emacs-version "29")
       (mock (ring-insert * *)))
     (dumb-jump-goto-file-line js-file 3 0)
     (should (string= (buffer-file-name) js-file))
     (should (= (line-number-at-pos) 3)))))

or turn the mock into a stub or remove that line alltogether.

@jobor
Copy link

jobor commented Mar 28, 2024

cc @jacktasia who added this quite some time ago. I'm sure you remember as if you added this yesterday... ;) but is the mock call supposed to prevent side-effects or can it be removed? Or should it be replaced with something else for Emacs 29?

@jacktasia
Copy link
Owner

@jobor Honestly I can't really remember, but I think the last example where you sniff the emacs-version is necessary since we definitely support older versions than that

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

No branches or pull requests

3 participants