Subject: Re: bug#43004: 28.0.50; Test failures due to symlinked Emacs sources

From: Stephen Berman <[email-masked]>
Date: Fri, 16 Oct 2020 16:15:43 +0200

On Fri, 16 Oct 2020 10:34:30 +0200 Lars Ingebrigtsen <[email-masked]> wrote:

> Stephen Berman <[email-masked]> writes:
>
>> However, concerning the latter, it seems that the tests expect
>> help-fns-function-description-header to return the quoted basename of
>> the file, while in my environment it returns the absolute filename.
>> Adjusting the regexp used in the tests fixes this issue (see the first
>> patch below) and then all tests pass regardless of where I start the
>> batch run.
>>
>> Concerning cl-generic-tests.el, using file-truename as in the second
>> patch below prevents the one failure, also regardless of where I start
>> the batch run.
>
> Thanks; I've now applied your patch to the trunk.

Thanks.

>> The same reduction but not full elimination is achieved by removing
>> the call to file-truename in the value of the defvar emacs-test-dir in
>> elisp-mode-tests.el.  So far I haven't figured out how to prevent
>> these five failures.
>
> Have you made any progress on these remaining failures, by any chance?

I looked at them again and, by trial and error, came up with the
attached patch, with which I now get no unexpected failures when running
the tests in batch mode, though when run interactively
xref-elisp-test-find-defs-defgeneric-implicit-generic still fails.  But
in any case I wouldn't blindly install this patch; someone who knows the
xref code really needs to look at what's going on here.

Steve Berman

diff --git a/test/lisp/progmodes/elisp-mode-tests.el b/test/lisp/progmodes/elisp-mode-tests.el
index 6c30e4f664..95259290ce 100644
--- a/test/lisp/progmodes/elisp-mode-tests.el
+++ b/test/lisp/progmodes/elisp-mode-tests.el
@@ -360,8 +360,7 @@ xref-elisp-deftest
 ;; `xref-elisp-test-run'.
 (defvar emacs-test-dir
   (funcall (if xref--case-insensitive 'downcase 'identity)
-           (file-truename (file-name-directory
-                           (or load-file-name (buffer-file-name))))))
+           (file-name-directory (or load-file-name (buffer-file-name)))))

 ;; alphabetical by test name
@@ -381,7 +380,8 @@ find-defs-constructor
     (xref-make "(cl-defstruct (xref-elisp-location (:constructor xref-make-elisp-location)))"
                (xref-make-elisp-location
                 'xref-elisp-location 'define-type
-                (expand-file-name "../../../lisp/progmodes/elisp-mode.el" emacs-test-dir)))
+                (file-truename
+                 (expand-file-name "../../../lisp/progmodes/elisp-mode.el" emacs-test-dir))))
     ;; It's not worth adding another special case to `xref-elisp-test-descr-to-target' for this
     "(cl-defstruct (xref-elisp-location")
    ))
@@ -392,11 +392,13 @@ find-defs-defalias-defun-el
    (xref-make "(defalias Buffer-menu-sort)"
 	      (xref-make-elisp-location
 	       'Buffer-menu-sort 'defalias
-	       (expand-file-name "../../../lisp/buff-menu.elc" emacs-test-dir)))
+	       (file-truename
+                 (expand-file-name "../../../lisp/buff-menu.elc" emacs-test-dir))))
    (xref-make "(defun tabulated-list-sort)"
 	      (xref-make-elisp-location
 	       'tabulated-list-sort nil
-	       (expand-file-name "../../../lisp/emacs-lisp/tabulated-list.el" emacs-test-dir)))
+	       (file-truename
+                 (expand-file-name "../../../lisp/emacs-lisp/tabulated-list.el" emacs-test-dir))))
    ))

 ;; FIXME: defconst
@@ -564,7 +566,8 @@ find-defs-defgeneric-el
 	       (cl--generic-load-hist-format
                 'xref-location-marker nil '(xref-elisp-location))
                'cl-defmethod
-	       (expand-file-name "../../../lisp/progmodes/elisp-mode.el" emacs-test-dir)))
+               (file-truename
+	        (expand-file-name "../../../lisp/progmodes/elisp-mode.el" emacs-test-dir))))
    (xref-make "(cl-defmethod xref-location-marker ((l xref-file-location)))"
 	      (xref-make-elisp-location
 	       (cl--generic-load-hist-format
@@ -724,7 +727,8 @@ find-defs-defun-el-defvar-c
     (xref-make "(defun abbrev-mode)"
                (xref-make-elisp-location
                 'abbrev-mode nil
-                (expand-file-name "../../../lisp/abbrev.el" emacs-test-dir)))
+                (file-truename
+                 (expand-file-name "../../../lisp/abbrev.el" emacs-test-dir))))
     "(define-minor-mode abbrev-mode"))
   )

@@ -778,11 +782,13 @@ find-defs-face-el
    (xref-make "(defvar font-lock-keyword-face)"
 	      (xref-make-elisp-location
 	       'font-lock-keyword-face 'defvar
-	       (expand-file-name "../../../lisp/font-lock.el" emacs-test-dir)))
+	       (file-truename
+                 (expand-file-name "../../../lisp/font-lock.el" emacs-test-dir))))
    (xref-make "(defface font-lock-keyword-face)"
 	      (xref-make-elisp-location
 	       'font-lock-keyword-face 'defface
-	       (expand-file-name "../../../lisp/font-lock.el" emacs-test-dir)))
+	       (file-truename
+                 (expand-file-name "../../../lisp/font-lock.el" emacs-test-dir))))
    ))

 (xref-elisp-deftest find-defs-face-eval