Subject: bug#76381: todo-test-add-and-delete-file fails on Ubuntu 24.10

From: Stephen Berman <[email-masked]>
Date: Thu, 20 Feb 2025 14:33:24 +0100

On Mon, 17 Feb 2025 17:14:19 -0800 Paul Eggert <[email-masked]> wrote:

> Currently (commit 9cedb434ee390a30a690e9f979428c5735cb88e5) the
> todo-mode-tests fail for me. This failure has been happening for a while and I
> finally got up the energy to report it today.
>
> I see the following failure symptoms on Ubuntu 24.10, running on a ZFS file
> system mounted with the options rw, noatime, xattr, posixacl, and
> casesensitive.
>
>   $ cd test
>   $ make lisp/calendar/todo-mode-tests
>   make[1]: Entering directory
>   '/home/eggert/src/gnu/emacs/static-checking/test'
>     GEN      lisp/calendar/todo-mode-tests.log
>   Running 42 tests (2025-02-17 17:04:52-0800, selector ‘(not (or (tag
>   :unstable) (tag :nativecomp)))’)
>   Enter a non-existing file name:
>
> ... and the test hangs, waiting for me to type a file name I guess.

I cannot reproduce this, either on the master, emacs-30 or emacs-29
branch (on a GNU/Linux system with ext4 file system).  For one thing,
when I run the equivalent of `make lisp/calendar/todo-mode-tests' (I
build out-of-tree) I get:

steve [ ~/build/emacs-master/test ]$ make ~/src/emacs/emacs-master/test/lisp/calendar/todo-mode-tests
make: *** No rule to make target '/home/steve/src/emacs/emacs-master/test/lisp/calendar/todo-mode-tests'.  Stop.

But when I run `make
~/src/emacs/emacs-master/test/lisp/calendar/todo-mode-tests.log' all
tests are run and all pass (on all three emacs branches).

> Of course a test like this shouldn't read from standard input.

Indeed, and the test uses `todo-test--add-file', whose doc string says:
"This provides a noninteractive API for todo-add-file for use in
automatic testing."  So I'm mystified as to why you get the hang above
and the error below.  From backtrace of the latter it looks like
`todo-read-category' from todo-mode.el is being used instead of the
mocked version defined in `todo-test--add-file', but I don't see how
that could have happened.

Steve Berman

> If I run this command instead:
>
>   $ make lisp/calendar/todo-mode-tests </dev/null
>
> I get a failure. Here is what I see in the terminal output (from here to the
> end of this email):
>
> make[1]: Entering directory '/home/eggert/src/gnu/emacs/static-checking/test'
>   GEN      lisp/calendar/todo-mode-tests.log
> Running 42 tests (2025-02-17 17:06:39-0800, selector ‘(not (or (tag :unstable)
> (tag :nativecomp)))’)
> Enter a non-existing file name: Test todo-test-add-and-delete-file backtrace:
>   read-from-minibuffer("Enter a non-existing file name: " nil (keymap
>   completing-read-default("Enter a non-existing file name: " ("todo-te
>   completing-read("Enter a non-existing file name: " ("todo-test-1" "t
>   todo-validate-name("todo-test-2" file)
>   todo-add-file()
>   funcall-interactively(todo-add-file)
>   call-interactively(todo-add-file)
>   (progn (fset 'todo-read-category vnew) (fset 'todo-read-file-name vn
>   (unwind-protect (progn (fset 'todo-read-category vnew) (fset 'todo-r
>   (let* ((vnew #'(lambda (_prompt) file0)) (vnew #'(lambda (_prompt &o
>   (let ((file0 (expand-file-name (concat file ".todo") (let* ((testfil
>   todo-test--add-file("todo-test-2" "cat21")
>   (let* ((file (concat todo-directory "todo-test-2.todo")) (file-nb (f
>   (progn (todo-show) (let* ((fn-724 #'equal) (args-725 (condition-case
>   (unwind-protect (progn (todo-show) (let* ((fn-724 #'equal) (args-725
>   (let* ((abbreviated-home-dir nil) (process-environment (cons (format
>   (progn (let* ((abbreviated-home-dir nil) (process-environment (cons
>   (unwind-protect (progn (let* ((abbreviated-home-dir nil) (process-en
>   (let* ((coding-system-for-write nil) (temp-file (file-name-as-direct
>   #f(lambda () [t] (let* ((coding-system-for-write nil) (temp-file (fi
>   #f(compiled-function () #<bytecode 0x232899316c83114>)()
>   handler-bind-1(#f(compiled-function () #<bytecode 0x232899316c83114>
>   ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
>   ert-run-test(#s(ert-test :name todo-test-add-and-delete-file :docume
>   ert-run-or-rerun-test(#s(ert--stats :selector ... :tests ... :test-m
>   ert-run-tests((not (or (tag :unstable) (tag :nativecomp))) #f(compil
>   ert-run-tests-batch((not (or (tag :unstable) (tag :nativecomp))))
>   ert-run-tests-batch-and-exit((not (or (tag :unstable) (tag :nativeco
>   eval((ert-run-tests-batch-and-exit '(not (or (tag :unstable) (tag :n
>   command-line-1(("-L" ":." "-l" "ert" "--eval" "(setq treesit-extra-l
>   command-line()
>   normal-top-level()
> Test todo-test-add-and-delete-file condition:
>     (end-of-file "Error reading from stdin")
>    FAILED   1/42  todo-test-add-and-delete-file (0.023699 sec) at
>    lisp/calendar/todo-mode-tests.el:823
[...]
> Ran 42 tests, 41 results as expected, 1 unexpected (2025-02-17 17:06:40-0800,
> 0.558779 sec)
>
> 1 unexpected results:
>    FAILED  todo-test-add-and-delete-file
>
> make[1]: *** [Makefile:185: lisp/calendar/todo-mode-tests.log] Error 1
> make[1]: Leaving directory '/home/eggert/src/gnu/emacs/static-checking/test'
> make: *** [Makefile:251: lisp/calendar/todo-mode-tests] Error 2