mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Tramp: Do not raise an error when not connected (Bug#78572)
* lisp/net/tramp-cmds.el (tramp-cleanup-connection): Use read syntax #' for `tramp-timeout-session', * lisp/net/tramp.el (tramp-barf-if-file-missing): Do not raise an error when not connected. (Bug#78572) (tramp-file-name-handler): Do not force the backtrace. (tramp-connectable-p): Check also, whether initial handshake is finished. (tramp-skeleton-directory-files) (tramp-skeleton-directory-files-and-attributes) (tramp-skeleton-set-file-modes-times-uid-gid): Rearrange sending `file-missing' error. (tramp-handle-access-file, tramp-handle-unlock-file): Use `tramp-connectable-p'. * test/lisp/net/tramp-tests.el (project-mode-line-format) (project-mode-line): Declare. (tramp-test48-session-timeout): New test. (tramp-test49-auto-load, tramp-test49-delay-load) (tramp-test49-recursive-load, tramp-test49-remote-load-path) (tramp-test50-without-remote-files, tramp-test51-unload): Rename.
This commit is contained in:
parent
1b03a348f7
commit
55691c61d4
4 changed files with 139 additions and 97 deletions
|
|
@ -67,6 +67,7 @@
|
|||
(require 'vc-git)
|
||||
(require 'vc-hg)
|
||||
|
||||
(declare-function project-mode-line-format "project")
|
||||
(declare-function tramp-check-remote-uname "tramp-sh")
|
||||
(declare-function tramp-find-executable "tramp-sh")
|
||||
(declare-function tramp-get-remote-chmod-h "tramp-sh")
|
||||
|
|
@ -89,6 +90,7 @@
|
|||
(defvar tramp-use-connection-share)
|
||||
|
||||
;; Declared in Emacs 30.1.
|
||||
(defvar project-mode-line)
|
||||
(defvar remote-file-name-access-timeout)
|
||||
(defvar remote-file-name-inhibit-delete-by-moving-to-trash)
|
||||
|
||||
|
|
@ -8374,8 +8376,52 @@ process sentinels. They shall not disturb each other."
|
|||
;; Cleanup.
|
||||
(tramp-cleanup-connection tramp-test-vec 'keep-debug))
|
||||
|
||||
;; This test is inspired by Bug#78572.
|
||||
(ert-deftest tramp-test48-session-timeout ()
|
||||
"Check that Tramp handles a session timeout properly."
|
||||
(skip-unless (tramp--test-enabled))
|
||||
(skip-unless
|
||||
(tramp-get-method-parameter tramp-test-vec 'tramp-session-timeout))
|
||||
|
||||
;; We want to see the timeout message.
|
||||
(tramp--test-instrument-test-case 3
|
||||
(let ((remote-file-name-inhibit-cache t)
|
||||
(tmp-name (tramp--test-make-temp-name)))
|
||||
(unwind-protect
|
||||
(progn
|
||||
(should-not (file-exists-p tmp-name))
|
||||
(write-region "foo" nil tmp-name)
|
||||
(should (file-exists-p tmp-name))
|
||||
|
||||
(tramp-timeout-session tramp-test-vec)
|
||||
(should (file-exists-p tmp-name))
|
||||
(should (directory-files (file-name-directory tmp-name)))
|
||||
|
||||
;; `project-mode-line' was introduced in Emacs 30.1.
|
||||
(when (boundp 'project-mode-line)
|
||||
(require 'project)
|
||||
(ert-with-message-capture captured-messages
|
||||
(let ((project-mode-line t))
|
||||
(with-temp-buffer
|
||||
(set-visited-file-name tmp-name)
|
||||
(insert "foo")
|
||||
(should (buffer-modified-p))
|
||||
(tramp-timeout-session tramp-test-vec)
|
||||
;; This calls `file-directory-p' and
|
||||
;; `directory-files'. Shouldn't raise an error when
|
||||
;; not connected.
|
||||
(project-mode-line-format)
|
||||
;; Steal the file lock.
|
||||
(cl-letf (((symbol-function #'ask-user-about-lock) #'always))
|
||||
(save-buffer)))
|
||||
(should-not
|
||||
(string-match-p "File is missing:" captured-messages))))))
|
||||
|
||||
;; Cleanup.
|
||||
(ignore-errors (delete-file tmp-name))))))
|
||||
|
||||
;; This test is inspired by Bug#29163.
|
||||
(ert-deftest tramp-test48-auto-load ()
|
||||
(ert-deftest tramp-test49-auto-load ()
|
||||
"Check that Tramp autoloads properly."
|
||||
;; If we use another syntax but `default', Tramp is already loaded
|
||||
;; due to the `tramp-change-syntax' call.
|
||||
|
|
@ -8400,7 +8446,7 @@ process sentinels. They shall not disturb each other."
|
|||
(mapconcat #'shell-quote-argument load-path " -L ")
|
||||
(shell-quote-argument code)))))))
|
||||
|
||||
(ert-deftest tramp-test48-delay-load ()
|
||||
(ert-deftest tramp-test49-delay-load ()
|
||||
"Check that Tramp is loaded lazily, only when needed."
|
||||
;; Tramp is neither loaded at Emacs startup, nor when completing a
|
||||
;; non-Tramp file name like "/foo". Completing a Tramp-alike file
|
||||
|
|
@ -8430,7 +8476,7 @@ process sentinels. They shall not disturb each other."
|
|||
(mapconcat #'shell-quote-argument load-path " -L ")
|
||||
(shell-quote-argument (format code tm)))))))))
|
||||
|
||||
(ert-deftest tramp-test48-recursive-load ()
|
||||
(ert-deftest tramp-test49-recursive-load ()
|
||||
"Check that Tramp does not fail due to recursive load."
|
||||
(skip-unless (tramp--test-enabled))
|
||||
|
||||
|
|
@ -8454,7 +8500,7 @@ process sentinels. They shall not disturb each other."
|
|||
(mapconcat #'shell-quote-argument load-path " -L ")
|
||||
(shell-quote-argument code))))))))
|
||||
|
||||
(ert-deftest tramp-test48-remote-load-path ()
|
||||
(ert-deftest tramp-test49-remote-load-path ()
|
||||
"Check that Tramp autoloads its packages with remote `load-path'."
|
||||
;; `tramp-cleanup-all-connections' is autoloaded from tramp-cmds.el.
|
||||
;; It shall still work, when a remote file name is in the
|
||||
|
|
@ -8479,7 +8525,7 @@ process sentinels. They shall not disturb each other."
|
|||
(mapconcat #'shell-quote-argument load-path " -L ")
|
||||
(shell-quote-argument code)))))))
|
||||
|
||||
(ert-deftest tramp-test49-without-remote-files ()
|
||||
(ert-deftest tramp-test50-without-remote-files ()
|
||||
"Check that Tramp can be suppressed."
|
||||
(skip-unless (tramp--test-enabled))
|
||||
|
||||
|
|
@ -8494,7 +8540,7 @@ process sentinels. They shall not disturb each other."
|
|||
(setq tramp-mode t)
|
||||
(should (file-remote-p ert-remote-temporary-file-directory)))
|
||||
|
||||
(ert-deftest tramp-test50-unload ()
|
||||
(ert-deftest tramp-test51-unload ()
|
||||
"Check that Tramp and its subpackages unload completely.
|
||||
Since it unloads Tramp, it shall be the last test to run."
|
||||
:tags '(:expensive-test)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue