bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21816: elisp-mode-tests fails on a case-preserving filesystem


From: Stephen Leake
Subject: bug#21816: elisp-mode-tests fails on a case-preserving filesystem
Date: Tue, 03 Nov 2015 03:17:42 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (windows-nt)

Juanma Barranquero <lekktu@gmail.com> writes:

> Package: emacs
> Version: 25.0.50
> Severity: minor
> X-Debbugs-CC: stephen_leake@stephe-leake.org
>
>
> Test xref-elisp-test-find-defs-feature-el fails on my Windows system
> because of a case-sensitive filename comparison.
>
> Basically
>
> ELISP> (aref (aref (car (elisp--xref-find-definitions 'xref)) 2) 3)
> "c:/devel/emacs/repo/trunk/lisp/progmodes/xref.el"
>
> ELISP> (aref (xref-make-elisp-location
>      'xref 'feature
>      (expand-file-name "../../lisp/progmodes/xref.el"
> emacs-test-dir))
>     3)
> "c:/Devel/emacs/repo/trunk/lisp/progmodes/xref.el"
>
> and the test fails at the d/D in c:/Devel vs. c:/devel (as seen in the log
> below).
>
> The value returned by `expand-file-name' is the real name as stored in the
> filesystem (the directory is called "Devel"). 

This is not caused by expand-file-name, but by the values passed to it.
In this case, `emacs-test-dir' has the "c:/Devel"; it is set by:

(defconst emacs-test-dir (file-name-directory (or load-file-name 
(buffer-file-name))))

I can reproduce the problem by adding a "downcase" to this; my emacs
test dir is in c:/Projects/..., but my load-path has the correct case.

> The value from
> `elisp--xref-find-definitions' ultimately comes from `locate-file', and
> reflects what's stored in `load-path' (which can be set by the user, so we
> cannot force it to have "correct" casing).

Well, since this is only a problem in a test run by developers (not
general users), we _could_ insist on that, but I agree it would be nice
not to.

> The test code in elisp-mode-tests.el uses `equal' to compare the xref
> structures. I can think a couple of ways to fix the test, but they are all
> quite ugly....

The canonical solution for case-insensitive string comparisons is to use
`downcase' on both values before using `equal'. This works for me:

(defun xref-elisp-test-run (xrefs expected-xrefs)
  (should (= (length xrefs) (length expected-xrefs)))
  (while xrefs
    (let* ((xref (pop xrefs))
           (expected (pop expected-xrefs))
           (expected-xref (or (when (consp expected) (car expected)) expected))
           (expected-source (when (consp expected) (cdr expected))))

      ;; Downcase the filename for case-insensitive file systems.
      (setf (xref-elisp-location-file (oref xref :location))
            (downcase (xref-elisp-location-file (oref xref :location))))

      (setf (xref-elisp-location-file (oref expected-xref :location))
            (downcase (xref-elisp-location-file (oref expected-xref 
:location))))

      (should (equal xref expected-xref))

      (xref--goto-location (xref-item-location xref))
      (back-to-indentation)
      (should (looking-at (or expected-source
                              (xref-elisp-test-descr-to-target expected)))))
    ))

together with:

;; We add 'downcase' here to deliberately cause a potential problem on
;; case-insensitive file systems. On such systems, `load-file-name'
;; may not have the same case as the real file system, since the user
;; can set `load-path' to have the wrong case. This is handled in
;; `xref-elisp-test-run'.
(defconst emacs-test-dir (downcase (file-name-directory (or load-file-name 
(buffer-file-name)))))


If no one objects to this, I'll commit it.

-- 
-- Stephe





reply via email to

[Prev in Thread] Current Thread [Next in Thread]