summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2023-04-26 18:06:39 +0200
committerMichael Albinus <michael.albinus@gmx.de>2023-04-26 18:06:39 +0200
commit022f50ebe616e04bb34487a26d529ca08954d287 (patch)
tree617a2abdf09c7f17931a850f9e53709f7327b9f6 /test
parentd07815a7cc3540201afa06e3c80c061e9f497815 (diff)
downloademacs-022f50ebe616e04bb34487a26d529ca08954d287.tar.gz
New command 'tramp-cleanup-some-buffers'
* doc/misc/tramp.texi (Cleanup remote connections): Document tramp-cleanup-some-buffers and tramp-cleanup-some-buffers-hook. * etc/NEWS: New command 'tramp-cleanup-some-buffers'. * lisp/net/tramp.el (tramp-handle-make-process): * lisp/net/tramp-adb.el (tramp-adb-handle-make-process): * lisp/net/tramp-sh.el (tramp-sh-handle-make-process): Use `tramp-taint-remote-process-buffer'. * lisp/net/tramp.el (tramp-post-process-creation): New defun. (tramp-handle-make-process): * lisp/net/tramp-adb.el (tramp-adb-maybe-open-connection): * lisp/net/tramp-crypt.el (tramp-crypt-maybe-open-connection): * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-file-notify-add-watch) (tramp-gvfs-maybe-open-connection): * lisp/net/tramp-rclone.el (tramp-rclone-maybe-open-connection): * lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band) (tramp-sh-handle-file-notify-add-watch) (tramp-maybe-open-connection): * lisp/net/tramp-smb.el (tramp-smb-handle-copy-directory) (tramp-smb-handle-file-acl, tramp-smb-handle-set-file-acl) (tramp-smb-maybe-open-connection): * lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-maybe-open-connection) (tramp-sudoedit-send-command): Use it. * lisp/net/tramp-cmds.el (tramp-tainted-remote-process-buffers): New defvar. (tramp-cleanup-dired-buffer-p) (tramp-delete-tainted-remote-process-buffer-function) (kill-buffer-hook, tramp-cleanup-remote-process-p) (tramp-cleanup-some-buffers): New defuns. (tramp-cleanup-some-buffers-hook): New defcustom. Add `buffer-file-name', `tramp-cleanup-dired-buffer-p' and `tramp-cleanup-remote-process-p' to the hook. (kill-buffer-hook): Add `tramp-delete-tainted-remote-process-buffer-function'. (tramp-cleanup-all-buffers): Rework. * lisp/net/tramp-compat.el (tramp-compat-always): New defalias. * test/lisp/net/tramp-tests.el (tramp--test-always): Delete. (tramp-test10-write-region, tramp-test21-file-links) (tramp--test-deftest-direct-async-process) (tramp-test37-make-auto-save-file-name) (tramp-test38-find-backup-file-name) (tramp-test39-make-lock-file-name) (tramp-test39-detect-external-change): Use `tramp-compat-always'.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/tramp-tests.el31
1 files changed, 10 insertions, 21 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 9bca6a03754..5fde783087e 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -297,16 +297,6 @@ is greater than 10.
(tramp--test-message
"%s %f sec" ,message (float-time (time-subtract nil start))))))
-;; `always' is introduced with Emacs 28.1.
-(defalias 'tramp--test-always
- (if (fboundp 'always)
- #'always
- (lambda (&rest _arguments)
- "Do nothing and return t.
-This function accepts any number of ARGUMENTS, but ignores them.
-Also see `ignore'."
- t)))
-
(ert-deftest tramp-test00-availability ()
"Test availability of Tramp functions."
:expected-result (if (tramp--test-enabled) :passed :failed)
@@ -2563,9 +2553,9 @@ This checks also `file-name-as-directory', `file-name-directory',
;; `tramp-test39-make-lock-file-name'.
;; Do not overwrite if excluded.
- (cl-letf (((symbol-function #'y-or-n-p) #'tramp--test-always)
+ (cl-letf (((symbol-function #'y-or-n-p) #'tramp-compat-always)
;; Ange-FTP.
- ((symbol-function 'yes-or-no-p) #'tramp--test-always))
+ ((symbol-function 'yes-or-no-p) #'tramp-compat-always))
(write-region "foo" nil tmp-name nil nil nil 'mustbenew))
(should-error
(cl-letf (((symbol-function #'y-or-n-p) #'ignore)
@@ -3991,7 +3981,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(should-error
(make-symbolic-link tmp-name1 tmp-name2 0)
:type 'file-already-exists)))
- (cl-letf (((symbol-function #'yes-or-no-p) #'tramp--test-always))
+ (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always))
(make-symbolic-link tmp-name1 tmp-name2 0)
(should
(string-equal
@@ -4071,7 +4061,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
(should-error
(add-name-to-file tmp-name1 tmp-name2 0)
:type 'file-already-exists))
- (cl-letf (((symbol-function #'yes-or-no-p) #'tramp--test-always))
+ (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always))
(add-name-to-file tmp-name1 tmp-name2 0)
(should (file-regular-p tmp-name2)))
(add-name-to-file tmp-name1 tmp-name2 'ok-if-already-exists)
@@ -5202,7 +5192,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
;; `file-truename' does it by side-effect. Suppress
;; `tramp--test-enabled', in order to keep the connection.
;; Suppress "Process ... finished" messages.
- (cl-letf (((symbol-function #'tramp--test-enabled) #'tramp--test-always)
+ (cl-letf (((symbol-function #'tramp--test-enabled) #'tramp-compat-always)
((symbol-function #'internal-default-process-sentinel)
#'ignore))
(file-truename ert-remote-temporary-file-directory)
@@ -6410,7 +6400,7 @@ INPUT, if non-nil, is a string sent to the process."
(tramp-cleanup-connection
tramp-test-vec 'keep-debug 'keep-password)
(cl-letf (((symbol-function #'yes-or-no-p)
- #'tramp--test-always))
+ #'tramp-compat-always))
(should (stringp (make-auto-save-file-name))))))))
;; Cleanup.
@@ -6556,8 +6546,7 @@ INPUT, if non-nil, is a string sent to the process."
:type 'file-error))
(tramp-cleanup-connection
tramp-test-vec 'keep-debug 'keep-password)
- (cl-letf (((symbol-function #'yes-or-no-p)
- #'tramp--test-always))
+ (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always))
(should (stringp (car (find-backup-file-name tmp-name1)))))))
;; Cleanup.
@@ -6712,8 +6701,7 @@ INPUT, if non-nil, is a string sent to the process."
:type 'file-error))
(tramp-cleanup-connection
tramp-test-vec 'keep-debug 'keep-password)
- (cl-letf (((symbol-function #'yes-or-no-p)
- #'tramp--test-always))
+ (cl-letf (((symbol-function #'yes-or-no-p) #'tramp-compat-always))
(write-region "foo" nil tmp-name1))))
;; Cleanup.
@@ -6783,7 +6771,8 @@ INPUT, if non-nil, is a string sent to the process."
(should (file-locked-p tmp-name)))))
;; `save-buffer' removes the file lock.
- (cl-letf (((symbol-function 'yes-or-no-p) #'tramp--test-always)
+ (cl-letf (((symbol-function 'yes-or-no-p)
+ #'tramp-compat-always)
((symbol-function 'read-char-choice)
(lambda (&rest _) ?y)))
(should (buffer-modified-p))