[Top][All Lists]

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

master 01df347947 1/2: Use `permission-denied' in Tramp tests, and more

From: Michael Albinus
Subject: master 01df347947 1/2: Use `permission-denied' in Tramp tests, and more
Date: Mon, 27 Dec 2021 13:53:13 -0500 (EST)

branch: master
commit 01df347947c8785c7c21d5a2baa12de2ffde80dd
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Use `permission-denied' in Tramp tests, and more
    * lisp/net/tramp-crypt.el (tramp-crypt-maybe-open-connection):
    Simplify code.
    * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-system-info):
    Adapt for "mtp" method.
    * test/lisp/net/tramp-tests.el (tramp-test18-file-attributes):
    Use `permission-denied' error.  Simplify code.
    (tramp-test24-file-acl, tramp-test26-file-name-completion):
    Simplify code.
 lisp/net/tramp-crypt.el      |  2 +-
 lisp/net/tramp-gvfs.el       |  6 ++++--
 test/lisp/net/tramp-tests.el | 10 +++++-----
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/lisp/net/tramp-crypt.el b/lisp/net/tramp-crypt.el
index 4ff8e6bbf1..dd2ba23f0f 100644
--- a/lisp/net/tramp-crypt.el
+++ b/lisp/net/tramp-crypt.el
@@ -323,7 +323,7 @@ connection if a previous connection has died for some 
           tramp-crypt-encfs-config (tramp-crypt-get-remote-dir vec)))
         (local-config (tramp-crypt-config-file-name vec)))
     ;; There is no local encfs6 config file.
-    (when (not (file-exists-p local-config))
+    (unless (file-exists-p local-config)
       (if (and tramp-crypt-save-encfs-config-remote
               (file-exists-p remote-config))
          ;; Copy remote encfs6 config file if possible.
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index 6b0299aa09..292da5a166 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1524,8 +1524,10 @@ If FILE-SYSTEM is non-nil, return file system 
       (when (or size free)
        (list (and size (string-to-number size))
              (and free (string-to-number free))
-             (and size used
-                  (- (string-to-number size) (string-to-number used))))))))
+             ;; "mtp" connections do not return "filesystem::used".
+             (or (and size used
+                      (- (string-to-number size) (string-to-number used)))
+                 (and free (string-to-number free))))))))
 (defun tramp-gvfs-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index f14d63af4c..7ba5a87076 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3405,12 +3405,12 @@ This tests also `access-file', `file-readable-p',
            (when (tramp--test-supports-set-file-modes-p)
              (write-region "foo" nil tmp-name1)
              ;; A file is always accessible for user "root".
-             (when (not (zerop (file-attribute-user-id
-                                (file-attributes tmp-name1))))
+             (unless
+                 (zerop (file-attribute-user-id (file-attributes tmp-name1)))
                (set-file-modes tmp-name1 0)
                 (access-file tmp-name1 "error")
-                :type 'file-error)
+                :type tramp-permission-denied)
                (set-file-modes tmp-name1 #o777))
              (delete-file tmp-name1))
@@ -4095,7 +4095,7 @@ This tests also `make-symbolic-link', `file-truename' and 
            (should (file-acl tmp-name2))
            (should (string-equal (file-acl tmp-name1) (file-acl tmp-name2)))
            ;; Different permissions mean different ACLs.
-           (when (not (tramp--test-windows-nt-or-smb-p))
+           (unless (tramp--test-windows-nt-or-smb-p)
              (set-file-modes tmp-name1 #o777)
              (set-file-modes tmp-name2 #o444)
@@ -4297,7 +4297,7 @@ This tests also `make-symbolic-link', `file-truename' and 
   ;; Method and host name in completion mode.  This kind of completion
   ;; does not work on MS Windows.
-  (when (not (memq system-type '(cygwin windows-nt)))
+  (unless (memq system-type '(cygwin windows-nt))
     (let ((method (file-remote-p tramp-test-temporary-file-directory 'method))
          (host (file-remote-p tramp-test-temporary-file-directory 'host))
           (orig-syntax tramp-syntax))

reply via email to

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