]> git.eshelyaron.com Git - emacs.git/commitdiff
Use `permission-denied' in Tramp tests, and more
authorMichael Albinus <michael.albinus@gmx.de>
Mon, 27 Dec 2021 18:51:58 +0000 (19:51 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Mon, 27 Dec 2021 18:51:58 +0000 (19:51 +0100)
* 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
lisp/net/tramp-gvfs.el
test/lisp/net/tramp-tests.el

index 4ff8e6bbf1267d7781231365cec521ed7a842722..dd2ba23f0f0d938895028bfc6763dfc58924ac8f 100644 (file)
@@ -323,7 +323,7 @@ connection if a previous connection has died for some reason."
           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.
index 6b0299aa09765d3c0d762559ddc10eac1bb7ccfd..292da5a16698474b89e56e63203466089447c553 100644 (file)
@@ -1524,8 +1524,10 @@ If FILE-SYSTEM is non-nil, return file system attributes."
       (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."
index f14d63af4cd6348a6243a4de9023d23d84dd462b..7ba5a8707667e00da5a16867b4cc03f6a8f3be71 100644 (file)
@@ -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)
                (should-error
                 (access-file tmp-name1 "error")
-                :type 'file-error)
+                :type tramp-permission-denied)
                (set-file-modes tmp-name1 #o777))
              (delete-file tmp-name1))
            (should-error
@@ -4095,7 +4095,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
            (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)
              (should-not
@@ -4297,7 +4297,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
 
   ;; 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))