julia-emacs
julia-emacs copied to clipboard
Test failure for julia--test-end-of-defun-nested-2
I just tried to run the tests for 7a8c868, with Emacs-29.1, and I got the following error:
...
Test julia--test-end-of-defun-nested-2 backtrace:
ert-fail(((should (eq (point) (if (stringp "return fact(x)[ \n]+end"
(if (unwind-protect (setq value-657 (apply fn-655 args-656)) (setq f
(let (form-description-659) (if (unwind-protect (setq value-657 (app
(let ((value-657 'ert-form-evaluation-aborted-658)) (let (form-descr
(let* ((fn-655 #'eq) (args-656 (condition-case err (let ((signal-hoo
(progn (julia-mode) (insert "function f(x)\nfunction fact(n)\nif n =
(unwind-protect (progn (julia-mode) (insert "function f(x)\nfunction
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
(let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
(lambda nil (let ((temp-buffer (generate-new-buffer " *temp*" t))) (
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name julia--test-end-of-defun-nested-2 :do
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" "." "-l" "ert" "-l" "julia-mode-tests.el" "-f"
command-line()
normal-top-level()
Test julia--test-end-of-defun-nested-2 condition:
(ert-test-failed
((should
(eq
(point)
(if ... ... "return fact(x)[ \n]+end")))
:form
(eq 141 163)
:value nil))
FAILED 19/65 julia--test-end-of-defun-nested-2 (0.001256 sec) at julia-mode-tests.el:887
...
I tried with Emacs-28.2 and it works fine.
Cheers,
Simon
This problem seems to be the cause of the problem for this behavior in Guix
$ guix package -i emacs-ess
The following package will be installed:
emacs-ess 18.10.2-0.24da603
The following derivations will be built:
/gnu/store/fr1fp22rpdjc7k4my8b5bdvqpvf14s8y-emacs-julia-mode-0.4.drv
/gnu/store/y6gn2gkvnawzkf5n79ryswqcx6r809rn-emacs-ess-18.10.2-0.24da603.drv
building /gnu/store/fr1fp22rpdjc7k4my8b5bdvqpvf14s8y-emacs-julia-mode-0.4.drv...
| 'check' phasebuilder for `/gnu/store/fr1fp22rpdjc7k4my8b5bdvqpvf14s8y-emacs-julia-mode-0.4.drv' failed with exit code 1
build of /gnu/store/fr1fp22rpdjc7k4my8b5bdvqpvf14s8y-emacs-julia-mode-0.4.drv failed
View build log at '/var/log/guix/drvs/fr/1fp22rpdjc7k4my8b5bdvqpvf14s8y-emacs-julia-mode-0.4.drv.gz'.
guix package: error: build of `/gnu/store/fr1fp22rpdjc7k4my8b5bdvqpvf14s8y-emacs-julia-mode-0.4.drv' failed
$ echo $?
1
Here's the relevant part of the file /var/log/guix/drvs/fr/1fp22rpdjc7k4my8b5bdvqpvf14s8y-emacs-julia-mode-0.4.drv.gz' (complete file here)
Indenting region...
Indenting region...done
Test julia--test-end-of-defun-nested-2 backtrace:
signal(ert-test-failed (((should (eq (point) (if (stringp "return fa
ert-fail(((should (eq (point) (if (stringp "return fact(x)[ \n]+end"
(if (unwind-protect (setq value-247 (apply fn-245 args-246)) (setq f
(let (form-description-249) (if (unwind-protect (setq value-247 (app
(let ((value-247 'ert-form-evaluation-aborted-248)) (let (form-descr
(let* ((fn-245 #'eq) (args-246 (condition-case err (let ((signal-hoo
(progn (julia-mode) (insert "function f(x)\nfunction fact(n)\nif n =
(unwind-protect (progn (julia-mode) (insert "function f(x)\nfunction
(save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
(let ((temp-buffer (generate-new-buffer " *temp*" t))) (save-current
(lambda nil (let ((temp-buffer (generate-new-buffer " *temp*" t))) (
ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
ert-run-test(#s(ert-test :name julia--test-end-of-defun-nested-2 :do
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" "julia-mode-tests.el" "-f" "ert-run-tests-batch
command-line()
normal-top-level()
Test julia--test-end-of-defun-nested-2 condition:
(ert-test-failed
((should
(eq
(point)
(if ... ... "return fact(x)[ \n]+end")))
:form
(eq 141 163)
:value nil))
FAILED 14/43 julia--test-end-of-defun-nested-2 (0.000723 sec) at julia-mode-tests.el:584
passed 15/43 julia--test-escaped-strings-dont-terminate-string (0.000403 sec)
passed 16/43 julia--test-function-assignment-font-locking (0.000419 sec)
Indenting region...
Indenting region...done
@simonlegrand I confim the bug appears with Emacs 29.1 and not with 28.2. What happens? Consider the Julia code used by the test:
function f(x)
function fact(n)
if n == 0
return 1
else
return n * fact(n-1)
end
end
return fact(x)
end
Now, I use the symbol [X] to mark where the current point is.
function f(x)
function fact(n)
if n == 0[X]
return 1
else
return n * fact(n-1)
end
end
return fact(x)
end
The test julia--test-end-of-defun-nested-2 applies C-u 2 C-M-e, it results:
function f(x)
function fact(n)
if n == 0
return 1
else
return n * fact(n-1)
end
end
[x] return fact(x)
end
which is incorrect. It should be at the end. Therefore, julia-end-of-defun is buggy.
I guess the bug comes from this new snippet in 29.1, lisp/emacs-lisp/lisp.el from core:
;; At this point, point either didn't move (because we started
;; in between two defun's), or is at the end of a defun
;; (because we started in the middle of a defun).
(unless (zerop arg)
(when (setq success (beginning-of-defun-raw (- arg)))
(funcall end-of-defun-function))))
that replaced this old snippet in 28.x:
(unless (zerop arg)
(beginning-of-defun-raw (- arg))
(setq beg (point))
(funcall end-of-defun-function))))
The test
julia--test-end-of-defun-nested-2appliesC-u 2 C-M-e, it results: [...] which is incorrect. It should be at the end. Therefore,julia-end-of-defunis buggy.
Hum, I do not know... I observe the same behavior with an equivalent Python code using python-mode.
Thanks for the explanations!
Hum, I do not know... I observe the same behavior with an equivalent Python code using python-mode.
Doesn't it make sens since python-mode is also using end-of-defun-function?
Reported to upstream Emacs: #66763.
While waiting for Emacs to address this, I refactored our tests in #209 so they no longer error. Closing this, but if anyone wants it reopened please comment.