all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Failing test in files-tests.el on MS-Windows
@ 2019-02-15 10:34 Eli Zaretskii
  2019-02-15 12:00 ` Michael Albinus
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2019-02-15 10:34 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

Michael,

The (relatively) recently added test in files-tests.el fails on
MS-Windows:

  Test files-tests-file-name-non-special-insert-directory backtrace:
    signal(ert-test-failed (((should-error (with-temp-buffer (insert-dir
    ert-fail(((should-error (with-temp-buffer (insert-directory nospecia
    (if errorp764 nil (ert-fail (append (funcall form-description-fn-765
    (let ((errorp764 nil) (form-description-fn-765 #'(lambda nil form-de
    (let (form-description-763) (let ((errorp764 nil) (form-description-
    (let ((value-762 (gensym "ert-form-evaluation-aborted-"))) (let (for
    (progn (let ((value-762 (gensym "ert-form-evaluation-aborted-"))) (l
    (unwind-protect (progn (let ((value-762 (gensym "ert-form-evaluation
    (let* ((temporary-file-directory (file-truename temporary-file-direc
    (closure (t) nil (let* ((temporary-file-directory (file-truename tem
    ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
    ert-run-test(#s(ert-test :name files-tests-file-name-non-special-ins
    ert-run-or-rerun-test(#s(ert--stats :selector (not ...) :tests [... 
    ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type
    ert-run-tests-batch((not (tag :unstable)))
    ert-run-tests-batch-and-exit((not (tag :unstable)))
    eval((ert-run-tests-batch-and-exit '(not (tag :unstable))))
    command-line-1((#("-L" 0 2 (charset cp862)) #(";." 0 2 (charset cp86
    command-line()
    normal-top-level()
  Test files-tests-file-name-non-special-insert-directory condition:
      (ert-test-failed
       ((should-error
	 (with-temp-buffer
	   (insert-directory nospecial-dir "")))
	:form
	(let
	    ((temp-buffer ...))
	  (save-current-buffer
	    (set-buffer temp-buffer)
	    (unwind-protect ... ...)))
	:value nil :fail-reason "did not signal an error"))
     FAILED  56/79  files-tests-file-name-non-special-insert-directory (2.015561 sec)
  Test files-tests-file-name-non-special-insert-directory backtrace:
    signal(ert-test-failed (((should-error (with-temp-buffer (insert-dir
    ert-fail(((should-error (with-temp-buffer (insert-directory nospecia
    (if errorp764 nil (ert-fail (append (funcall form-description-fn-765
    (let ((errorp764 nil) (form-description-fn-765 #'(lambda nil form-de
    (let (form-description-763) (let ((errorp764 nil) (form-description-
    (let ((value-762 (gensym "ert-form-evaluation-aborted-"))) (let (for
    (progn (let ((value-762 (gensym "ert-form-evaluation-aborted-"))) (l
    (unwind-protect (progn (let ((value-762 (gensym "ert-form-evaluation
    (let* ((temporary-file-directory (file-truename temporary-file-direc
    (closure (t) nil (let* ((temporary-file-directory (file-truename tem
    ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
    ert-run-test(#s(ert-test :name files-tests-file-name-non-special-ins
    ert-run-or-rerun-test(#s(ert--stats :selector (not ...) :tests [... 
    ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type
    ert-run-tests-batch((not (tag :unstable)))
    ert-run-tests-batch-and-exit((not (tag :unstable)))
    eval((ert-run-tests-batch-and-exit '(not (tag :unstable))))
    command-line-1((#("-L" 0 2 (charset cp862)) #(";." 0 2 (charset cp86
    command-line()
    normal-top-level()
  Test files-tests-file-name-non-special-insert-directory condition:
      (ert-test-failed
       ((should-error
	 (with-temp-buffer
	   (insert-directory nospecial-dir "")))
	:form
	(let
	    ((temp-buffer ...))
	  (save-current-buffer
	    (set-buffer temp-buffer)
	    (unwind-protect ... ...)))
	:value nil :fail-reason "did not signal an error"))
     FAILED  56/79  files-tests-file-name-non-special-insert-directory (2.015561 sec)

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).

Thanks.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Failing test in files-tests.el on MS-Windows
  2019-02-15 10:34 Failing test in files-tests.el on MS-Windows Eli Zaretskii
@ 2019-02-15 12:00 ` Michael Albinus
  2019-02-15 13:47   ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Albinus @ 2019-02-15 12:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> 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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Failing test in files-tests.el on MS-Windows
  2019-02-15 12:00 ` Michael Albinus
@ 2019-02-15 13:47   ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2019-02-15 13:47 UTC (permalink / raw)
  To: Michael Albinus; +Cc: emacs-devel

> From: Michael Albinus <michael.albinus@gmx.de>
> Cc: emacs-devel@gnu.org
> Date: Fri, 15 Feb 2019 13:00:48 +0100
> 
> --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, fixed.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-15 13:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-15 10:34 Failing test in files-tests.el on MS-Windows Eli Zaretskii
2019-02-15 12:00 ` Michael Albinus
2019-02-15 13:47   ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.