aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2021-09-11 15:35:51 +0200
committerMichael Albinus2021-09-11 15:35:51 +0200
commitef65d717d0a1eeb6530176b59aa03cd09efb5fa9 (patch)
treed584da3097eeaa91902e789d50e6c005e6327471
parent6343384348180b18be191be64d7106c4866c0675 (diff)
downloademacs-ef65d717d0a1eeb6530176b59aa03cd09efb5fa9.tar.gz
emacs-ef65d717d0a1eeb6530176b59aa03cd09efb5fa9.zip
Tramp code cleanup
* 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.
-rw-r--r--lisp/net/tramp-gvfs.el8
-rw-r--r--lisp/net/tramp-sh.el4
-rw-r--r--test/lisp/net/tramp-tests.el45
3 files changed, 19 insertions, 38 deletions
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el
index eb889bb4f28..25deead8133 100644
--- a/lisp/net/tramp-gvfs.el
+++ b/lisp/net/tramp-gvfs.el
@@ -1574,10 +1574,10 @@ If FILE-SYSTEM is non-nil, return file system attributes."
1574 (when (and parents (not (file-directory-p ldir))) 1574 (when (and parents (not (file-directory-p ldir)))
1575 (make-directory ldir parents)) 1575 (make-directory ldir parents))
1576 ;; Just do it. 1576 ;; Just do it.
1577 (or (let ((mkdir-succeeded 1577 (or (when-let ((mkdir-succeeded
1578 (tramp-gvfs-send-command 1578 (tramp-gvfs-send-command
1579 v "gvfs-mkdir" (tramp-gvfs-url-file-name dir)))) 1579 v "gvfs-mkdir" (tramp-gvfs-url-file-name dir))))
1580 (if mkdir-succeeded (set-file-modes dir (default-file-modes))) 1580 (set-file-modes dir (default-file-modes))
1581 mkdir-succeeded) 1581 mkdir-succeeded)
1582 (and parents (file-directory-p dir)) 1582 (and parents (file-directory-p dir))
1583 (tramp-error v 'file-error "Couldn't make directory %s" dir)))))) 1583 (tramp-error v 'file-error "Couldn't make directory %s" dir))))))
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index e57145e8e7c..dc049782fd2 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -244,14 +244,14 @@ The string is used in `tramp-methods'.")
244 (add-to-list 'tramp-methods 244 (add-to-list 'tramp-methods
245 `("telnet" 245 `("telnet"
246 (tramp-login-program "telnet") 246 (tramp-login-program "telnet")
247 (tramp-login-args (("%h") ("%p") ("%n"))) 247 (tramp-login-args (("%h") ("%p")))
248 (tramp-remote-shell ,tramp-default-remote-shell) 248 (tramp-remote-shell ,tramp-default-remote-shell)
249 (tramp-remote-shell-login ("-l")) 249 (tramp-remote-shell-login ("-l"))
250 (tramp-remote-shell-args ("-c")))) 250 (tramp-remote-shell-args ("-c"))))
251 (add-to-list 'tramp-methods 251 (add-to-list 'tramp-methods
252 `("nc" 252 `("nc"
253 (tramp-login-program "telnet") 253 (tramp-login-program "telnet")
254 (tramp-login-args (("%h") ("%p") ("%n"))) 254 (tramp-login-args (("%h") ("%p")))
255 (tramp-remote-shell ,tramp-default-remote-shell) 255 (tramp-remote-shell ,tramp-default-remote-shell)
256 (tramp-remote-shell-login ("-l")) 256 (tramp-remote-shell-login ("-l"))
257 (tramp-remote-shell-args ("-c")) 257 (tramp-remote-shell-args ("-c"))
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 393302d7e1b..af4f45d6913 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -2765,12 +2765,12 @@ This checks also `file-name-as-directory', `file-name-directory',
2765 (ignore-errors (delete-directory source 'recursive)) 2765 (ignore-errors (delete-directory source 'recursive))
2766 (ignore-errors (delete-directory target 'recursive)))))))) 2766 (ignore-errors (delete-directory target 'recursive))))))))
2767 2767
2768(defun tramp-test-make-directory-helper (test-default-file-modes-p) 2768(ert-deftest tramp-test13-make-directory ()
2769 "Helper test used by tramp-test13-make-directory* tests." 2769 "Check `make-directory'.
2770 (dolist (quoted (if (and (tramp--test-expensive-test) 2770This tests also `file-directory-p' and `file-accessible-directory-p'."
2771 (not test-default-file-modes-p)) 2771 (skip-unless (tramp--test-enabled))
2772 '(nil t) 2772
2773 '(nil))) 2773 (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil)))
2774 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) 2774 (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted))
2775 (tmp-name2 (expand-file-name "foo/bar" tmp-name1)) 2775 (tmp-name2 (expand-file-name "foo/bar" tmp-name1))
2776 (unusual-file-mode-1 #o740) 2776 (unusual-file-mode-1 #o740)
@@ -2784,9 +2784,9 @@ This checks also `file-name-as-directory', `file-name-directory',
2784 :type 'file-already-exists) 2784 :type 'file-already-exists)
2785 (should (file-directory-p tmp-name1)) 2785 (should (file-directory-p tmp-name1))
2786 (should (file-accessible-directory-p tmp-name1)) 2786 (should (file-accessible-directory-p tmp-name1))
2787 (and test-default-file-modes-p 2787 (when (tramp--test-supports-file-modes-p)
2788 (should (equal (format "%#o" unusual-file-mode-1) 2788 (should (equal (format "%#o" unusual-file-mode-1)
2789 (format "%#o" (file-modes tmp-name1))))) 2789 (format "%#o" (file-modes tmp-name1)))))
2790 (should-error 2790 (should-error
2791 (make-directory tmp-name2) 2791 (make-directory tmp-name2)
2792 :type 'file-error) 2792 :type 'file-error)
@@ -2794,9 +2794,9 @@ This checks also `file-name-as-directory', `file-name-directory',
2794 (make-directory tmp-name2 'parents)) 2794 (make-directory tmp-name2 'parents))
2795 (should (file-directory-p tmp-name2)) 2795 (should (file-directory-p tmp-name2))
2796 (should (file-accessible-directory-p tmp-name2)) 2796 (should (file-accessible-directory-p tmp-name2))
2797 (and test-default-file-modes-p 2797 (when (tramp--test-supports-file-modes-p)
2798 (should (equal (format "%#o" unusual-file-mode-2) 2798 (should (equal (format "%#o" unusual-file-mode-2)
2799 (format "%#o" (file-modes tmp-name2))))) 2799 (format "%#o" (file-modes tmp-name2)))))
2800 ;; If PARENTS is non-nil, `make-directory' shall not 2800 ;; If PARENTS is non-nil, `make-directory' shall not
2801 ;; signal an error when DIR exists already. 2801 ;; signal an error when DIR exists already.
2802 (make-directory tmp-name2 'parents)) 2802 (make-directory tmp-name2 'parents))
@@ -2804,20 +2804,6 @@ This checks also `file-name-as-directory', `file-name-directory',
2804 ;; Cleanup. 2804 ;; Cleanup.
2805 (ignore-errors (delete-directory tmp-name1 'recursive)))))) 2805 (ignore-errors (delete-directory tmp-name1 'recursive))))))
2806 2806
2807(ert-deftest tramp-test13-make-directory ()
2808 "Check `make-directory'.
2809This tests also `file-directory-p' and `file-accessible-directory-p'."
2810 (skip-unless (tramp--test-enabled))
2811 (tramp-test-make-directory-helper nil))
2812
2813(ert-deftest tramp-test13-make-directory-with-file-modes ()
2814 "Check that `make-directory' honors `default-file-modes'.
2815This is a separate test from `tramp-test13-make-directory' so
2816it can be skipped for backends that do not support file modes."
2817 (skip-unless (tramp--test-enabled))
2818 (skip-unless (tramp--test-supports-file-modes-p))
2819 (tramp-test-make-directory-helper t))
2820
2821(ert-deftest tramp-test14-delete-directory () 2807(ert-deftest tramp-test14-delete-directory ()
2822 "Check `delete-directory'." 2808 "Check `delete-directory'."
2823 (skip-unless (tramp--test-enabled)) 2809 (skip-unless (tramp--test-enabled))
@@ -6763,11 +6749,6 @@ process sentinels. They shall not disturb each other."
6763 (cond 6749 (cond
6764 ((getenv "EMACS_HYDRA_CI") 10) 6750 ((getenv "EMACS_HYDRA_CI") 10)
6765 (t 1))) 6751 (t 1)))
6766 ;; We must distinguish due to performance reasons.
6767 (timer-operation
6768 (cond
6769 ((tramp--test-mock-p) #'vc-registered)
6770 (t #'file-attributes)))
6771 ;; This is when all timers start. We check inside the 6752 ;; This is when all timers start. We check inside the
6772 ;; timer function, that we don't exceed timeout. 6753 ;; timer function, that we don't exceed timeout.
6773 (timer-start (current-time)) 6754 (timer-start (current-time))
@@ -6803,7 +6784,7 @@ process sentinels. They shall not disturb each other."
6803 (cons 'remote-file-error debug-ignored-errors))) 6784 (cons 'remote-file-error debug-ignored-errors)))
6804 (tramp--test-message 6785 (tramp--test-message
6805 "Start timer %s %s" file (current-time-string)) 6786 "Start timer %s %s" file (current-time-string))
6806 (funcall timer-operation file) 6787 (vc-registered file)
6807 (tramp--test-message 6788 (tramp--test-message
6808 "Stop timer %s %s" file (current-time-string)) 6789 "Stop timer %s %s" file (current-time-string))
6809 ;; Adjust timer if it takes too much time. 6790 ;; Adjust timer if it takes too much time.