emacs-devel
[Top][All Lists]
Advanced

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

Re: Failing test in files-tests.el on MS-Windows


From: Michael Albinus
Subject: Re: Failing test in files-tests.el on MS-Windows
Date: Fri, 15 Feb 2019 13:00:48 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <address@hidden> writes:

> Michael,

Hi Eli,

> If you could tell a bit regarding why the expression
>
>   (with-temp-buffer (insert-directory nospecial-dir ""))
>
> is supposed to signal an error here, I could look into the possible
> reason(s).

That is rather tricky. We have two macros for every
files-tests-file-name-non-special-<foo> test:
`files-tests--with-temp-non-special' and
`files-tests--with-temp-non-special-and-file-name-handler'.

The first macro is rather a straight forward test. In case of
`files-tests-file-name-non-special-insert-directory', it does something
like (house-keeping stripped off):

--8<---------------cut here---------------start------------->8---
(let* ((temporary-file-directory (file-truename temporary-file-directory))
       (tmpdir (make-temp-file "files-tests" t))
       (nospecial-dir (file-name-quote tmpdir)))
  (should (equal (with-temp-buffer
                   (insert-directory nospecial-dir "")
                   (buffer-string))
                 (with-temp-buffer
                   (insert-directory tmpdir "")
                   (buffer-string)))))
--8<---------------cut here---------------end--------------->8---

The second macro adds an additional file name handler
`files-tests--special-file-name-handler', which cares about files with
trailing ".special" in their name, and which removes this part of the
file name, if they are not quoted. This is done just to see, whether
this file name handler has been invoked (which shouldn't for quoted file
names). So this part in the
`files-tests-file-name-non-special-insert-directory' test expands to

--8<---------------cut here---------------start------------->8---
(let* ((temporary-file-directory (file-truename temporary-file-directory))
       (file-name-handler-alist
        `((,files-tests--special-file-name-regexp
           . files-tests--special-file-name-handler)
          . ,file-name-handler-alist))
       (tmpdir (concat
                (make-temp-file "files-tests" t)
                files-tests--special-file-name-extension))
       (nospecial-dir (file-name-quote tmpdir)))
  (should-error (with-temp-buffer (insert-directory nospecial-dir ""))))
--8<---------------cut here---------------end--------------->8---

The idea is to check, that once a file name has been quoted with the
leading "/:", no other file name handler comes in play. In the given
example, a directory "/tmp/files-testsdItXI0" is created, and tmpdir
gets the value "/tmp/files-testsdItXI0.special".

(insert-directory tmpdir "") would work because the file name handler
removes the trailing ".special" from tmpdir.

(insert-directory nospecial-dir "") should raise an error, because the
file name handler is not invoked, and nospecial-dir does not exist.

This works fine under GNU/Linux. Luckily, I have a Windows machine under
control today. Running the second snippet under edebug, I get:

--8<---------------cut here---------------start------------->8---
c:/Users/albinmic/AppData/Local/Temp/files-testsKpFOvs.special: doesn’t exist 
or is inaccessible

Test failed: ((should-error (edebug-after (edebug-before 17) 21 
(with-temp-buffer (edebug-after (edebug-before 18) 20 (insert-directory 
(edebug-after 0 19 nospecial-dir) ""))))) :form (edebug-after 17 21 nil) :value 
nil :fail-reason "did not signal an error")
--8<---------------cut here---------------end--------------->8---

`insert-directory' has shown a bug, but it doesn't signal an error. This
seems to be the problem, and maybe also for the other failed tests you
have presented.

And indeed:

--8<---------------cut here---------------start------------->8---
(insert-directory "c:/dir/does/not/exist" "")
=> nil
--8<---------------cut here---------------end--------------->8---

But no error is signaled. Under GNU/Linux, I have

--8<---------------cut here---------------start------------->8---
(insert-directory "/dir/does/not/exist" "")
=> Debugger entered--Lisp error: (file-missing "Reading directory" "No such 
file or directory" "/dir/does/not/exist")
--8<---------------cut here---------------end--------------->8---

> Thanks.

Best regards, Michael.

PS: Thanks to Noam, who has written all these boring files-tests, which
uncover the problems now.

Best regards, Michael.



reply via email to

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