]> git.eshelyaron.com Git - emacs.git/commitdiff
Tramp code cleanup
authorMichael Albinus <michael.albinus@gmx.de>
Sat, 11 Sep 2021 13:35:51 +0000 (15:35 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Sat, 11 Sep 2021 13:35:51 +0000 (15:35 +0200)
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-make-directory): Simplify.

* lisp/net/tramp-sh.el (tramp-methods) <telnet, nc>: Don't use
"%n" marker.

* test/lisp/net/tramp-tests.el (tramp-test13-make-directory): Merge with
`tramp-test-make-directory-helper' and
`tramp-test13-make-directory-with-file-modes'.
(tramp-test44-asynchronous-requests): Use always the same
operation in timer.

lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
test/lisp/net/tramp-tests.el

index eb889bb4f2872577bac890cf0000155ca05d5b51..25deead81333a83f917cdbbc3e80918be1f37508 100644 (file)
@@ -1574,10 +1574,10 @@ If FILE-SYSTEM is non-nil, return file system attributes."
        (when (and parents (not (file-directory-p ldir)))
          (make-directory ldir parents))
        ;; Just do it.
-       (or (let ((mkdir-succeeded
-                  (tramp-gvfs-send-command
-                   v "gvfs-mkdir" (tramp-gvfs-url-file-name dir))))
-             (if mkdir-succeeded (set-file-modes dir (default-file-modes)))
+       (or (when-let ((mkdir-succeeded
+                       (tramp-gvfs-send-command
+                        v "gvfs-mkdir" (tramp-gvfs-url-file-name dir))))
+             (set-file-modes dir (default-file-modes))
              mkdir-succeeded)
            (and parents (file-directory-p dir))
            (tramp-error v 'file-error "Couldn't make directory %s" dir))))))
index e57145e8e7c14ec5ab164002283044a0575a3842..dc049782fd243a5bd4017c40fe707f1026f5a6f4 100644 (file)
@@ -244,14 +244,14 @@ The string is used in `tramp-methods'.")
  (add-to-list 'tramp-methods
               `("telnet"
                 (tramp-login-program        "telnet")
-                (tramp-login-args           (("%h") ("%p") ("%n")))
+                (tramp-login-args           (("%h") ("%p")))
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))))
  (add-to-list 'tramp-methods
               `("nc"
                 (tramp-login-program        "telnet")
-                (tramp-login-args           (("%h") ("%p") ("%n")))
+                (tramp-login-args           (("%h") ("%p")))
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
index 393302d7e1b53589ee2d136014d23ee72f6d4c44..af4f45d6913b76998baa65c2e683a4c5983fe429 100644 (file)
@@ -2765,12 +2765,12 @@ This checks also `file-name-as-directory', `file-name-directory',
            (ignore-errors (delete-directory source 'recursive))
            (ignore-errors (delete-directory target 'recursive))))))))
 
-(defun tramp-test-make-directory-helper (test-default-file-modes-p)
-  "Helper test used by tramp-test13-make-directory* tests."
-  (dolist (quoted (if (and (tramp--test-expensive-test)
-                           (not test-default-file-modes-p))
-                      '(nil t)
-                    '(nil)))
+(ert-deftest tramp-test13-make-directory ()
+  "Check `make-directory'.
+This tests also `file-directory-p' and `file-accessible-directory-p'."
+  (skip-unless (tramp--test-enabled))
+
+  (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
     (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
           (tmp-name2 (expand-file-name "foo/bar" tmp-name1))
           (unusual-file-mode-1 #o740)
@@ -2784,9 +2784,9 @@ This checks also `file-name-as-directory', `file-name-directory',
             :type 'file-already-exists)
            (should (file-directory-p tmp-name1))
            (should (file-accessible-directory-p tmp-name1))
-           (and test-default-file-modes-p
-                (should (equal (format "%#o" unusual-file-mode-1)
-                               (format "%#o" (file-modes tmp-name1)))))
+           (when (tramp--test-supports-file-modes-p)
+             (should (equal (format "%#o" unusual-file-mode-1)
+                            (format "%#o" (file-modes tmp-name1)))))
            (should-error
             (make-directory tmp-name2)
             :type 'file-error)
@@ -2794,9 +2794,9 @@ This checks also `file-name-as-directory', `file-name-directory',
              (make-directory tmp-name2 'parents))
            (should (file-directory-p tmp-name2))
            (should (file-accessible-directory-p tmp-name2))
-           (and test-default-file-modes-p
-                (should (equal (format "%#o" unusual-file-mode-2)
-                               (format "%#o" (file-modes tmp-name2)))))
+           (when (tramp--test-supports-file-modes-p)
+             (should (equal (format "%#o" unusual-file-mode-2)
+                            (format "%#o" (file-modes tmp-name2)))))
            ;; If PARENTS is non-nil, `make-directory' shall not
            ;; signal an error when DIR exists already.
            (make-directory tmp-name2 'parents))
@@ -2804,20 +2804,6 @@ This checks also `file-name-as-directory', `file-name-directory',
        ;; Cleanup.
        (ignore-errors (delete-directory tmp-name1 'recursive))))))
 
-(ert-deftest tramp-test13-make-directory ()
-  "Check `make-directory'.
-This tests also `file-directory-p' and `file-accessible-directory-p'."
-  (skip-unless (tramp--test-enabled))
-  (tramp-test-make-directory-helper nil))
-
-(ert-deftest tramp-test13-make-directory-with-file-modes ()
-  "Check that `make-directory' honors `default-file-modes'.
-This is a separate test from `tramp-test13-make-directory' so
-it can be skipped for backends that do not support file modes."
-  (skip-unless (tramp--test-enabled))
-  (skip-unless (tramp--test-supports-file-modes-p))
-  (tramp-test-make-directory-helper t))
-
 (ert-deftest tramp-test14-delete-directory ()
   "Check `delete-directory'."
   (skip-unless (tramp--test-enabled))
@@ -6763,11 +6749,6 @@ process sentinels.  They shall not disturb each other."
             (cond
              ((getenv "EMACS_HYDRA_CI") 10)
              (t 1)))
-           ;; We must distinguish due to performance reasons.
-           (timer-operation
-            (cond
-             ((tramp--test-mock-p) #'vc-registered)
-             (t #'file-attributes)))
           ;; This is when all timers start.  We check inside the
           ;; timer function, that we don't exceed timeout.
           (timer-start (current-time))
@@ -6803,7 +6784,7 @@ process sentinels.  They shall not disturb each other."
                           (cons 'remote-file-error debug-ignored-errors)))
                       (tramp--test-message
                        "Start timer %s %s" file (current-time-string))
-                     (funcall timer-operation file)
+                     (vc-registered file)
                       (tramp--test-message
                        "Stop timer %s %s" file (current-time-string))
                       ;; Adjust timer if it takes too much time.