1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-05 15:11:30 -08:00

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.
This commit is contained in:
Michael Albinus 2021-09-11 15:35:51 +02:00
parent 6343384348
commit ef65d717d0
3 changed files with 19 additions and 38 deletions

View 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))))))

View 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"))

View 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.