Subject: bug#37202: shadowfile-tests: two failures on macOS

From: Michael Albinus <[email-masked]>
Date: Fri, 20 Sep 2019 14:35:52 +0200

Paul Eggert <[email-masked]> writes:

Hi Paul,

> Could you explain how the backtrace implicates file-attributes? I see
> the following in the backtrace, but I don't see file-attributes listed
> there, and when I look at the tramp-handle-file-modes source it
> appears that file-attributes returned nil which is what I think you
> expected.
>
> Test shadow-test08-shadow-todo backtrace:
>   signal(args-out-of-range ("([] 1)"))
>   tramp-signal-hook-function(args-out-of-range ([] 1))
>   tramp-mode-string-to-int(nil)
>
> tramp-handle-file-modes(#("/mock:localhost:/build/shadowfile-tests75GTBI"
> 6 15 (tramp-default t)))

Right, `file-attributes' does not seem to have raised an error. But it
still seems to behave differently. The code is

--8<---------------cut here---------------start------------->8---
(defun tramp-handle-file-modes (filename)
  "Like `file-modes' for Tramp files."
  (let ((truename (or (file-truename filename) filename)))
    (when (file-exists-p truename)
      (tramp-mode-string-to-int
       (tramp-compat-file-attribute-modes (file-attributes truename))))))
--8<---------------cut here---------------end--------------->8---

That means, (file-attributes truename) returns nil although
(file-exists-p truename) returns non-nil. That seems to be a changed
behaviour to me, I don't remember having seen this before.

Arguably, the test shall better use `access-file' but
`file-exists-p'. But anyway, such subtle differences could break Tramp.

I still use conditional wording, because I cannot debug on hydra. And I
cannot say for sure that your changes have caused the problem.

For the time being, I'll adapt `tramp-handle-file-modes' in order to
unbreak the errors on hydra.

Best regards, Michael.